Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9cbd604d
提交
9cbd604d
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
boolean getX > isX
上级
32aef28f
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
22 行增加
和
19 行删除
+22
-19
Parser.java
h2/src/main/org/h2/command/Parser.java
+3
-4
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+2
-2
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+13
-8
AlterTableRename.java
h2/src/main/org/h2/command/ddl/AlterTableRename.java
+1
-1
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+3
-4
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
9cbd604d
...
...
@@ -3393,7 +3393,7 @@ public class Parser {
int
type
=
dataType
.
type
;
Column
column
=
new
Column
(
columnName
,
type
,
precision
,
scale
,
displaySize
);
if
(
templateColumn
!=
null
)
{
column
.
setNullable
(
templateColumn
.
get
Nullable
());
column
.
setNullable
(
templateColumn
.
is
Nullable
());
column
.
setDefaultExpression
(
session
,
templateColumn
.
getDefaultExpression
());
int
selectivity
=
templateColumn
.
getSelectivity
();
if
(
selectivity
!=
Constants
.
SELECTIVITY_DEFAULT
)
{
...
...
@@ -3774,8 +3774,7 @@ public class Parser {
columns
.
add
(
new
Column
(
c
,
Value
.
STRING
));
}
int
id
=
database
.
allocateObjectId
(
true
,
true
);
recursiveTable
=
schema
.
createTable
(
tempViewName
,
id
,
columns
,
false
,
true
,
false
,
Index
.
EMPTY_HEAD
,
session
);
recursiveTable
.
setTemporary
(
true
);
recursiveTable
=
schema
.
createTable
(
tempViewName
,
id
,
columns
,
true
,
false
,
true
,
false
,
Index
.
EMPTY_HEAD
,
session
);
session
.
addLocalTempTable
(
recursiveTable
);
String
querySQL
=
StringCache
.
getNew
(
sqlCommand
.
substring
(
parseIndex
));
read
(
"AS"
);
...
...
@@ -4616,7 +4615,7 @@ public class Parser {
}
else
{
String
columnName
=
readColumnIdentifier
();
Column
column
=
parseColumnForTable
(
columnName
);
if
(
column
.
getAutoIncrement
()
&&
column
.
get
PrimaryKey
())
{
if
(
column
.
isAutoIncrement
()
&&
column
.
is
PrimaryKey
())
{
column
.
setPrimaryKey
(
false
);
IndexColumn
[]
cols
=
new
IndexColumn
[]{
new
IndexColumn
()};
cols
[
0
].
columnName
=
column
.
getName
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
9cbd604d
...
...
@@ -249,7 +249,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
// parent relationship is already set with addConstraint
constraint
.
setComment
(
comment
);
if
(
table
.
getTemporary
()
&&
!
table
.
get
GlobalTemporary
())
{
if
(
table
.
isTemporary
()
&&
!
table
.
is
GlobalTemporary
())
{
session
.
addLocalTempTableConstraint
(
constraint
);
}
else
{
db
.
addSchemaObject
(
session
,
constraint
);
...
...
@@ -305,7 +305,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
}
private
boolean
canUseUniqueIndex
(
Index
idx
,
Table
table
,
IndexColumn
[]
cols
)
{
if
(
idx
.
getTable
()
!=
table
||
!
idx
.
getIndexType
().
get
Unique
())
{
if
(
idx
.
getTable
()
!=
table
||
!
idx
.
getIndexType
().
is
Unique
())
{
return
false
;
}
Column
[]
indexCols
=
idx
.
getColumns
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
9cbd604d
...
...
@@ -113,7 +113,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
Sequence
sequence
=
oldColumn
==
null
?
null
:
oldColumn
.
getSequence
();
switch
(
type
)
{
case
NOT_NULL:
{
if
(!
oldColumn
.
get
Nullable
())
{
if
(!
oldColumn
.
is
Nullable
())
{
// no change
break
;
}
...
...
@@ -123,7 +123,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
break
;
}
case
NULL:
{
if
(
oldColumn
.
get
Nullable
())
{
if
(
oldColumn
.
is
Nullable
())
{
// no change
break
;
}
...
...
@@ -147,9 +147,9 @@ public class AlterTableAlterColumn extends SchemaCommand {
oldColumn
.
setSequence
(
null
);
oldColumn
.
setDefaultExpression
(
session
,
null
);
oldColumn
.
setConvertNullToDefault
(
false
);
if
(
oldColumn
.
getNullable
()
&&
!
newColumn
.
get
Nullable
())
{
if
(
oldColumn
.
isNullable
()
&&
!
newColumn
.
is
Nullable
())
{
checkNoNullValues
();
}
else
if
(!
oldColumn
.
getNullable
()
&&
newColumn
.
get
Nullable
())
{
}
else
if
(!
oldColumn
.
isNullable
()
&&
newColumn
.
is
Nullable
())
{
checkNullable
();
}
convertToIdentityIfRequired
(
newColumn
);
...
...
@@ -185,7 +185,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
private
void
convertToIdentityIfRequired
(
Column
c
)
{
if
(
c
.
get
AutoIncrement
())
{
if
(
c
.
is
AutoIncrement
())
{
c
.
setOriginalSQL
(
"IDENTITY"
);
}
}
...
...
@@ -232,13 +232,14 @@ public class AlterTableAlterColumn extends SchemaCommand {
newColumns
.
remove
(
position
);
newColumns
.
add
(
position
,
newColumn
);
}
// create a table object in order to get the SQL statement
// can't just use this table, because most column objects are 'shared'
// with the old table
// still need a new id because using 0 would mean: the new table tries
// to use the rows of the table 0 (the meta table)
int
id
=
db
.
allocateObjectId
(
true
,
true
);
TableData
newTable
=
getSchema
().
createTable
(
tempName
,
id
,
newColumns
,
table
.
isPersistIndexes
(),
table
.
isPersistData
(),
false
,
Index
.
EMPTY_HEAD
,
session
);
TableData
newTable
=
getSchema
().
createTable
(
tempName
,
id
,
newColumns
,
table
.
is
Temporary
(),
table
.
is
PersistIndexes
(),
table
.
isPersistData
(),
false
,
Index
.
EMPTY_HEAD
,
session
);
newTable
.
setComment
(
table
.
getComment
());
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
newTable
.
getCreateSQL
());
...
...
@@ -263,8 +264,12 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
buff
.
append
(
" FROM "
).
append
(
table
.
getSQL
());
String
newTableSQL
=
buff
.
toString
();
String
newTableName
=
newTable
.
getName
();
Schema
newTableSchema
=
newTable
.
getSchema
();
newTable
.
removeChildrenAndResources
(
session
);
execute
(
newTableSQL
,
true
);
newTable
=
(
TableData
)
newTable
.
getSchema
().
getTableOrView
(
session
,
newTable
.
getName
()
);
newTable
=
(
TableData
)
newTable
Schema
.
getTableOrView
(
session
,
newTableName
);
ObjectArray
<
String
>
triggers
=
ObjectArray
.
newInstance
();
for
(
DbObject
child
:
table
.
getChildren
())
{
if
(
child
instanceof
Sequence
)
{
...
...
@@ -384,7 +389,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
continue
;
}
IndexType
indexType
=
index
.
getIndexType
();
if
(
indexType
.
getPrimaryKey
()
||
indexType
.
get
Hash
())
{
if
(
indexType
.
isPrimaryKey
()
||
indexType
.
is
Hash
())
{
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_IS_PART_OF_INDEX_1
,
index
.
getSQL
());
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/AlterTableRename.java
浏览文件 @
9cbd604d
...
...
@@ -44,7 +44,7 @@ public class AlterTableRename extends SchemaCommand {
throw
Message
.
getSQLException
(
ErrorCode
.
TABLE_OR_VIEW_ALREADY_EXISTS_1
,
newTableName
);
}
session
.
getUser
().
checkRight
(
oldTable
,
Right
.
ALL
);
if
(
oldTable
.
get
Temporary
())
{
if
(
oldTable
.
is
Temporary
())
{
throw
Message
.
getUnsupportedException
(
"TEMP TABLE"
);
}
db
.
renameSchemaObject
(
session
,
oldTable
,
newTableName
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
9cbd604d
...
...
@@ -131,7 +131,7 @@ public class CreateTable extends SchemaCommand {
}
ObjectArray
<
Sequence
>
sequences
=
ObjectArray
.
newInstance
();
for
(
Column
c
:
columns
)
{
if
(
c
.
get
AutoIncrement
())
{
if
(
c
.
is
AutoIncrement
())
{
int
objId
=
getObjectId
(
true
,
true
);
c
.
convertAutoIncrementToSequence
(
session
,
getSchema
(),
objId
,
temporary
);
}
...
...
@@ -141,9 +141,8 @@ public class CreateTable extends SchemaCommand {
}
}
int
id
=
getObjectId
(
true
,
true
);
TableData
table
=
getSchema
().
createTable
(
tableName
,
id
,
columns
,
persistIndexes
,
persistData
,
clustered
,
headPos
,
session
);
TableData
table
=
getSchema
().
createTable
(
tableName
,
id
,
columns
,
temporary
,
persistIndexes
,
persistData
,
clustered
,
headPos
,
session
);
table
.
setComment
(
comment
);
table
.
setTemporary
(
temporary
);
table
.
setGlobalTemporary
(
globalTemporary
);
if
(
temporary
&&
!
globalTemporary
)
{
if
(
onCommitDrop
)
{
...
...
@@ -167,7 +166,7 @@ public class CreateTable extends SchemaCommand {
command
.
update
();
}
if
(
asQuery
!=
null
)
{
boolean
old
=
session
.
get
UndoLogEnabled
();
boolean
old
=
session
.
is
UndoLogEnabled
();
try
{
session
.
setUndoLogEnabled
(
false
);
Insert
insert
=
null
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论