Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3a7253d5
Unverified
提交
3a7253d5
authored
1月 12, 2018
作者:
Noel Grandin
提交者:
GitHub
1月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #749 from katzyn/build_errors
Fix some build checks in sources
上级
08742763
815ce845
显示空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
248 行增加
和
218 行删除
+248
-218
Parser.java
h2/src/main/org/h2/command/Parser.java
+36
-33
CreateView.java
h2/src/main/org/h2/command/ddl/CreateView.java
+9
-6
DropView.java
h2/src/main/org/h2/command/ddl/DropView.java
+4
-4
MergeUsing.java
h2/src/main/org/h2/command/dml/MergeUsing.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+5
-4
Database.java
h2/src/main/org/h2/engine/Database.java
+5
-5
Session.java
h2/src/main/org/h2/engine/Session.java
+13
-3
JdbcStatementBackwardsCompat.java
h2/src/main/org/h2/jdbc/JdbcStatementBackwardsCompat.java
+1
-1
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+5
-5
FilePathDisk.java
h2/src/main/org/h2/store/fs/FilePathDisk.java
+1
-1
Table.java
h2/src/main/org/h2/table/Table.java
+1
-1
TableView.java
h2/src/main/org/h2/table/TableView.java
+27
-24
SourceCompiler.java
h2/src/main/org/h2/util/SourceCompiler.java
+1
-1
AbstractBaseForCommonTableExpressions.java
...org/h2/test/db/AbstractBaseForCommonTableExpressions.java
+76
-72
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+2
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+2
-1
TestGeneralCommonTableQueries.java
...rc/test/org/h2/test/db/TestGeneralCommonTableQueries.java
+32
-30
TestPersistentCommonTableExpressions.java
.../org/h2/test/db/TestPersistentCommonTableExpressions.java
+13
-13
TestTriggersConstraints.java
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
+2
-1
TestMvccMultiThreaded2.java
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded2.java
+12
-11
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
3a7253d5
...
...
@@ -1136,7 +1136,8 @@ public class Parser {
command
.
setQueryAlias
(
readFromAlias
(
null
,
Arrays
.
asList
(
"ON"
)));
String
[]
querySQLOutput
=
new
String
[]{
null
};
List
<
Column
>
columnTemplateList
=
TableView
.
createQueryColumnTemplateList
(
null
,
command
.
getQuery
(),
querySQLOutput
);
List
<
Column
>
columnTemplateList
=
TableView
.
createQueryColumnTemplateList
(
null
,
command
.
getQuery
(),
querySQLOutput
);
TableView
temporarySourceTableView
=
createCTEView
(
command
.
getQueryAlias
(),
querySQLOutput
[
0
],
columnTemplateList
,
false
/* no recursion */
,
...
...
@@ -5154,8 +5155,8 @@ public class Parser {
List
<
TableView
>
viewsCreated
=
new
ArrayList
<>();
readIf
(
"RECURSIVE"
);
// this WITH statement might not be a temporary view - allow optional keyword to
tell us that
// this keyword. This feature will not be documented - H2 internal use only.
// this WITH statement might not be a temporary view - allow optional keyword to
// t
ell us that t
his keyword. This feature will not be documented - H2 internal use only.
boolean
isPersistent
=
readIf
(
"PERSISTENT"
);
// this WITH statement is not a temporary view - it is part of a persistent view
...
...
@@ -5307,7 +5308,8 @@ public class Parser {
synchronized
(
targetSession
)
{
view
=
new
TableView
(
schema
,
id
,
cteViewName
,
querySQL
,
parameters
,
columnTemplateArray
,
targetSession
,
allowRecursiveQueryDetection
,
false
/* literalsChecked */
,
true
/* isTableExpression */
,
isPersistent
);
allowRecursiveQueryDetection
,
false
/* literalsChecked */
,
true
/* isTableExpression */
,
isPersistent
);
if
(!
view
.
isRecursiveQueryDetected
()
&&
allowRecursiveQueryDetection
)
{
if
(
isPersistent
)
{
db
.
addSchemaObject
(
targetSession
,
view
);
...
...
@@ -5318,7 +5320,8 @@ public class Parser {
}
view
=
new
TableView
(
schema
,
id
,
cteViewName
,
querySQL
,
parameters
,
columnTemplateArray
,
targetSession
,
false
/* assume recursive */
,
false
/* literalsChecked */
,
true
/* isTableExpression */
,
isPersistent
);
false
/* assume recursive */
,
false
/* literalsChecked */
,
true
/* isTableExpression */
,
isPersistent
);
}
// both removeSchemaObject and removeLocalTempTable hold meta locks
targetSession
.
getDatabase
().
unlockMeta
(
targetSession
);
...
...
h2/src/main/org/h2/command/ddl/CreateView.java
浏览文件 @
3a7253d5
...
...
@@ -117,9 +117,12 @@ public class CreateView extends SchemaCommand {
}
if
(
view
==
null
)
{
if
(
isTableExpression
)
{
view
=
TableView
.
createTableViewMaybeRecursive
(
getSchema
(),
id
,
viewName
,
querySQL
,
null
,
columnTemplatesAsStrings
,
session
,
false
/* literalsChecked */
,
isTableExpression
,
true
/*isPersistent*/
,
db
);
view
=
TableView
.
createTableViewMaybeRecursive
(
getSchema
(),
id
,
viewName
,
querySQL
,
null
,
columnTemplatesAsStrings
,
session
,
false
/* literalsChecked */
,
isTableExpression
,
true
/* isPersistent */
,
db
);
}
else
{
view
=
new
TableView
(
getSchema
(),
id
,
viewName
,
querySQL
,
null
,
columnTemplatesAsUnknowns
,
session
,
false
/* allow recursive */
,
false
/* literalsChecked */
,
isTableExpression
,
true
);
view
=
new
TableView
(
getSchema
(),
id
,
viewName
,
querySQL
,
null
,
columnTemplatesAsUnknowns
,
session
,
false
/* allow recursive */
,
false
/* literalsChecked */
,
isTableExpression
,
true
);
}
}
else
{
// TODO support isTableExpression in replace function...
...
...
h2/src/main/org/h2/command/ddl/DropView.java
浏览文件 @
3a7253d5
h2/src/main/org/h2/command/dml/MergeUsing.java
浏览文件 @
3a7253d5
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
3a7253d5
...
...
@@ -1064,8 +1064,9 @@ public class Select extends Query {
if
(
tableView
!=
null
&&
tableView
.
isRecursive
()
&&
tableView
.
isTableExpression
())
{
if
(
tableView
.
isPersistent
())
{
// skip the generation of plan SQL for this already recursive persistent ctes, since using a with
// statement will re-create the common table expression views.
// skip the generation of plan SQL for this already recursive persistent CTEs,
// since using a with statement will re-create the common table expression
// views.
continue
;
}
else
{
buff
.
append
(
"WITH RECURSIVE "
).
append
(
t
.
getName
()).
append
(
'('
);
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
3a7253d5
h2/src/main/org/h2/engine/Session.java
浏览文件 @
3a7253d5
...
...
@@ -229,6 +229,16 @@ public class Session extends SessionWithState {
return
subQueryInfo
;
}
/**
* Stores name of currently parsed view in a stack so it can be determined
* during {@code prepare()}.
*
* @param parsingView
* {@code true} to store one more name, {@code false} to remove it
* from stack
* @param viewName
* name of the view
*/
public
void
setParsingCreateView
(
boolean
parsingView
,
String
viewName
)
{
// It can be recursive, thus implemented as counter.
this
.
parsingView
+=
parsingView
?
1
:
-
1
;
...
...
h2/src/main/org/h2/jdbc/JdbcStatementBackwardsCompat.java
浏览文件 @
3a7253d5
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
3a7253d5
h2/src/main/org/h2/store/fs/FilePathDisk.java
浏览文件 @
3a7253d5
h2/src/main/org/h2/table/Table.java
浏览文件 @
3a7253d5
h2/src/main/org/h2/table/TableView.java
浏览文件 @
3a7253d5
...
...
@@ -67,7 +67,8 @@ public class TableView extends Table {
ArrayList
<
Parameter
>
params
,
Column
[]
columnTemplates
,
Session
session
,
boolean
allowRecursive
,
boolean
literalsChecked
,
boolean
isTableExpression
,
boolean
isPersistent
)
{
super
(
schema
,
id
,
name
,
false
,
true
);
init
(
querySQL
,
params
,
columnTemplates
,
session
,
allowRecursive
,
literalsChecked
,
isTableExpression
,
isPersistent
);
init
(
querySQL
,
params
,
columnTemplates
,
session
,
allowRecursive
,
literalsChecked
,
isTableExpression
,
isPersistent
);
}
/**
...
...
@@ -746,15 +747,17 @@ public class TableView extends Table {
parameters
,
columnTemplateList
.
toArray
(
columnTemplates
),
session
,
true
/* try recursive */
,
literalsChecked
,
isTableExpression
,
isPersistent
);
// is recursion really detected ? if not - recreate it without recursion flag and no recursive index
// is recursion really detected ? if not - recreate it without recursion flag
// and no recursive index
if
(!
view
.
isRecursiveQueryDetected
())
{
if
(
isPersistent
)
{
db
.
addSchemaObject
(
session
,
view
);
view
.
lock
(
session
,
true
,
true
);
session
.
getDatabase
().
removeSchemaObject
(
session
,
view
);
// during database startup - this method does not normally get called - and it needs to be
// to correctly un-register the table which the table expression uses...
// during database startup - this method does not normally get called - and it
// needs to be to correctly un-register the table which the table expression
// uses...
view
.
removeChildrenAndResources
(
session
);
}
else
{
session
.
removeLocalTempTable
(
view
);
...
...
h2/src/main/org/h2/util/SourceCompiler.java
浏览文件 @
3a7253d5
h2/src/test/org/h2/test/db/AbstractBaseForCommonTableExpressions.java
浏览文件 @
3a7253d5
...
...
@@ -11,27 +11,29 @@ import java.sql.ResultSet;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
org.h2.test.TestBase
;
/**
* Base class for common table expression tests
*/
public
abstract
class
AbstractBaseForCommonTableExpressions
extends
TestBase
{
protected
void
testRepeatedQueryWithSetup
(
int
maxRetries
,
String
[]
expectedRowData
,
String
[]
expectedColumnNames
,
int
expectedNumbeOfRows
,
String
setupSQL
,
String
withQuery
,
int
closeAndReopenDatabaseConnectionOnIteration
,
String
[]
expectedColumnTypes
)
throws
SQLException
{
protected
void
testRepeatedQueryWithSetup
(
int
maxRetries
,
String
[]
expectedRowData
,
String
[]
expectedColumnNames
,
int
expectedNumberOfRows
,
String
setupSQL
,
String
withQuery
,
int
closeAndReopenDatabaseConnectionOnIteration
,
String
[]
expectedColumnTypes
)
throws
SQLException
{
deleteDb
(
"commonTableExpressionQueries"
);
Connection
conn
=
getConnection
(
"commonTableExpressionQueries"
);
PreparedStatement
prep
;
ResultSet
rs
;
for
(
int
queryRunTries
=
1
;
queryRunTries
<=
maxRetries
;
queryRunTries
++)
{
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
setupSQL
);
stat
.
close
();
// close and re-open connection for one iteration to make sure the query work between connections
// close and re-open connection for one iteration to make sure the query work
// between connections
if
(
queryRunTries
==
closeAndReopenDatabaseConnectionOnIteration
)
{
conn
.
close
();
...
...
@@ -44,7 +46,9 @@ public abstract class AbstractBaseForCommonTableExpressions extends TestBase {
assertTrue
(
rs
.
getMetaData
().
getColumnLabel
(
columnIndex
)
!=
null
);
assertEquals
(
expectedColumnNames
[
columnIndex
-
1
],
rs
.
getMetaData
().
getColumnLabel
(
columnIndex
));
assertEquals
(
"wrongly type column "
+
rs
.
getMetaData
().
getColumnLabel
(
columnIndex
)+
" on iteration#"
+
queryRunTries
,
assertEquals
(
"wrong type of column "
+
rs
.
getMetaData
().
getColumnLabel
(
columnIndex
)
+
" on iteration #"
+
queryRunTries
,
expectedColumnTypes
[
columnIndex
-
1
],
rs
.
getMetaData
().
getColumnTypeName
(
columnIndex
));
}
...
...
@@ -52,13 +56,13 @@ public abstract class AbstractBaseForCommonTableExpressions extends TestBase {
while
(
rs
.
next
())
{
StringBuffer
buf
=
new
StringBuffer
();
for
(
int
columnIndex
=
1
;
columnIndex
<=
rs
.
getMetaData
().
getColumnCount
();
columnIndex
++)
{
buf
.
append
(
"|"
+
rs
.
getString
(
columnIndex
));
buf
.
append
(
"|"
+
rs
.
getString
(
columnIndex
));
}
assertEquals
(
expectedRowData
[
rowNdx
],
buf
.
toString
());
rowNdx
++;
}
assertEquals
(
expectedNumbeOfRows
,
rowNdx
);
assertEquals
(
expectedNumberOfRows
,
rowNdx
);
rs
.
close
();
prep
.
close
();
...
...
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
3a7253d5
...
...
@@ -302,7 +302,8 @@ public class TestCases extends TestBase {
throws
SQLException
{
assertThrows
(
expectedDropSuccess
?
0
:
ErrorCode
.
CANNOT_DROP_2
,
stat
)
.
execute
(
"drop table test "
+
(
restrict
?
"restrict"
:
"cascade"
));
assertThrows
(
expectedDropSuccess
?
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
:
0
,
stat
).
execute
(
"select * from test"
);
assertThrows
(
expectedDropSuccess
?
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
:
0
,
stat
)
.
execute
(
"select * from test"
);
}
private
void
testDropTableNoReference
(
final
boolean
stdDropTableRestrict
,
final
boolean
restrict
)
...
...
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
3a7253d5
...
...
@@ -2061,7 +2061,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
stat
).
execute
(
"select signal('00145', 'success class is invalid')"
);
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
stat
).
execute
(
"select signal('foo', 'SQLSTATE has 5 chars')"
);
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
stat
).
execute
(
"select signal('Ab123', 'SQLSTATE has only digits or upper-case letters')"
);
assertThrows
(
ErrorCode
.
INVALID_VALUE_2
,
stat
)
.
execute
(
"select signal('Ab123', 'SQLSTATE has only digits or upper-case letters')"
);
try
{
stat
.
execute
(
"select signal('AB123', 'some custom error')"
);
fail
(
"Should have thrown"
);
...
...
h2/src/test/org/h2/test/db/TestGeneralCommonTableQueries.java
浏览文件 @
3a7253d5
...
...
@@ -526,8 +526,10 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
config
=
new
TestAll
();
try
{
//Test with settings: lazy mvStore memory mvcc multiThreaded
// connection url is =mem:script;MV_STORE=true;LOG=1;LOCK_TIMEOUT=50;MVCC=TRUE;MULTI_THREADED=TRUE;LAZY_QUERY_EXECUTION=1
// Test with settings: lazy mvStore memory mvcc multiThreaded
// connection url is
// mem:script;MV_STORE=true;LOG=1;LOCK_TIMEOUT=50;MVCC=TRUE;
// MULTI_THREADED=TRUE;LAZY_QUERY_EXECUTION=1
config
.
lazy
=
true
;
config
.
mvStore
=
true
;
config
.
memory
=
true
;
...
...
@@ -545,8 +547,8 @@ public class TestGeneralCommonTableQueries extends AbstractBaseForCommonTableExp
int
maxRetries
=
10
;
int
expectedNumberOfRows
=
expectedRowData
.
length
;
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumberOfRows
,
setupSQL
,
withQuery
,
maxRetries
-
1
,
expectedColumnTypes
);
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumberOfRows
,
setupSQL
,
withQuery
,
maxRetries
-
1
,
expectedColumnTypes
);
}
finally
{
config
=
backupConfig
;
}
...
...
h2/src/test/org/h2/test/db/TestPersistentCommonTableExpressions.java
浏览文件 @
3a7253d5
...
...
@@ -94,7 +94,7 @@ public class TestPersistentCommonTableExpressions extends AbstractBaseForCommonT
}
private
void
testPersistentRecursiveTableInCreateView
()
throws
Exception
{
String
setu
o
SQL
=
"--SET TRACE_LEVEL_SYSTEM_OUT 3;\n"
String
setu
p
SQL
=
"--SET TRACE_LEVEL_SYSTEM_OUT 3;\n"
+
"DROP TABLE IF EXISTS my_tree; \n"
+
"DROP VIEW IF EXISTS v_my_tree; \n"
+
"CREATE TABLE my_tree ( \n"
...
...
@@ -137,7 +137,7 @@ public class TestPersistentCommonTableExpressions extends AbstractBaseForCommonT
String
[]
expectedColumnNames
=
new
String
[]{
"SUB_TREE_ROOT_ID"
,
"TREE_LEVEL"
,
"PARENT_FK"
,
"CHILD_FK"
};
String
[]
expectedColumnTypes
=
new
String
[]{
"INTEGER"
,
"INTEGER"
,
"INTEGER"
,
"INTEGER"
};
int
expectedNumberOfRows
=
11
;
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumberOfRows
,
setu
o
SQL
,
testRepeatedQueryWithSetup
(
maxRetries
,
expectedRowData
,
expectedColumnNames
,
expectedNumberOfRows
,
setu
p
SQL
,
withQuery
,
maxRetries
-
1
,
expectedColumnTypes
);
}
...
...
h2/src/test/org/h2/test/db/TestTriggersConstraints.java
浏览文件 @
3a7253d5
...
...
@@ -506,7 +506,8 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
}
else
if
(
"javascript"
.
equals
(
sourceLang
))
{
String
triggerClassName
=
this
.
getClass
().
getName
()
+
"."
+
TestTriggerAlterTable
.
class
.
getSimpleName
();
final
String
body
=
"//javascript\nnew Packages."
+
triggerClassName
+
"();"
;
final
String
body
=
"//javascript\n"
+
"new Packages."
+
triggerClassName
+
"();"
;
stat
.
execute
(
"create trigger test_upd before insert on test as $$"
+
body
+
" $$"
);
}
else
{
...
...
h2/src/test/org/h2/test/mvcc/TestMvccMultiThreaded2.java
浏览文件 @
3a7253d5
...
...
@@ -93,10 +93,11 @@ public class TestMvccMultiThreaded2 extends TestBase {
}
if
(
DISPLAY_STATS
)
{
System
.
out
.
println
(
String
.
format
(
"+ INFO: TestMvccMultiThreaded2 RUN STATS threads=%d, minProcessed=%d, maxProcessed=%d, "
+
"totalProcessed=%d, averagePerThread=%d, averagePerThreadPerSecond=%d\n"
,
TEST_THREAD_COUNT
,
minProcessed
,
maxProcessed
,
totalProcessed
,
totalProcessed
/
TEST_THREAD_COUNT
,
totalProcessed
/(
TEST_THREAD_COUNT
*
TEST_TIME_SECONDS
)));
System
.
out
.
println
(
String
.
format
(
"+ INFO: TestMvccMultiThreaded2 RUN STATS threads=%d, minProcessed=%d, maxProcessed=%d, "
+
"totalProcessed=%d, averagePerThread=%d, averagePerThreadPerSecond=%d\n"
,
TEST_THREAD_COUNT
,
minProcessed
,
maxProcessed
,
totalProcessed
,
totalProcessed
/
TEST_THREAD_COUNT
,
totalProcessed
/
(
TEST_THREAD_COUNT
*
TEST_TIME_SECONDS
)));
}
IOUtils
.
closeSilently
(
conn
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论