Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
da652fde
提交
da652fde
authored
4月 04, 2013
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue 274: Sybase/MSSQLServer compatibility - swap parameters of CONVERT function.
上级
6d66a72f
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
35 行增加
和
12 行删除
+35
-12
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+13
-5
Mode.java
h2/src/main/org/h2/engine/Mode.java
+6
-0
Function.java
h2/src/main/org/h2/expression/Function.java
+2
-0
TestCompatibility.java
h2/src/test/org/h2/test/db/TestCompatibility.java
+12
-7
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
da652fde
...
...
@@ -30,6 +30,8 @@ Change Log
</li><li>
Fix Issue 406: support "SELECT h2version()"
</li><li>
Fix Issue 389: When there is a multi-column primary key, H2 does not seem to always pick the right index
</li><li>
Fix Issue 305: Implement SELECT ... FOR FETCH ONLY
</li><li>
Issue 274: Sybase/MSSQLServer compatibility - Add GETDATE and CHARINDEX system functions
</li><li>
Issue 274: Sybase/MSSQLServer compatibility - swap parameters of CONVERT function.
</li></ul>
<h2>
Version 1.3.171 (2013-03-17)
</h2>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
da652fde
...
...
@@ -2191,11 +2191,19 @@ public class Parser {
break
;
}
case
Function
.
CONVERT
:
{
function
.
setParameter
(
0
,
readExpression
());
read
(
","
);
Column
type
=
parseColumnWithType
(
null
);
function
.
setDataType
(
type
);
read
(
")"
);
if
(
database
.
getMode
().
swapConvertFunctionParameters
)
{
Column
type
=
parseColumnWithType
(
null
);
function
.
setDataType
(
type
);
read
(
","
);
function
.
setParameter
(
0
,
readExpression
());
read
(
")"
);
}
else
{
function
.
setParameter
(
0
,
readExpression
());
read
(
","
);
Column
type
=
parseColumnWithType
(
null
);
function
.
setDataType
(
type
);
read
(
")"
);
}
break
;
}
case
Function
.
EXTRACT
:
{
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
da652fde
...
...
@@ -117,6 +117,11 @@ public class Mode {
* SERIAL and BIGSERIAL columns are not automatically primary keys.
*/
public
boolean
serialColumnIsNotPK
;
/**
* Swap the parameters of the CONVERT function.
*/
public
boolean
swapConvertFunctionParameters
;
private
final
String
name
;
...
...
@@ -152,6 +157,7 @@ public class Mode {
mode
.
squareBracketQuotedNames
=
true
;
mode
.
uniqueIndexSingleNull
=
true
;
mode
.
allowPlusForStringConcat
=
true
;
mode
.
swapConvertFunctionParameters
=
true
;
add
(
mode
);
mode
=
new
Mode
(
"MySQL"
);
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
da652fde
...
...
@@ -241,6 +241,7 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"LENGTH"
,
LENGTH
,
1
,
Value
.
LONG
);
// 2 or 3 arguments
addFunction
(
"LOCATE"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
addFunction
(
"CHARINDEX"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
// alias for MSSQLServer
// same as LOCATE with 2 arguments
addFunction
(
"POSITION"
,
LOCATE
,
2
,
Value
.
INT
);
addFunction
(
"INSTR"
,
INSTR
,
VAR_ARGS
,
Value
.
INT
);
...
...
@@ -277,6 +278,7 @@ public class Function extends Expression implements FunctionCall {
// date
addFunctionNotDeterministic
(
"CURRENT_DATE"
,
CURRENT_DATE
,
0
,
Value
.
DATE
);
addFunctionNotDeterministic
(
"CURDATE"
,
CURDATE
,
0
,
Value
.
DATE
);
addFunctionNotDeterministic
(
"GETDATE"
,
CURDATE
,
0
,
Value
.
DATE
);
// alias for MSSQLServer
addFunctionNotDeterministic
(
"CURRENT_TIME"
,
CURRENT_TIME
,
0
,
Value
.
TIME
);
addFunctionNotDeterministic
(
"CURTIME"
,
CURTIME
,
0
,
Value
.
TIME
);
addFunctionNotDeterministic
(
"CURRENT_TIMESTAMP"
,
CURRENT_TIMESTAMP
,
VAR_ARGS
,
Value
.
TIMESTAMP
);
...
...
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
da652fde
...
...
@@ -48,7 +48,7 @@ public class TestCompatibility extends TestBase {
testMySQL
();
testDB2
();
testDerby
();
test
PlusSignAsConcatOperato
r
();
test
SybaseAndMSSQLServe
r
();
conn
.
close
();
deleteDb
(
"compatibility"
);
...
...
@@ -261,7 +261,7 @@ public class TestCompatibility extends TestBase {
conn
=
getConnection
(
"compatibility"
);
}
private
void
test
PlusSignAsConcatOperato
r
()
throws
SQLException
{
private
void
test
SybaseAndMSSQLServe
r
()
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"SET MODE MSSQLServer"
);
stat
.
execute
(
"DROP TABLE IF EXISTS TEST"
);
...
...
@@ -298,12 +298,17 @@ public class TestCompatibility extends TestBase {
prep
=
conn
.
prepareStatement
(
"SELECT full_name FROM test WHERE (SUBSTRING(name, 1, 1) + SUBSTRING(surname, 2, 3)) = ?"
);
prep
.
setString
(
1
,
"Joe"
);
ResultSet
r
e
s
=
prep
.
executeQuery
();
assertTrue
(
"Result cannot be empty"
,
r
e
s
.
next
());
assertEquals
(
"John, Doe"
,
r
e
s
.
getString
(
1
));
r
e
s
.
close
();
ResultSet
rs
=
prep
.
executeQuery
();
assertTrue
(
"Result cannot be empty"
,
rs
.
next
());
assertEquals
(
"John, Doe"
,
rs
.
getString
(
1
));
rs
.
close
();
prep
.
close
();
// CONVERT has it's parameters the other way around from the default mode
rs
=
stat
.
executeQuery
(
"SELECT CONVERT(INT, '10')"
);
rs
.
next
();
assertEquals
(
10
,
rs
.
getInt
(
1
));
rs
.
close
();
}
private
void
testDB2
()
throws
SQLException
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论