Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b9e6c06e
提交
b9e6c06e
authored
4月 22, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
d536591a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
98 行增加
和
87 行删除
+98
-87
classes.html
h2/src/docsrc/javadoc/classes.html
+2
-0
Parser.java
h2/src/main/org/h2/command/Parser.java
+85
-76
Script.java
h2/src/main/org/h2/command/dml/Script.java
+9
-8
ScriptBase.java
h2/src/main/org/h2/command/dml/ScriptBase.java
+2
-2
Select.java
h2/src/main/org/h2/command/dml/Select.java
+0
-1
没有找到文件。
h2/src/docsrc/javadoc/classes.html
浏览文件 @
b9e6c06e
...
...
@@ -22,6 +22,7 @@ Initial Developer: H2 Group
<br
/>
<b>
JDBC
</b><br
/>
<a
href=
"org/h2/jdbc/JdbcArray.html"
target=
"javadoc"
>
Array
</a><br
/>
<a
href=
"org/h2/jdbc/JdbcBlob.html"
target=
"javadoc"
>
Blob
</a><br
/>
<a
href=
"org/h2/jdbc/JdbcCallableStatement.html"
target=
"javadoc"
>
CallableStatement
</a><br
/>
<a
href=
"org/h2/jdbc/JdbcClob.html"
target=
"javadoc"
>
Clob
</a><br
/>
...
...
@@ -46,6 +47,7 @@ Package org.h2.tools<br />
<a
href=
"org/h2/tools/Csv.html"
target=
"javadoc"
>
Csv
</a><br
/>
<a
href=
"org/h2/tools/DeleteDbFiles.html"
target=
"javadoc"
>
DeleteDbFiles
</a><br
/>
<a
href=
"org/h2/tools/MultiDimension.html"
target=
"javadoc"
>
MultiDimension
</a><br
/>
<a
href=
"org/h2/tools/Script.html"
target=
"javadoc"
>
Script
</a><br
/>
<a
href=
"org/h2/tools/Recover.html"
target=
"javadoc"
>
Recover
</a><br
/>
<a
href=
"org/h2/tools/RunScript.html"
target=
"javadoc"
>
RunScript
</a><br
/>
<a
href=
"org/h2/tools/Server.html"
target=
"javadoc"
>
Server
</a><br
/>
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
b9e6c06e
...
...
@@ -161,6 +161,7 @@ public class Parser {
private
boolean
rightsChecked
;
private
boolean
recompileAlways
;
private
ObjectArray
indexedParameterList
;
private
int
tempViewId
;
public
Parser
(
Session
session
)
{
this
.
session
=
session
;
...
...
@@ -734,7 +735,8 @@ public class Parser {
if
(
isToken
(
"SELECT"
)
||
isToken
(
"FROM"
))
{
Query
query
=
parseQueryWithParams
();
String
querySQL
=
query
.
getSQL
();
table
=
new
TableView
(
mainSchema
,
0
,
"TEMP_VIEW"
,
querySQL
,
query
.
getParameters
(),
null
,
session
,
false
);
int
id
=
tempViewId
++;
table
=
new
TableView
(
mainSchema
,
0
,
"TEMP_VIEW_"
+
id
,
querySQL
,
query
.
getParameters
(),
null
,
session
,
false
);
read
(
")"
);
}
else
{
TableFilter
top
=
readTableFilter
(
fromOuter
);
...
...
@@ -1675,6 +1677,21 @@ public class Parser {
read
(
")"
);
break
;
}
case
Function
.
TABLE
:
{
int
i
=
0
;
ObjectArray
columns
=
new
ObjectArray
();
do
{
String
columnName
=
readAliasIdentifier
();
Column
column
=
parseColumn
(
columnName
);
columns
.
add
(
column
);
read
(
"="
);
function
.
setParameter
(
i
,
readExpression
());
i
++;
}
while
(
readIf
(
","
));
read
(
")"
);
function
.
setColumns
(
columns
);
break
;
}
default
:
if
(!
readIf
(
")"
))
{
int
i
=
0
;
...
...
@@ -3157,51 +3174,46 @@ public class Parser {
}
private
Query
parserWith
()
throws
SQLException
{
// String tempViewName = readUniqueIdentifier();
// if(readIf("(")) {
// String[] cols = parseColumnList(false);
// command.setColumnNames(cols);
//
//
// if(recursive) {
// ObjectArray columns = new ObjectArray();
// for(int i=0; i<cols.length; i++) {
// columns.add(new Column(cols[i], Value.STRING, 0, 0));
// }
// recursiveTable = new TableData(getSchema(), viewName, 0, columns, false);
// recursiveTable.setTemporary(true);
// session.addLocalTempTable(recursiveTable);
// }
return
null
;
String
tempViewName
=
readIdentifierWithSchema
();
Schema
schema
=
getSchema
();
TableData
recursiveTable
;
read
(
"("
);
String
[]
cols
=
parseColumnList
(
false
);
ObjectArray
columns
=
new
ObjectArray
();
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++)
{
columns
.
add
(
new
Column
(
cols
[
i
],
Value
.
STRING
,
0
,
0
));
}
int
id
=
database
.
allocateObjectId
(
true
,
true
);
recursiveTable
=
new
TableData
(
schema
,
tempViewName
,
id
,
columns
,
false
);
recursiveTable
.
setTemporary
(
true
);
session
.
addLocalTempTable
(
recursiveTable
);
String
querySQL
=
StringCache
.
getNew
(
sqlCommand
.
substring
(
parseIndex
));
read
(
"AS"
);
Query
withQuery
=
parseSelect
();
withQuery
.
prepare
();
session
.
removeLocalTempTable
(
recursiveTable
);
id
=
database
.
allocateObjectId
(
true
,
true
);
TableView
view
=
new
TableView
(
schema
,
id
,
tempViewName
,
querySQL
,
null
,
cols
,
session
,
true
);
view
.
setTemporary
(
true
);
// view.setOnCommitDrop(true);
session
.
addLocalTempTable
(
view
);
Query
query
=
parseSelect
();
query
.
prepare
();
query
.
setPrepareAlways
(
true
);
// session.removeLocalTempTable(view);
return
query
;
}
private
CreateView
parseCreateView
(
boolean
force
)
throws
SQLException
{
int
test
;
TableData
recursiveTable
=
null
;
boolean
recursive
=
readIf
(
"RECURSIVE"
);
boolean
ifNotExists
=
readIfNoExists
();
String
viewName
=
readIdentifierWithSchema
();
CreateView
command
=
new
CreateView
(
session
,
getSchema
());
command
.
setRecursive
(
recursive
);
command
.
setViewName
(
viewName
);
command
.
setIfNotExists
(
ifNotExists
);
command
.
setComment
(
readCommentIf
());
if
(
readIf
(
"("
))
{
String
[]
cols
=
parseColumnList
(
false
);
command
.
setColumnNames
(
cols
);
if
(
recursive
)
{
ObjectArray
columns
=
new
ObjectArray
();
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++)
{
columns
.
add
(
new
Column
(
cols
[
i
],
Value
.
STRING
,
0
,
0
));
}
int
id
=
database
.
allocateObjectId
(
true
,
true
);
recursiveTable
=
new
TableData
(
getSchema
(),
viewName
,
id
,
columns
,
false
);
recursiveTable
.
setTemporary
(
true
);
session
.
addLocalTempTable
(
recursiveTable
);
}
}
String
select
=
StringCache
.
getNew
(
sqlCommand
.
substring
(
parseIndex
));
read
(
"AS"
);
...
...
@@ -3216,11 +3228,6 @@ public class Parser {
throw
e
;
}
}
if
(
recursiveTable
!=
null
)
{
session
.
removeLocalTempTable
(
recursiveTable
);
}
return
command
;
}
...
...
@@ -3756,35 +3763,7 @@ public class Parser {
command
.
setIndex
(
schema
.
findIndex
(
indexName
));
}
read
(
"REFERENCES"
);
if
(
readIf
(
"("
))
{
command
.
setRefTableName
(
schema
,
tableName
);
cols
=
parseColumnList
(
false
);
command
.
setRefColumnNames
(
cols
);
}
else
{
String
refTableName
=
readIdentifierWithSchema
(
schema
.
getName
());
command
.
setRefTableName
(
getSchema
(),
refTableName
);
if
(
readIf
(
"("
))
{
cols
=
parseColumnList
(
false
);
command
.
setRefColumnNames
(
cols
);
}
}
if
(
readIf
(
"INDEX"
))
{
String
indexName
=
readIdentifierWithSchema
();
command
.
setRefIndex
(
getSchema
().
findIndex
(
indexName
));
}
while
(
readIf
(
"ON"
))
{
if
(
readIf
(
"DELETE"
))
{
command
.
setDeleteAction
(
parseAction
());
}
else
{
read
(
"UPDATE"
);
command
.
setUpdateAction
(
parseAction
());
}
}
if
(
readIf
(
"NOT"
))
{
read
(
"DEFERRABLE"
);
}
else
{
readIf
(
"DEFERRABLE"
);
}
parseReferences
(
command
,
schema
,
tableName
);
}
else
{
if
(
name
!=
null
)
{
throw
getSyntaxError
();
...
...
@@ -3796,6 +3775,39 @@ public class Parser {
command
.
setComment
(
comment
);
return
command
;
}
private
void
parseReferences
(
AlterTableAddConstraint
command
,
Schema
schema
,
String
tableName
)
throws
SQLException
{
String
[]
cols
;
if
(
readIf
(
"("
))
{
command
.
setRefTableName
(
schema
,
tableName
);
cols
=
parseColumnList
(
false
);
command
.
setRefColumnNames
(
cols
);
}
else
{
String
refTableName
=
readIdentifierWithSchema
(
schema
.
getName
());
command
.
setRefTableName
(
getSchema
(),
refTableName
);
if
(
readIf
(
"("
))
{
cols
=
parseColumnList
(
false
);
command
.
setRefColumnNames
(
cols
);
}
}
if
(
readIf
(
"INDEX"
))
{
String
indexName
=
readIdentifierWithSchema
();
command
.
setRefIndex
(
getSchema
().
findIndex
(
indexName
));
}
while
(
readIf
(
"ON"
))
{
if
(
readIf
(
"DELETE"
))
{
command
.
setDeleteAction
(
parseAction
());
}
else
{
read
(
"UPDATE"
);
command
.
setUpdateAction
(
parseAction
());
}
}
if
(
readIf
(
"NOT"
))
{
read
(
"DEFERRABLE"
);
}
else
{
readIf
(
"DEFERRABLE"
);
}
}
private
CreateLinkedTable
parseCreateLinkedTable
()
throws
SQLException
{
read
(
"TABLE"
);
...
...
@@ -3869,21 +3881,18 @@ public class Parser {
unique
.
setColumnNames
(
new
String
[]{
columnName
});
unique
.
setTableName
(
tableName
);
command
.
addConstraintCommand
(
unique
);
}
else
if
(
readIf
(
"CHECK"
))
{
}
if
(
readIf
(
"CHECK"
))
{
Expression
expr
=
readExpression
();
column
.
addCheckConstraint
(
session
,
expr
);
}
else
if
(
readIf
(
"REFERENCES"
))
{
}
if
(
readIf
(
"REFERENCES"
))
{
AlterTableAddConstraint
ref
=
new
AlterTableAddConstraint
(
session
,
schema
);
ref
.
setConstraintName
(
constraintName
);
ref
.
setType
(
AlterTableAddConstraint
.
REFERENTIAL
);
ref
.
setColumnNames
(
new
String
[]{
columnName
});
ref
.
setTableName
(
tableName
);
String
refTableName
=
readIdentifierWithSchema
(
schema
.
getName
());
ref
.
setRefTableName
(
getSchema
(),
refTableName
);
if
(
readIf
(
"("
))
{
String
[]
cols
=
parseColumnList
(
false
);
ref
.
setRefColumnNames
(
cols
);
}
parseReferences
(
ref
,
schema
,
tableName
);
command
.
addConstraintCommand
(
ref
);
}
}
...
...
h2/src/main/org/h2/command/dml/Script.java
浏览文件 @
b9e6c06e
...
...
@@ -138,6 +138,9 @@ public class Script extends ScriptBase {
ObjectArray
datatypes
=
db
.
getAllUserDataTypes
();
for
(
int
i
=
0
;
i
<
datatypes
.
size
();
i
++)
{
UserDataType
datatype
=
(
UserDataType
)
datatypes
.
get
(
i
);
if
(
drop
)
{
add
(
datatype
.
getDropSQL
(),
false
);
}
add
(
datatype
.
getCreateSQL
(),
false
);
}
ObjectArray
constants
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTANT
);
...
...
@@ -148,6 +151,9 @@ public class Script extends ScriptBase {
ObjectArray
functionAliases
=
db
.
getAllFunctionAliases
();
for
(
int
i
=
0
;
i
<
functionAliases
.
size
();
i
++)
{
FunctionAlias
alias
=
(
FunctionAlias
)
functionAliases
.
get
(
i
);
if
(
drop
)
{
add
(
alias
.
getDropSQL
(),
false
);
}
add
(
alias
.
getCreateSQL
(),
false
);
}
ObjectArray
tables
=
db
.
getAllSchemaObjects
(
DbObject
.
TABLE_OR_VIEW
);
...
...
@@ -167,20 +173,15 @@ public class Script extends ScriptBase {
// null for metadata tables
continue
;
}
String
tableType
=
table
.
getTableType
();
if
(
drop
)
{
if
(
Table
.
VIEW
.
equals
(
tableType
))
{
add
(
"DROP VIEW IF EXISTS "
+
table
.
getSQL
(),
false
);
}
else
{
add
(
"DROP TABLE IF EXISTS "
+
table
.
getSQL
(),
false
);
}
add
(
table
.
getDropSQL
(),
false
);
}
}
ObjectArray
sequences
=
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
);
for
(
int
i
=
0
;
i
<
sequences
.
size
();
i
++)
{
Sequence
sequence
=
(
Sequence
)
sequences
.
get
(
i
);
if
(
drop
&&
!
sequence
.
getBelongsToTable
()
)
{
add
(
"DROP SEQUENCE IF EXISTS "
+
sequence
.
get
SQL
(),
false
);
if
(
drop
)
{
add
(
sequence
.
getDrop
SQL
(),
false
);
}
add
(
sequence
.
getCreateSQL
(),
false
);
}
...
...
h2/src/main/org/h2/command/dml/ScriptBase.java
浏览文件 @
b9e6c06e
...
...
@@ -38,8 +38,7 @@ public class ScriptBase extends Prepared implements DataHandler {
private
FileInputStream
inStream
;
protected
OutputStream
out
;
protected
InputStream
in
;
protected
String
fileName
;
protected
String
fileName
;
private
String
compressionAlgorithm
;
public
ScriptBase
(
Session
session
)
{
...
...
@@ -81,6 +80,7 @@ public class ScriptBase extends Prepared implements DataHandler {
Database
db
=
session
.
getDatabase
();
// script files are always in text format
store
=
FileStore
.
open
(
db
,
fileName
,
magic
,
cipher
,
key
);
store
.
setCheckedWriting
(
false
);
store
.
init
();
}
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
b9e6c06e
...
...
@@ -33,7 +33,6 @@ import org.h2.value.ValueArray;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueNull
;
/**
* visibleColumnCount <= distinctColumnCount <= expressionCount
* Sortable count could include ORDER BY expressions that are not in the select list
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论