Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9f951e0a
Unverified
提交
9f951e0a
authored
7月 16, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
7月 16, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1293 from katzyn/misc
Move HELP and SHOW tests into own files
上级
c2bffcf8
2192c90a
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
164 行增加
和
134 行删除
+164
-134
Parser.java
h2/src/main/org/h2/command/Parser.java
+15
-19
Select.java
h2/src/main/org/h2/command/dml/Select.java
+6
-0
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+0
-2
TestShow.java
h2/src/test/org/h2/test/db/TestShow.java
+0
-69
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+4
-1
show.sql
h2/src/test/org/h2/test/scripts/dml/show.sql
+113
-0
help.sql
h2/src/test/org/h2/test/scripts/other/help.sql
+26
-0
testScript.sql
h2/src/test/org/h2/test/scripts/testScript.sql
+0
-43
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
9f951e0a
...
@@ -1271,23 +1271,23 @@ public class Parser {
...
@@ -1271,23 +1271,23 @@ public class Parser {
}
}
private
Prepared
parseHelp
()
{
private
Prepared
parseHelp
()
{
StringBuilder
buff
=
new
StringBuilder
(
Select
select
=
new
Select
(
session
);
"SELECT * FROM INFORMATION_SCHEMA.HELP"
);
select
.
setWildcard
();
int
i
=
0
;
Table
table
=
database
.
getSchema
(
"INFORMATION_SCHEMA"
).
resolveTableOrView
(
session
,
"HELP"
);
ArrayList
<
Value
>
paramValues
=
Utils
.
newSmallArrayList
();
Function
function
=
Function
.
getFunction
(
database
,
"UPPER"
);
function
.
setParameter
(
0
,
new
ExpressionColumn
(
database
,
"INFORMATION_SCHEMA"
,
"HELP"
,
"TOPIC"
));
function
.
doneWithParameters
();
TableFilter
filter
=
new
TableFilter
(
session
,
table
,
null
,
rightsChecked
,
select
,
0
,
null
);
select
.
addTableFilter
(
filter
,
true
);
while
(
currentTokenType
!=
END
)
{
while
(
currentTokenType
!=
END
)
{
String
s
=
currentToken
;
String
s
=
currentToken
;
read
();
read
();
if
(
i
==
0
)
{
CompareLike
like
=
new
CompareLike
(
database
,
function
,
buff
.
append
(
" WHERE "
);
ValueExpression
.
get
(
ValueString
.
get
(
'%'
+
s
+
'%'
)),
null
,
false
);
}
else
{
select
.
addCondition
(
like
);
buff
.
append
(
" AND "
);
}
i
++;
buff
.
append
(
"UPPER(TOPIC) LIKE ?"
);
paramValues
.
add
(
ValueString
.
get
(
"%"
+
s
+
"%"
));
}
}
return
prepare
(
session
,
buff
.
toString
(),
paramValues
);
select
.
init
();
return
select
;
}
}
private
Prepared
parseShow
()
{
private
Prepared
parseShow
()
{
...
@@ -1463,9 +1463,7 @@ public class Parser {
...
@@ -1463,9 +1463,7 @@ public class Parser {
command
.
setSourceTableFilter
(
sourceTableFilter
);
command
.
setSourceTableFilter
(
sourceTableFilter
);
Select
preparedQuery
=
new
Select
(
session
);
Select
preparedQuery
=
new
Select
(
session
);
ArrayList
<
Expression
>
expr
=
new
ArrayList
<>(
1
);
preparedQuery
.
setWildcard
();
expr
.
add
(
new
Wildcard
(
null
,
null
));
preparedQuery
.
setExpressions
(
expr
);
TableFilter
filter
=
new
TableFilter
(
session
,
sourceTableFilter
.
getTable
(),
TableFilter
filter
=
new
TableFilter
(
session
,
sourceTableFilter
.
getTable
(),
sourceTableFilter
.
getTableAlias
(),
rightsChecked
,
preparedQuery
,
0
,
null
);
sourceTableFilter
.
getTableAlias
(),
rightsChecked
,
preparedQuery
,
0
,
null
);
preparedQuery
.
addTableFilter
(
filter
,
true
);
preparedQuery
.
addTableFilter
(
filter
,
true
);
...
@@ -5130,9 +5128,7 @@ public class Parser {
...
@@ -5130,9 +5128,7 @@ public class Parser {
Select
command
=
new
Select
(
session
);
Select
command
=
new
Select
(
session
);
currentSelect
=
command
;
currentSelect
=
command
;
TableFilter
filter
=
parseValuesTable
(
0
);
TableFilter
filter
=
parseValuesTable
(
0
);
ArrayList
<
Expression
>
list
=
new
ArrayList
<>(
1
);
command
.
setWildcard
();
list
.
add
(
new
Wildcard
(
null
,
null
));
command
.
setExpressions
(
list
);
command
.
addTableFilter
(
filter
,
true
);
command
.
addTableFilter
(
filter
,
true
);
command
.
init
();
command
.
init
();
return
command
;
return
command
;
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
9f951e0a
...
@@ -25,6 +25,7 @@ import org.h2.expression.Expression;
...
@@ -25,6 +25,7 @@ import org.h2.expression.Expression;
import
org.h2.expression.ExpressionColumn
;
import
org.h2.expression.ExpressionColumn
;
import
org.h2.expression.ExpressionVisitor
;
import
org.h2.expression.ExpressionVisitor
;
import
org.h2.expression.Parameter
;
import
org.h2.expression.Parameter
;
import
org.h2.expression.Wildcard
;
import
org.h2.index.Cursor
;
import
org.h2.index.Cursor
;
import
org.h2.index.Index
;
import
org.h2.index.Index
;
import
org.h2.index.IndexType
;
import
org.h2.index.IndexType
;
...
@@ -171,6 +172,11 @@ public class Select extends Query {
...
@@ -171,6 +172,11 @@ public class Select extends Query {
this
.
expressions
=
expressions
;
this
.
expressions
=
expressions
;
}
}
public
void
setWildcard
()
{
expressions
=
new
ArrayList
<>(
1
);
expressions
.
add
(
new
Wildcard
(
null
,
null
));
}
/**
/**
* Called if this query contains aggregate functions.
* Called if this query contains aggregate functions.
*/
*/
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
9f951e0a
...
@@ -70,7 +70,6 @@ import org.h2.test.db.TestSelectCountNonNullColumn;
...
@@ -70,7 +70,6 @@ import org.h2.test.db.TestSelectCountNonNullColumn;
import
org.h2.test.db.TestSequence
;
import
org.h2.test.db.TestSequence
;
import
org.h2.test.db.TestSessionsLocks
;
import
org.h2.test.db.TestSessionsLocks
;
import
org.h2.test.db.TestSetCollation
;
import
org.h2.test.db.TestSetCollation
;
import
org.h2.test.db.TestShow
;
import
org.h2.test.db.TestSpaceReuse
;
import
org.h2.test.db.TestSpaceReuse
;
import
org.h2.test.db.TestSpatial
;
import
org.h2.test.db.TestSpatial
;
import
org.h2.test.db.TestSpeed
;
import
org.h2.test.db.TestSpeed
;
...
@@ -779,7 +778,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -779,7 +778,6 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest
(
new
TestSessionsLocks
());
addTest
(
new
TestSessionsLocks
());
addTest
(
new
TestSelectCountNonNullColumn
());
addTest
(
new
TestSelectCountNonNullColumn
());
addTest
(
new
TestSequence
());
addTest
(
new
TestSequence
());
addTest
(
new
TestShow
());
addTest
(
new
TestSpaceReuse
());
addTest
(
new
TestSpaceReuse
());
addTest
(
new
TestSpatial
());
addTest
(
new
TestSpatial
());
addTest
(
new
TestSpeed
());
addTest
(
new
TestSpeed
());
...
...
h2/src/test/org/h2/test/db/TestShow.java
deleted
100644 → 0
浏览文件 @
c2bffcf8
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
db
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestDb
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
/**
* Test of compatibility for the SHOW statement.
*/
public
class
TestShow
extends
TestDb
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
void
test
()
throws
SQLException
{
testPgCompatibility
();
testMysqlCompatibility
();
}
private
void
testPgCompatibility
()
throws
SQLException
{
try
(
Connection
conn
=
getConnection
(
"mem:pg"
))
{
Statement
stat
=
conn
.
createStatement
();
assertResult
(
"UNICODE"
,
stat
,
"SHOW CLIENT_ENCODING"
);
assertResult
(
"read committed"
,
stat
,
"SHOW DEFAULT_TRANSACTION_ISOLATION"
);
assertResult
(
"read committed"
,
stat
,
"SHOW TRANSACTION ISOLATION LEVEL"
);
assertResult
(
"ISO"
,
stat
,
"SHOW DATESTYLE"
);
assertResult
(
"8.2.23"
,
stat
,
"SHOW SERVER_VERSION"
);
assertResult
(
"UTF8"
,
stat
,
"SHOW SERVER_ENCODING"
);
}
}
private
void
testMysqlCompatibility
()
throws
SQLException
{
try
(
Connection
conn
=
getConnection
(
"mem:pg"
))
{
Statement
stat
=
conn
.
createStatement
();
ResultSet
rs
;
// show tables without a schema
stat
.
execute
(
"create table person(id int, name varchar)"
);
rs
=
stat
.
executeQuery
(
"SHOW TABLES"
);
assertTrue
(
rs
.
next
());
assertEquals
(
"PERSON"
,
rs
.
getString
(
1
));
assertEquals
(
"PUBLIC"
,
rs
.
getString
(
2
));
assertFalse
(
rs
.
next
());
// show tables with a schema
assertResultRowCount
(
1
,
stat
.
executeQuery
(
"SHOW TABLES FROM PUBLIC"
));
// columns
assertResultRowCount
(
2
,
stat
.
executeQuery
(
"SHOW COLUMNS FROM person"
));
}
}
}
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
9f951e0a
...
@@ -129,9 +129,12 @@ public class TestScript extends TestDb {
...
@@ -129,9 +129,12 @@ public class TestScript extends TestDb {
testScript
(
"ddl/"
+
s
+
".sql"
);
testScript
(
"ddl/"
+
s
+
".sql"
);
}
}
for
(
String
s
:
new
String
[]
{
"error_reporting"
,
"insertIgnore"
,
"merge"
,
"mergeUsing"
,
"replace"
,
for
(
String
s
:
new
String
[]
{
"error_reporting"
,
"insertIgnore"
,
"merge"
,
"mergeUsing"
,
"replace"
,
"script"
,
"with"
})
{
"script"
,
"
show"
,
"
with"
})
{
testScript
(
"dml/"
+
s
+
".sql"
);
testScript
(
"dml/"
+
s
+
".sql"
);
}
}
for
(
String
s
:
new
String
[]
{
"help"
})
{
testScript
(
"other/"
+
s
+
".sql"
);
}
for
(
String
s
:
new
String
[]
{
"avg"
,
"bit-and"
,
"bit-or"
,
"count"
,
for
(
String
s
:
new
String
[]
{
"avg"
,
"bit-and"
,
"bit-or"
,
"count"
,
"group-concat"
,
"max"
,
"median"
,
"min"
,
"selectivity"
,
"stddev-pop"
,
"group-concat"
,
"max"
,
"median"
,
"min"
,
"selectivity"
,
"stddev-pop"
,
"stddev-samp"
,
"sum"
,
"var-pop"
,
"var-samp"
,
"array-agg"
})
{
"stddev-samp"
,
"sum"
,
"var-pop"
,
"var-samp"
,
"array-agg"
})
{
...
...
h2/src/test/org/h2/test/scripts/dml/show.sql
0 → 100644
浏览文件 @
9f951e0a
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
------------------------------
-- PostgreSQL compatibility --
------------------------------
SHOW
CLIENT_ENCODING
;
>
CLIENT_ENCODING
>
---------------
>
UNICODE
>
rows
:
1
SHOW
DEFAULT_TRANSACTION_ISOLATION
;
>
DEFAULT_TRANSACTION_ISOLATION
>
-----------------------------
>
read
committed
>
rows
:
1
SHOW
TRANSACTION
ISOLATION
LEVEL
;
>
TRANSACTION_ISOLATION
>
---------------------
>
read
committed
>
rows
:
1
SHOW
DATESTYLE
;
>
DATESTYLE
>
---------
>
ISO
>
rows
:
1
SHOW
SERVER_VERSION
;
>
SERVER_VERSION
>
--------------
>
8
.
2
.
23
>
rows
:
1
SHOW
SERVER_ENCODING
;
>
SERVER_ENCODING
>
---------------
>
UTF8
>
rows
:
1
-------------------------
-- MySQL compatibility --
-------------------------
CREATE
TABLE
TEST_P
(
ID_P
INT
PRIMARY
KEY
,
U_P
VARCHAR
(
255
)
UNIQUE
,
N_P
INT
DEFAULT
1
);
>
ok
CREATE
SCHEMA
SCH
;
>
ok
CREATE
TABLE
SCH
.
TEST_S
(
ID_S
INT
PRIMARY
KEY
,
U_S
VARCHAR
(
255
)
UNIQUE
,
N_S
INT
DEFAULT
1
);
>
ok
SHOW
TABLES
;
>
TABLE_NAME
TABLE_SCHEMA
>
---------- ------------
>
TEST_P
PUBLIC
>
rows
:
1
SHOW
TABLES
FROM
PUBLIC
;
>
TABLE_NAME
TABLE_SCHEMA
>
---------- ------------
>
TEST_P
PUBLIC
>
rows
:
1
SHOW
TABLES
FROM
SCH
;
>
TABLE_NAME
TABLE_SCHEMA
>
---------- ------------
>
TEST_S
SCH
>
rows
:
1
SHOW
COLUMNS
FROM
TEST_P
;
>
FIELD
TYPE
NULL
KEY
DEFAULT
>
----- ------------ ---- --- -------
>
ID_P
INTEGER
(
10
)
NO
PRI
NULL
>
N_P
INTEGER
(
10
)
YES
1
>
U_P
VARCHAR
(
255
)
YES
UNI
NULL
>
rows
:
3
SHOW
COLUMNS
FROM
TEST_S
FROM
SCH
;
>
FIELD
TYPE
NULL
KEY
DEFAULT
>
----- ------------ ---- --- -------
>
ID_S
INTEGER
(
10
)
NO
PRI
NULL
>
N_S
INTEGER
(
10
)
YES
1
>
U_S
VARCHAR
(
255
)
YES
UNI
NULL
>
rows
:
3
SHOW
DATABASES
;
>
SCHEMA_NAME
>
------------------
>
INFORMATION_SCHEMA
>
PUBLIC
>
SCH
>
rows
:
3
SHOW
SCHEMAS
;
>
SCHEMA_NAME
>
------------------
>
INFORMATION_SCHEMA
>
PUBLIC
>
SCH
>
rows
:
3
DROP
TABLE
TEST_P
;
>
ok
DROP
SCHEMA
SCH
CASCADE
;
>
ok
h2/src/test/org/h2/test/scripts/other/help.sql
0 → 100644
浏览文件 @
9f951e0a
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
help
abc
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ------- ----- ------ ----
>
rows
:
0
HELP
ABCDE
EF_GH
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ------- ----- ------ ----
>
rows
:
0
HELP
HELP
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ---------------- ----- ----------------------- ----------------------------------------------------
>
64
Commands
(
Other
)
HELP
HELP
[
anything
[...]
]
Displays
the
help
pages
of
SQL
commands
or
keywords
.
>
rows
:
1
HELP
he
lp
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ---------------- ----- ----------------------- ----------------------------------------------------
>
64
Commands
(
Other
)
HELP
HELP
[
anything
[...]
]
Displays
the
help
pages
of
SQL
commands
or
keywords
.
>
rows
:
1
h2/src/test/org/h2/test/scripts/testScript.sql
浏览文件 @
9f951e0a
...
@@ -630,38 +630,6 @@ select count(*) from test where id = 'X1';
...
@@ -630,38 +630,6 @@ select count(*) from test where id = 'X1';
drop
table
test
;
drop
table
test
;
>
ok
>
ok
create
table
test
(
id
int
primary
key
,
name
varchar
(
255
),
x
int
);
>
ok
create
unique
index
idx_name1
on
test
(
name
);
>
ok
create
unique
index
idx_name2
on
test
(
name
);
>
ok
show
columns
from
test
;
>
FIELD
TYPE
NULL
KEY
DEFAULT
>
----- ------------ ---- --- -------
>
ID
INTEGER
(
10
)
NO
PRI
NULL
>
NAME
VARCHAR
(
255
)
YES
UNI
NULL
>
X
INTEGER
(
10
)
YES
NULL
>
rows
:
3
show
columns
from
catalogs
from
information_schema
;
>
FIELD
TYPE
NULL
KEY
DEFAULT
>
------------ ------------------- ---- --- -------
>
CATALOG_NAME
VARCHAR
(
2147483647
)
YES
NULL
>
rows
:
1
show
columns
from
information_schema
.
catalogs
;
>
FIELD
TYPE
NULL
KEY
DEFAULT
>
------------ ------------------- ---- --- -------
>
CATALOG_NAME
VARCHAR
(
2147483647
)
YES
NULL
>
rows
:
1
drop
table
test
;
>
ok
create
table
test
(
id
int
,
constraint
pk
primary
key
(
id
),
constraint
x
unique
(
id
));
create
table
test
(
id
int
,
constraint
pk
primary
key
(
id
),
constraint
x
unique
(
id
));
>
ok
>
ok
...
@@ -1109,11 +1077,6 @@ drop table test;
...
@@ -1109,11 +1077,6 @@ drop table test;
alter
table
information_schema
.
help
rename
to
information_schema
.
help2
;
alter
table
information_schema
.
help
rename
to
information_schema
.
help2
;
>
exception
FEATURE_NOT_SUPPORTED_1
>
exception
FEATURE_NOT_SUPPORTED_1
help
abc
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ------- ----- ------ ----
>
rows
:
0
CREATE
TABLE
test
(
id
int
(
25
)
NOT
NULL
auto_increment
,
name
varchar
NOT
NULL
,
PRIMARY
KEY
(
id
,
name
));
CREATE
TABLE
test
(
id
int
(
25
)
NOT
NULL
auto_increment
,
name
varchar
NOT
NULL
,
PRIMARY
KEY
(
id
,
name
));
>
ok
>
ok
...
@@ -6880,12 +6843,6 @@ DROP INDEX IF EXISTS IDXNAME;
...
@@ -6880,12 +6843,6 @@ DROP INDEX IF EXISTS IDXNAME;
DROP
TABLE
TEST
;
DROP
TABLE
TEST
;
>
ok
>
ok
--- help ----------------------------------------------------------------------------------------------
HELP
ABCDE
EF_GH
;
>
ID
SECTION
TOPIC
SYNTAX
TEXT
>
-- ------- ----- ------ ----
>
rows
:
0
--- sequence ----------------------------------------------------------------------------------------------
--- sequence ----------------------------------------------------------------------------------------------
CREATE
CACHED
TABLE
TEST
(
ID
INT
PRIMARY
KEY
);
CREATE
CACHED
TABLE
TEST
(
ID
INT
PRIMARY
KEY
);
>
ok
>
ok
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论