Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
2ec10192
提交
2ec10192
authored
4月 22, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ALTER TABLE ALTER COLUMN: changing the data type of a column no longer makes it nullable.
上级
e166ac36
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
9 行删除
+10
-9
Parser.java
h2/src/main/org/h2/command/Parser.java
+10
-9
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
2ec10192
...
@@ -557,7 +557,7 @@ public class Parser {
...
@@ -557,7 +557,7 @@ public class Parser {
if
(
readIf
(
"("
))
{
if
(
readIf
(
"("
))
{
ArrayList
<
Column
>
list
=
New
.
arrayList
();
ArrayList
<
Column
>
list
=
New
.
arrayList
();
for
(
int
i
=
0
;;
i
++)
{
for
(
int
i
=
0
;;
i
++)
{
Column
column
=
parseColumnForTable
(
"C"
+
i
);
Column
column
=
parseColumnForTable
(
"C"
+
i
,
true
);
list
.
add
(
column
);
list
.
add
(
column
);
if
(
readIf
(
")"
))
{
if
(
readIf
(
")"
))
{
break
;
break
;
...
@@ -3253,7 +3253,7 @@ public class Parser {
...
@@ -3253,7 +3253,7 @@ public class Parser {
return
IDENTIFIER
;
return
IDENTIFIER
;
}
}
private
Column
parseColumnForTable
(
String
columnName
)
{
private
Column
parseColumnForTable
(
String
columnName
,
boolean
defaultNullable
)
{
Column
column
;
Column
column
;
boolean
isIdentity
=
false
;
boolean
isIdentity
=
false
;
if
(
readIf
(
"IDENTITY"
)
||
readIf
(
"SERIAL"
))
{
if
(
readIf
(
"IDENTITY"
)
||
readIf
(
"SERIAL"
))
{
...
@@ -3267,9 +3267,10 @@ public class Parser {
...
@@ -3267,9 +3267,10 @@ public class Parser {
if
(
readIf
(
"NOT"
))
{
if
(
readIf
(
"NOT"
))
{
read
(
"NULL"
);
read
(
"NULL"
);
column
.
setNullable
(
false
);
column
.
setNullable
(
false
);
}
else
{
}
else
if
(
readIf
(
"NULL"
))
{
readIf
(
"NULL"
);
column
.
setNullable
(
true
);
column
.
setNullable
(
true
);
}
else
{
column
.
setNullable
(
defaultNullable
);
}
}
if
(
readIf
(
"AS"
))
{
if
(
readIf
(
"AS"
))
{
if
(
isIdentity
)
{
if
(
isIdentity
)
{
...
@@ -3743,7 +3744,7 @@ public class Parser {
...
@@ -3743,7 +3744,7 @@ public class Parser {
CreateUserDataType
command
=
new
CreateUserDataType
(
session
);
CreateUserDataType
command
=
new
CreateUserDataType
(
session
);
command
.
setTypeName
(
readUniqueIdentifier
());
command
.
setTypeName
(
readUniqueIdentifier
());
read
(
"AS"
);
read
(
"AS"
);
Column
col
=
parseColumnForTable
(
"VALUE"
);
Column
col
=
parseColumnForTable
(
"VALUE"
,
true
);
if
(
readIf
(
"CHECK"
))
{
if
(
readIf
(
"CHECK"
))
{
Expression
expr
=
readExpression
();
Expression
expr
=
readExpression
();
col
.
addCheckConstraint
(
session
,
expr
);
col
.
addCheckConstraint
(
session
,
expr
);
...
@@ -4453,7 +4454,7 @@ public class Parser {
...
@@ -4453,7 +4454,7 @@ public class Parser {
if
(
readIf
(
"DATA"
))
{
if
(
readIf
(
"DATA"
))
{
// Derby compatibility
// Derby compatibility
read
(
"TYPE"
);
read
(
"TYPE"
);
Column
newColumn
=
parseColumnForTable
(
columnName
);
Column
newColumn
=
parseColumnForTable
(
columnName
,
column
.
isNullable
()
);
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
table
.
getSchema
());
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
table
.
getSchema
());
command
.
setTable
(
table
);
command
.
setTable
(
table
);
command
.
setType
(
AlterTableAlterColumn
.
CHANGE_TYPE
);
command
.
setType
(
AlterTableAlterColumn
.
CHANGE_TYPE
);
...
@@ -4492,7 +4493,7 @@ public class Parser {
...
@@ -4492,7 +4493,7 @@ public class Parser {
command
.
setSelectivity
(
readExpression
());
command
.
setSelectivity
(
readExpression
());
return
command
;
return
command
;
}
else
{
}
else
{
Column
newColumn
=
parseColumnForTable
(
columnName
);
Column
newColumn
=
parseColumnForTable
(
columnName
,
column
.
isNullable
()
);
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
table
.
getSchema
());
AlterTableAlterColumn
command
=
new
AlterTableAlterColumn
(
session
,
table
.
getSchema
());
command
.
setTable
(
table
);
command
.
setTable
(
table
);
command
.
setType
(
AlterTableAlterColumn
.
CHANGE_TYPE
);
command
.
setType
(
AlterTableAlterColumn
.
CHANGE_TYPE
);
...
@@ -4511,7 +4512,7 @@ public class Parser {
...
@@ -4511,7 +4512,7 @@ public class Parser {
command
.
setType
(
AlterTableAlterColumn
.
ADD
);
command
.
setType
(
AlterTableAlterColumn
.
ADD
);
command
.
setTable
(
table
);
command
.
setTable
(
table
);
String
columnName
=
readColumnIdentifier
();
String
columnName
=
readColumnIdentifier
();
Column
column
=
parseColumnForTable
(
columnName
);
Column
column
=
parseColumnForTable
(
columnName
,
true
);
command
.
setNewColumn
(
column
);
command
.
setNewColumn
(
column
);
if
(
readIf
(
"BEFORE"
))
{
if
(
readIf
(
"BEFORE"
))
{
command
.
setAddBefore
(
readColumnIdentifier
());
command
.
setAddBefore
(
readColumnIdentifier
());
...
@@ -4721,7 +4722,7 @@ public class Parser {
...
@@ -4721,7 +4722,7 @@ public class Parser {
command
.
addConstraintCommand
(
c
);
command
.
addConstraintCommand
(
c
);
}
else
{
}
else
{
String
columnName
=
readColumnIdentifier
();
String
columnName
=
readColumnIdentifier
();
Column
column
=
parseColumnForTable
(
columnName
);
Column
column
=
parseColumnForTable
(
columnName
,
true
);
if
(
column
.
isAutoIncrement
()
&&
column
.
isPrimaryKey
())
{
if
(
column
.
isAutoIncrement
()
&&
column
.
isPrimaryKey
())
{
column
.
setPrimaryKey
(
false
);
column
.
setPrimaryKey
(
false
);
IndexColumn
[]
cols
=
{
new
IndexColumn
()
};
IndexColumn
[]
cols
=
{
new
IndexColumn
()
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论