Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a96d24e2
提交
a96d24e2
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Aliases for built-in data types can now be re-mapped.
上级
78aab0c0
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
96 行增加
和
7 行删除
+96
-7
Parser.java
h2/src/main/org/h2/command/Parser.java
+8
-6
CreateUserDataType.java
h2/src/main/org/h2/command/ddl/CreateUserDataType.java
+5
-0
ErrorCode.java
h2/src/main/org/h2/constant/ErrorCode.java
+3
-1
test-1.0.txt
h2/src/test/org/h2/test/test-1.0.txt
+49
-0
test-1.1.txt
h2/src/test/org/h2/test/test-1.1.txt
+31
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
a96d24e2
...
@@ -3272,17 +3272,14 @@ public class Parser {
...
@@ -3272,17 +3272,14 @@ public class Parser {
}
else
{
}
else
{
regular
=
true
;
regular
=
true
;
}
}
DataType
dataType
=
DataType
.
getTypeByName
(
original
);
long
precision
=
-
1
;
long
precision
=
-
1
;
int
displaySize
=
-
1
;
int
displaySize
=
-
1
;
int
scale
=
-
1
;
int
scale
=
-
1
;
String
comment
=
null
;
String
comment
=
null
;
Column
templateColumn
=
null
;
Column
templateColumn
=
null
;
if
(
dataType
==
null
)
{
DataType
dataType
;
UserDataType
userDataType
=
database
.
findUserDataType
(
original
);
UserDataType
userDataType
=
database
.
findUserDataType
(
original
);
if
(
userDataType
==
null
)
{
if
(
userDataType
!=
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
currentToken
);
}
templateColumn
=
userDataType
.
getColumn
();
templateColumn
=
userDataType
.
getColumn
();
dataType
=
DataType
.
getDataType
(
templateColumn
.
getType
());
dataType
=
DataType
.
getDataType
(
templateColumn
.
getType
());
comment
=
templateColumn
.
getComment
();
comment
=
templateColumn
.
getComment
();
...
@@ -3290,6 +3287,11 @@ public class Parser {
...
@@ -3290,6 +3287,11 @@ public class Parser {
precision
=
templateColumn
.
getPrecision
();
precision
=
templateColumn
.
getPrecision
();
displaySize
=
templateColumn
.
getDisplaySize
();
displaySize
=
templateColumn
.
getDisplaySize
();
scale
=
templateColumn
.
getScale
();
scale
=
templateColumn
.
getScale
();
}
else
{
dataType
=
DataType
.
getTypeByName
(
original
);
if
(
dataType
==
null
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
UNKNOWN_DATA_TYPE_1
,
currentToken
);
}
}
}
if
(
database
.
getIgnoreCase
()
&&
dataType
.
type
==
Value
.
STRING
&&
!
"VARCHAR_CASESENSITIVE"
.
equals
(
original
))
{
if
(
database
.
getIgnoreCase
()
&&
dataType
.
type
==
Value
.
STRING
&&
!
"VARCHAR_CASESENSITIVE"
.
equals
(
original
))
{
original
=
"VARCHAR_IGNORECASE"
;
original
=
"VARCHAR_IGNORECASE"
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/ddl/CreateUserDataType.java
浏览文件 @
a96d24e2
...
@@ -14,6 +14,7 @@ import org.h2.engine.Session;
...
@@ -14,6 +14,7 @@ import org.h2.engine.Session;
import
org.h2.engine.UserDataType
;
import
org.h2.engine.UserDataType
;
import
org.h2.message.Message
;
import
org.h2.message.Message
;
import
org.h2.table.Column
;
import
org.h2.table.Column
;
import
org.h2.value.DataType
;
/**
/**
* This class represents the statement
* This class represents the statement
...
@@ -53,6 +54,10 @@ public class CreateUserDataType extends DefineCommand {
...
@@ -53,6 +54,10 @@ public class CreateUserDataType extends DefineCommand {
}
}
throw
Message
.
getSQLException
(
ErrorCode
.
USER_DATA_TYPE_ALREADY_EXISTS_1
,
typeName
);
throw
Message
.
getSQLException
(
ErrorCode
.
USER_DATA_TYPE_ALREADY_EXISTS_1
,
typeName
);
}
}
DataType
builtIn
=
DataType
.
getTypeByName
(
typeName
);
if
(
builtIn
!=
null
&&
!
builtIn
.
hidden
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
USER_DATA_TYPE_ALREADY_EXISTS_1
,
typeName
);
}
int
id
=
getObjectId
(
false
,
true
);
int
id
=
getObjectId
(
false
,
true
);
UserDataType
type
=
new
UserDataType
(
db
,
id
,
typeName
);
UserDataType
type
=
new
UserDataType
(
db
,
id
,
typeName
);
type
.
setColumn
(
column
);
type
.
setColumn
(
column
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/constant/ErrorCode.java
浏览文件 @
a96d24e2
...
@@ -1615,9 +1615,11 @@ public class ErrorCode {
...
@@ -1615,9 +1615,11 @@ public class ErrorCode {
/**
/**
* The error with code <code>90119</code> is thrown when
* The error with code <code>90119</code> is thrown when
* trying to create a domain if an object with this name already exists.
* trying to create a domain if an object with this name already exists,
* or when trying to overload a built-in data type.
* Example:
* Example:
* <pre>
* <pre>
* CREATE DOMAIN INTEGER AS VARCHAR;
* CREATE DOMAIN EMAIL AS VARCHAR CHECK LOCATE('@', VALUE) > 0;
* CREATE DOMAIN EMAIL AS VARCHAR CHECK LOCATE('@', VALUE) > 0;
* CREATE DOMAIN EMAIL AS VARCHAR CHECK LOCATE('@', VALUE) > 0;
* CREATE DOMAIN EMAIL AS VARCHAR CHECK LOCATE('@', VALUE) > 0;
* </pre>
* </pre>
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/test-1.0.txt
浏览文件 @
a96d24e2
--- special grammar and test cases ---------------------------------------------------------------------------------------------
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create domain integer as varchar;
> exception
create domain int as varchar;
> ok
create domain bit as int;
> ok
create table test(id bit);
> ok
script nodata nopasswords nosettings;
> SCRIPT
> --------------------------------------------------
> -- 0 = SELECT COUNT(*) FROM PUBLIC.TEST;
> CREATE CACHED TABLE PUBLIC.TEST( ID VARCHAR );
> CREATE DOMAIN BIT AS VARCHAR;
> CREATE DOMAIN INT AS VARCHAR;
> CREATE USER IF NOT EXISTS SA PASSWORD '' ADMIN;
> rows: 5
drop table test;
> ok
drop domain int;
> ok
drop domain bit;
> ok
create table test(id identity, parent bigint, foreign key(parent) references(id));
> ok
insert into test values(0, 0), (1, NULL), (2, 1), (3, 3), (4, 3);
> update count: 5
delete from test where id = 3;
> exception
delete from test where id = 0;
> update count: 1
delete from test where id = 1;
> exception
drop table test;
> ok
select iso_week('2006-12-31') w, iso_year('2007-12-31') y, iso_day_of_week('2007-12-31') w;
select iso_week('2006-12-31') w, iso_year('2007-12-31') y, iso_day_of_week('2007-12-31') w;
> W Y W
> W Y W
> -- ---- -
> -- ---- -
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/test-1.1.txt
浏览文件 @
a96d24e2
--- special grammar and test cases ---------------------------------------------------------------------------------------------
--- special grammar and test cases ---------------------------------------------------------------------------------------------
create domain integer as varchar;
> exception
create domain int as varchar;
> ok
create domain bit as int;
> ok
create table test(id bit);
> ok
script nodata nopasswords nosettings;
> SCRIPT
> --------------------------------------------------
> -- 0 = SELECT COUNT(*) FROM PUBLIC.TEST;
> CREATE CACHED TABLE PUBLIC.TEST( ID VARCHAR );
> CREATE DOMAIN BIT AS VARCHAR;
> CREATE DOMAIN INT AS VARCHAR;
> CREATE USER IF NOT EXISTS SA PASSWORD '' ADMIN;
> rows: 5
drop table test;
> ok
drop domain int;
> ok
drop domain bit;
> ok
create table test(id identity, parent bigint, foreign key(parent) references(id));
create table test(id identity, parent bigint, foreign key(parent) references(id));
> ok
> ok
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论