Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
394ac43a
提交
394ac43a
authored
8月 11, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parse CHARINDEX(), GETDATE(), and LEN() only in SQL Server compatibility mode
上级
5b022f39
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
50 行增加
和
12 行删除
+50
-12
Function.java
h2/src/main/org/h2/expression/Function.java
+0
-7
FunctionsMSSQLServer.java
h2/src/main/org/h2/mode/FunctionsMSSQLServer.java
+3
-0
length.sql
h2/src/test/org/h2/test/scripts/functions/string/length.sql
+20
-5
locate.sql
h2/src/test/org/h2/test/scripts/functions/string/locate.sql
+15
-0
current_date.sql
...rg/h2/test/scripts/functions/timeanddate/current_date.sql
+12
-0
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
394ac43a
...
@@ -240,12 +240,8 @@ public class Function extends Expression implements FunctionCall {
...
@@ -240,12 +240,8 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"LCASE"
,
LCASE
,
1
,
Value
.
STRING
);
addFunction
(
"LCASE"
,
LCASE
,
1
,
Value
.
STRING
);
addFunction
(
"LEFT"
,
LEFT
,
2
,
Value
.
STRING
);
addFunction
(
"LEFT"
,
LEFT
,
2
,
Value
.
STRING
);
addFunction
(
"LENGTH"
,
LENGTH
,
1
,
Value
.
LONG
);
addFunction
(
"LENGTH"
,
LENGTH
,
1
,
Value
.
LONG
);
// alias for MSSQLServer
addFunction
(
"LEN"
,
LENGTH
,
1
,
Value
.
LONG
);
// 2 or 3 arguments
// 2 or 3 arguments
addFunction
(
"LOCATE"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
addFunction
(
"LOCATE"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
// alias for MSSQLServer
addFunction
(
"CHARINDEX"
,
LOCATE
,
VAR_ARGS
,
Value
.
INT
);
// same as LOCATE with 2 arguments
// same as LOCATE with 2 arguments
addFunction
(
"POSITION"
,
LOCATE
,
2
,
Value
.
INT
);
addFunction
(
"POSITION"
,
LOCATE
,
2
,
Value
.
INT
);
addFunction
(
"INSTR"
,
INSTR
,
VAR_ARGS
,
Value
.
INT
);
addFunction
(
"INSTR"
,
INSTR
,
VAR_ARGS
,
Value
.
INT
);
...
@@ -293,9 +289,6 @@ public class Function extends Expression implements FunctionCall {
...
@@ -293,9 +289,6 @@ public class Function extends Expression implements FunctionCall {
addFunction
(
"TO_TIMESTAMP"
,
TO_TIMESTAMP
,
VAR_ARGS
,
Value
.
TIMESTAMP
);
addFunction
(
"TO_TIMESTAMP"
,
TO_TIMESTAMP
,
VAR_ARGS
,
Value
.
TIMESTAMP
);
addFunction
(
"ADD_MONTHS"
,
ADD_MONTHS
,
2
,
Value
.
TIMESTAMP
);
addFunction
(
"ADD_MONTHS"
,
ADD_MONTHS
,
2
,
Value
.
TIMESTAMP
);
addFunction
(
"TO_TIMESTAMP_TZ"
,
TO_TIMESTAMP_TZ
,
VAR_ARGS
,
Value
.
TIMESTAMP_TZ
);
addFunction
(
"TO_TIMESTAMP_TZ"
,
TO_TIMESTAMP_TZ
,
VAR_ARGS
,
Value
.
TIMESTAMP_TZ
);
// alias for MSSQLServer
addFunctionNotDeterministic
(
"GETDATE"
,
CURDATE
,
0
,
Value
.
DATE
);
addFunctionNotDeterministic
(
"CURRENT_TIME"
,
CURRENT_TIME
,
addFunctionNotDeterministic
(
"CURRENT_TIME"
,
CURRENT_TIME
,
VAR_ARGS
,
Value
.
TIME
);
VAR_ARGS
,
Value
.
TIME
);
addFunctionNotDeterministic
(
"LOCALTIME"
,
CURRENT_TIME
,
addFunctionNotDeterministic
(
"LOCALTIME"
,
CURRENT_TIME
,
...
...
h2/src/main/org/h2/mode/FunctionsMSSQLServer.java
浏览文件 @
394ac43a
...
@@ -19,6 +19,9 @@ public final class FunctionsMSSQLServer extends FunctionsBase {
...
@@ -19,6 +19,9 @@ public final class FunctionsMSSQLServer extends FunctionsBase {
private
static
final
HashMap
<
String
,
FunctionInfo
>
FUNCTIONS
=
new
HashMap
<>();
private
static
final
HashMap
<
String
,
FunctionInfo
>
FUNCTIONS
=
new
HashMap
<>();
static
{
static
{
copyFunction
(
FUNCTIONS
,
"LOCATE"
,
"CHARINDEX"
);
copyFunction
(
FUNCTIONS
,
"CURRENT_DATE"
,
"GETDATE"
);
copyFunction
(
FUNCTIONS
,
"LENGTH"
,
"LEN"
);
copyFunction
(
FUNCTIONS
,
"RANDOM_UUID"
,
"NEWID"
);
copyFunction
(
FUNCTIONS
,
"RANDOM_UUID"
,
"NEWID"
);
}
}
...
...
h2/src/test/org/h2/test/scripts/functions/string/length.sql
浏览文件 @
394ac43a
...
@@ -9,8 +9,23 @@ create memory table test(id int primary key, name varchar(255));
...
@@ -9,8 +9,23 @@ create memory table test(id int primary key, name varchar(255));
insert
into
test
values
(
1
,
'Hello'
);
insert
into
test
values
(
1
,
'Hello'
);
>
update
count
:
1
>
update
count
:
1
select
length
(
null
)
en
,
len
(
null
)
en2
,
length
(
'This has 17 chars'
)
e_17
,
len
(
'MSSQLServer uses the len keyword'
)
e_32
from
test
;
select
length
(
null
)
en
,
length
(
'This has 17 chars'
)
e_17
from
test
;
>
EN
EN2
E_17
E_32
>
EN
E_17
>
---- ---- ---- ----
>
---- ----
>
null
null
17
32
>
null
17
>
rows
:
1
>
rows
:
1
\ No newline at end of file
SELECT
LEN
(
NULL
);
>
exception
FUNCTION_NOT_FOUND_1
SET
MODE
MSSQLServer
;
>
ok
select
len
(
null
)
en
,
len
(
'MSSQLServer uses the len keyword'
)
e_32
from
test
;
>
EN
E_32
>
---- ----
>
null
32
>
rows
:
1
SET
MODE
Regular
;
>
ok
\ No newline at end of file
h2/src/test/org/h2/test/scripts/functions/string/locate.sql
浏览文件 @
394ac43a
...
@@ -20,3 +20,18 @@ select locate('World', 'Hello World') e7, locate('hi', 'abchihihi', 2) e3 from t
...
@@ -20,3 +20,18 @@ select locate('World', 'Hello World') e7, locate('hi', 'abchihihi', 2) e3 from t
>
-- --
>
-- --
>
7
4
>
7
4
>
rows
:
1
>
rows
:
1
SELECT
CHARINDEX
(
'test'
,
'test'
);
>
exception
FUNCTION_NOT_FOUND_1
SET
MODE
MSSQLServer
;
>
ok
select
charindex
(
'World'
,
'Hello World'
)
e7
,
charindex
(
'hi'
,
'abchihihi'
,
2
)
e3
from
test
;
>
E7
E3
>
-- --
>
7
4
>
rows
:
1
SET
MODE
Regular
;
>
ok
h2/src/test/org/h2/test/scripts/functions/timeanddate/current_date.sql
浏览文件 @
394ac43a
...
@@ -14,3 +14,15 @@ select length(curdate()) c1, length(current_date()) c2, substring(curdate(), 5,
...
@@ -14,3 +14,15 @@ select length(curdate()) c1, length(current_date()) c2, substring(curdate(), 5,
>
-- -- --
>
-- -- --
>
10
10
-
>
10
10
-
>
rows
:
1
>
rows
:
1
SELECT
GETDATE
();
>
exception
FUNCTION_NOT_FOUND_1
SET
MODE
MSSQLServer
;
>
ok
SELECT
CURRENT_DATE
=
GETDATE
();
>>
TRUE
SET
MODE
Regular
;
>
ok
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论