Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
eab3251b
提交
eab3251b
authored
7 年前
作者:
plus33
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added more Oracle compatibility: VARCHAR with type BYTE is accepted now
too. The type treaded same as CHAR.
上级
d40ab416
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
3 行删除
+34
-3
Parser.java
h2/src/main/org/h2/command/Parser.java
+15
-1
TestCompatibilityOracle.java
h2/src/test/org/h2/test/db/TestCompatibilityOracle.java
+19
-2
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
eab3251b
...
@@ -3486,6 +3486,20 @@ public class Parser {
...
@@ -3486,6 +3486,20 @@ public class Parser {
addExpected
(
token
);
addExpected
(
token
);
return
false
;
return
false
;
}
}
/*
* Reads passed token in list, in order and returns true on first match.
* If none of the token matches returns false
*/
private
boolean
readIfOr
(
String
...
tokens
)
{
for
(
String
token:
tokens
)
{
if
(
readIf
(
token
))
{
return
true
;
}
}
return
false
;
}
/*
/*
* Reads every token in list, in order - returns true if all are found.
* Reads every token in list, in order - returns true if all are found.
* If any are not found, returns false - AND resets parsing back to state when called.
* If any are not found, returns false - AND resets parsing back to state when called.
...
@@ -4466,7 +4480,7 @@ public class Parser {
...
@@ -4466,7 +4480,7 @@ public class Parser {
}
}
original
+=
"("
+
p
;
original
+=
"("
+
p
;
// Oracle syntax
// Oracle syntax
readIf
(
"CHAR
"
);
readIf
Or
(
"CHAR"
,
"BYTE
"
);
if
(
dataType
.
supportsScale
)
{
if
(
dataType
.
supportsScale
)
{
if
(
readIf
(
","
))
{
if
(
readIf
(
","
))
{
scale
=
readInt
();
scale
=
readInt
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/db/TestCompatibilityOracle.java
浏览文件 @
eab3251b
...
@@ -40,6 +40,7 @@ public class TestCompatibilityOracle extends TestBase {
...
@@ -40,6 +40,7 @@ public class TestCompatibilityOracle extends TestBase {
testPoundSymbolInColumnName
();
testPoundSymbolInColumnName
();
testToDate
();
testToDate
();
testForbidEmptyInClause
();
testForbidEmptyInClause
();
testSpecialTypes
();
}
}
private
void
testNotNullSyntax
()
throws
SQLException
{
private
void
testNotNullSyntax
()
throws
SQLException
{
...
@@ -86,12 +87,28 @@ public class TestCompatibilityOracle extends TestBase {
...
@@ -86,12 +87,28 @@ public class TestCompatibilityOracle extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
private
void
testSpecialTypes
()
throws
SQLException
{
// Test VARCHAR, VARCHAR2 with CHAR and BYTE
deleteDb
(
"oracle"
);
Connection
conn
=
getConnection
(
"oracle;MODE=Oracle"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table T (ID NUMBER)"
);
stat
.
execute
(
"alter table T add A_1 VARCHAR(1)"
);
stat
.
execute
(
"alter table T add A_2 VARCHAR2(1)"
);
stat
.
execute
(
"alter table T add B_1 VARCHAR(1 byte)"
);
// with BYTE
stat
.
execute
(
"alter table T add B_2 VARCHAR2(1 byte)"
);
stat
.
execute
(
"alter table T add C_1 VARCHAR(1 char)"
);
// with CHAR
stat
.
execute
(
"alter table T add C_2 VARCHAR2(1 char)"
);
stat
.
execute
(
"alter table T add B_255 VARCHAR(255 byte)"
);
stat
.
execute
(
"alter table T add C_255 VARCHAR(255 char)"
);
stat
.
execute
(
"drop table T"
);
conn
.
close
();
}
private
void
testTreatEmptyStringsAsNull
()
throws
SQLException
{
private
void
testTreatEmptyStringsAsNull
()
throws
SQLException
{
deleteDb
(
"oracle"
);
deleteDb
(
"oracle"
);
Connection
conn
=
getConnection
(
"oracle;MODE=Oracle"
);
Connection
conn
=
getConnection
(
"oracle;MODE=Oracle"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE A (ID NUMBER, X VARCHAR2(1))"
);
stat
.
execute
(
"CREATE TABLE A (ID NUMBER, X VARCHAR2(1))"
);
stat
.
execute
(
"INSERT INTO A VALUES (1, 'a')"
);
stat
.
execute
(
"INSERT INTO A VALUES (1, 'a')"
);
stat
.
execute
(
"INSERT INTO A VALUES (2, '')"
);
stat
.
execute
(
"INSERT INTO A VALUES (2, '')"
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论