Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f5d37007
提交
f5d37007
authored
7月 16, 2017
作者:
Noel Grandin
提交者:
GitHub
7月 16, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #565 from NiklasMehner/master
Refactor synonym implementation
上级
810a0771
5305a2d1
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
73 个修改的文件
包含
652 行增加
和
1426 行删除
+652
-1426
Parser.java
h2/src/main/org/h2/command/Parser.java
+52
-28
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+12
-9
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+11
-11
AlterTableRename.java
h2/src/main/org/h2/command/ddl/AlterTableRename.java
+3
-3
AlterTableRenameColumn.java
h2/src/main/org/h2/command/ddl/AlterTableRenameColumn.java
+2
-2
Analyze.java
h2/src/main/org/h2/command/ddl/Analyze.java
+6
-6
CreateIndex.java
h2/src/main/org/h2/command/ddl/CreateIndex.java
+2
-2
CreateLinkedTable.java
h2/src/main/org/h2/command/ddl/CreateLinkedTable.java
+1
-1
CreateSynonym.java
h2/src/main/org/h2/command/ddl/CreateSynonym.java
+10
-5
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+1
-1
CreateTrigger.java
h2/src/main/org/h2/command/ddl/CreateTrigger.java
+2
-2
CreateUserDataType.java
h2/src/main/org/h2/command/ddl/CreateUserDataType.java
+2
-2
CreateView.java
h2/src/main/org/h2/command/ddl/CreateView.java
+2
-2
DropDatabase.java
h2/src/main/org/h2/command/ddl/DropDatabase.java
+8
-8
DropSynonym.java
h2/src/main/org/h2/command/ddl/DropSynonym.java
+5
-7
DropTable.java
h2/src/main/org/h2/command/ddl/DropTable.java
+2
-2
DropTrigger.java
h2/src/main/org/h2/command/ddl/DropTrigger.java
+2
-2
DropView.java
h2/src/main/org/h2/command/ddl/DropView.java
+2
-2
GrantRevoke.java
h2/src/main/org/h2/command/ddl/GrantRevoke.java
+5
-5
TruncateTable.java
h2/src/main/org/h2/command/ddl/TruncateTable.java
+3
-3
AlterSequence.java
h2/src/main/org/h2/command/dml/AlterSequence.java
+2
-2
AlterTableSet.java
h2/src/main/org/h2/command/dml/AlterTableSet.java
+2
-2
Delete.java
h2/src/main/org/h2/command/dml/Delete.java
+2
-2
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+3
-3
Merge.java
h2/src/main/org/h2/command/dml/Merge.java
+3
-3
Query.java
h2/src/main/org/h2/command/dml/Query.java
+2
-2
Replace.java
h2/src/main/org/h2/command/dml/Replace.java
+3
-3
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+10
-11
Select.java
h2/src/main/org/h2/command/dml/Select.java
+7
-7
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+3
-3
Set.java
h2/src/main/org/h2/command/dml/Set.java
+4
-4
Update.java
h2/src/main/org/h2/command/dml/Update.java
+2
-2
Constraint.java
h2/src/main/org/h2/constraint/Constraint.java
+7
-7
ConstraintCheck.java
h2/src/main/org/h2/constraint/ConstraintCheck.java
+5
-5
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+8
-9
ConstraintUnique.java
h2/src/main/org/h2/constraint/ConstraintUnique.java
+6
-6
Comment.java
h2/src/main/org/h2/engine/Comment.java
+2
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+28
-15
DbObject.java
h2/src/main/org/h2/engine/DbObject.java
+7
-3
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+2
-2
MetaRecord.java
h2/src/main/org/h2/engine/MetaRecord.java
+6
-4
Right.java
h2/src/main/org/h2/engine/Right.java
+1
-2
RightOwner.java
h2/src/main/org/h2/engine/RightOwner.java
+2
-2
Role.java
h2/src/main/org/h2/engine/Role.java
+2
-2
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-3
Setting.java
h2/src/main/org/h2/engine/Setting.java
+2
-2
UndoLog.java
h2/src/main/org/h2/engine/UndoLog.java
+4
-4
UndoLogRecord.java
h2/src/main/org/h2/engine/UndoLogRecord.java
+4
-4
User.java
h2/src/main/org/h2/engine/User.java
+4
-4
UserAggregate.java
h2/src/main/org/h2/engine/UserAggregate.java
+2
-2
UserDataType.java
h2/src/main/org/h2/engine/UserDataType.java
+2
-2
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+3
-3
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+3
-3
ExpressionVisitor.java
h2/src/main/org/h2/expression/ExpressionVisitor.java
+5
-5
Function.java
h2/src/main/org/h2/expression/Function.java
+2
-2
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+1
-2
MultiVersionIndex.java
h2/src/main/org/h2/index/MultiVersionIndex.java
+1
-2
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+45
-4
Constant.java
h2/src/main/org/h2/schema/Constant.java
+2
-2
Schema.java
h2/src/main/org/h2/schema/Schema.java
+57
-13
Sequence.java
h2/src/main/org/h2/schema/Sequence.java
+2
-2
TriggerObject.java
h2/src/main/org/h2/schema/TriggerObject.java
+5
-5
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+2
-3
AbstractTable.java
h2/src/main/org/h2/table/AbstractTable.java
+0
-608
Column.java
h2/src/main/org/h2/table/Column.java
+3
-3
IndexColumn.java
h2/src/main/org/h2/table/IndexColumn.java
+1
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+22
-24
Table.java
h2/src/main/org/h2/table/Table.java
+183
-74
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+3
-3
TableSynonym.java
h2/src/main/org/h2/table/TableSynonym.java
+11
-428
TableType.java
h2/src/main/org/h2/table/TableType.java
+1
-6
TableView.java
h2/src/main/org/h2/table/TableView.java
+6
-6
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+22
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
f5d37007
差异被折叠。
点击展开。
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
f5d37007
...
...
@@ -22,9 +22,9 @@ import org.h2.index.Index;
import
org.h2.index.IndexType
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
...
...
@@ -62,7 +62,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
ifTableExists
=
b
;
}
private
String
generateConstraintName
(
Abstract
Table
table
)
{
private
String
generateConstraintName
(
Table
table
)
{
if
(
constraintName
==
null
)
{
constraintName
=
getSchema
().
getUniqueConstraintName
(
session
,
table
);
...
...
@@ -94,7 +94,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
session
.
commit
(
true
);
}
Database
db
=
session
.
getDatabase
();
Abstract
Table
table
=
getSchema
().
findTableOrView
(
session
,
tableName
);
Table
table
=
getSchema
().
findTableOrView
(
session
,
tableName
);
if
(
table
==
null
)
{
if
(
ifTableExists
)
{
return
0
;
...
...
@@ -197,7 +197,10 @@ public class AlterTableAddConstraint extends SchemaCommand {
break
;
}
case
CommandInterface
.
ALTER_TABLE_ADD_CONSTRAINT_REFERENTIAL
:
{
AbstractTable
refTable
=
refSchema
.
getTableOrView
(
session
,
refTableName
);
Table
refTable
=
refSchema
.
resolveTableOrView
(
session
,
refTableName
);
if
(
refTable
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
refTableName
);
}
session
.
getUser
().
checkRight
(
refTable
,
Right
.
ALL
);
if
(!
refTable
.
canReference
())
{
throw
DbException
.
getUnsupportedException
(
"Reference "
+
...
...
@@ -271,7 +274,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
0
;
}
private
Index
createIndex
(
Abstract
Table
t
,
IndexColumn
[]
cols
,
boolean
unique
)
{
private
Index
createIndex
(
Table
t
,
IndexColumn
[]
cols
,
boolean
unique
)
{
int
indexId
=
getObjectId
();
IndexType
indexType
;
if
(
unique
)
{
...
...
@@ -303,7 +306,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
this
.
updateAction
=
action
;
}
private
static
Index
getUniqueIndex
(
Abstract
Table
t
,
IndexColumn
[]
cols
)
{
private
static
Index
getUniqueIndex
(
Table
t
,
IndexColumn
[]
cols
)
{
if
(
t
.
getIndexes
()
==
null
)
{
return
null
;
}
...
...
@@ -315,7 +318,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
null
;
}
private
static
Index
getIndex
(
Abstract
Table
t
,
IndexColumn
[]
cols
,
boolean
moreColumnOk
)
{
private
static
Index
getIndex
(
Table
t
,
IndexColumn
[]
cols
,
boolean
moreColumnOk
)
{
if
(
t
.
getIndexes
()
==
null
)
{
return
null
;
}
...
...
@@ -327,7 +330,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
null
;
}
private
static
boolean
canUseUniqueIndex
(
Index
idx
,
Abstract
Table
table
,
private
static
boolean
canUseUniqueIndex
(
Index
idx
,
Table
table
,
IndexColumn
[]
cols
)
{
if
(
idx
.
getTable
()
!=
table
||
!
idx
.
getIndexType
().
isUnique
())
{
return
false
;
...
...
@@ -350,7 +353,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
return
true
;
}
private
static
boolean
canUseIndex
(
Index
existingIndex
,
Abstract
Table
table
,
private
static
boolean
canUseIndex
(
Index
existingIndex
,
Table
table
,
IndexColumn
[]
cols
,
boolean
moreColumnsOk
)
{
if
(
existingIndex
.
getTable
()
!=
table
||
existingIndex
.
getCreateSQL
()
==
null
)
{
// can't use the scan index or index of another table
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
f5d37007
...
...
@@ -29,8 +29,8 @@ import org.h2.schema.Schema;
import
org.h2.schema.SchemaObject
;
import
org.h2.schema.Sequence
;
import
org.h2.schema.TriggerObject
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.TableView
;
import
org.h2.util.New
;
...
...
@@ -92,7 +92,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
public
int
update
()
{
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
AbstractTable
table
=
getSchema
().
find
TableOrView
(
session
,
tableName
);
Table
table
=
getSchema
().
resolve
TableOrView
(
session
,
tableName
);
if
(
table
==
null
)
{
if
(
ifTableExists
)
{
return
0
;
...
...
@@ -211,7 +211,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
return
0
;
}
private
static
void
checkDefaultReferencesTable
(
Abstract
Table
table
,
Expression
defaultExpression
)
{
private
static
void
checkDefaultReferencesTable
(
Table
table
,
Expression
defaultExpression
)
{
if
(
defaultExpression
==
null
)
{
return
;
}
...
...
@@ -234,7 +234,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
private
void
convertAutoIncrementColumn
(
Abstract
Table
table
,
Column
c
)
{
private
void
convertAutoIncrementColumn
(
Table
table
,
Column
c
)
{
if
(
c
.
isAutoIncrement
())
{
if
(
c
.
isPrimaryKey
())
{
c
.
setOriginalSQL
(
"IDENTITY"
);
...
...
@@ -246,7 +246,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
private
void
removeSequence
(
Abstract
Table
table
,
Sequence
sequence
)
{
private
void
removeSequence
(
Table
table
,
Sequence
sequence
)
{
if
(
sequence
!=
null
)
{
table
.
removeSequence
(
sequence
);
sequence
.
setBelongsToTable
(
false
);
...
...
@@ -255,7 +255,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
private
void
copyData
(
Abstract
Table
table
)
{
private
void
copyData
(
Table
table
)
{
if
(
table
.
isTemporary
())
{
throw
DbException
.
getUnsupportedException
(
"TEMP TABLE"
);
}
...
...
@@ -264,7 +264,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
String
tempName
=
db
.
getTempTableName
(
baseName
,
session
);
Column
[]
columns
=
table
.
getColumns
();
ArrayList
<
Column
>
newColumns
=
New
.
arrayList
();
Abstract
Table
newTable
=
cloneTableStructure
(
table
,
columns
,
db
,
tempName
,
newColumns
);
Table
newTable
=
cloneTableStructure
(
table
,
columns
,
db
,
tempName
,
newColumns
);
try
{
// check if a view would become invalid
// (because the column to drop is referenced or so)
...
...
@@ -314,7 +314,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
private
AbstractTable
cloneTableStructure
(
Abstract
Table
table
,
Column
[]
columns
,
Database
db
,
private
Table
cloneTableStructure
(
Table
table
,
Column
[]
columns
,
Database
db
,
String
tempName
,
ArrayList
<
Column
>
newColumns
)
{
for
(
Column
col
:
columns
)
{
newColumns
.
add
(
col
.
getClone
());
...
...
@@ -368,7 +368,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
data
.
isHidden
=
table
.
isHidden
();
data
.
create
=
true
;
data
.
session
=
session
;
Abstract
Table
newTable
=
getSchema
().
createTable
(
data
);
Table
newTable
=
getSchema
().
createTable
(
data
);
newTable
.
setComment
(
table
.
getComment
());
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
newTable
.
getCreateSQL
());
...
...
@@ -504,7 +504,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
private
void
checkNullable
(
Abstract
Table
table
)
{
private
void
checkNullable
(
Table
table
)
{
for
(
Index
index
:
table
.
getIndexes
())
{
if
(
index
.
getColumnIndex
(
oldColumn
)
<
0
)
{
continue
;
...
...
@@ -517,7 +517,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
private
void
checkNoNullValues
(
Abstract
Table
table
)
{
private
void
checkNoNullValues
(
Table
table
)
{
String
sql
=
"SELECT COUNT(*) FROM "
+
table
.
getSQL
()
+
" WHERE "
+
oldColumn
.
getSQL
()
+
" IS NULL"
;
...
...
h2/src/main/org/h2/command/ddl/AlterTableRename.java
浏览文件 @
f5d37007
...
...
@@ -12,7 +12,7 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -45,7 +45,7 @@ public class AlterTableRename extends SchemaCommand {
public
int
update
()
{
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
Abstract
Table
oldTable
=
getSchema
().
findTableOrView
(
session
,
oldTableName
);
Table
oldTable
=
getSchema
().
findTableOrView
(
session
,
oldTableName
);
if
(
oldTable
==
null
)
{
if
(
ifTableExists
)
{
return
0
;
...
...
@@ -53,7 +53,7 @@ public class AlterTableRename extends SchemaCommand {
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
oldTableName
);
}
session
.
getUser
().
checkRight
(
oldTable
,
Right
.
ALL
);
Abstract
Table
t
=
getSchema
().
findTableOrView
(
session
,
newTableName
);
Table
t
=
getSchema
().
findTableOrView
(
session
,
newTableName
);
if
(
t
!=
null
&&
hidden
&&
newTableName
.
equals
(
oldTable
.
getName
()))
{
if
(!
t
.
isHidden
())
{
t
.
setHidden
(
hidden
);
...
...
h2/src/main/org/h2/command/ddl/AlterTableRenameColumn.java
浏览文件 @
f5d37007
...
...
@@ -14,8 +14,8 @@ import org.h2.engine.Session;
import
org.h2.expression.Expression
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -52,7 +52,7 @@ public class AlterTableRenameColumn extends SchemaCommand {
public
int
update
()
{
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
Abstract
Table
table
=
getSchema
().
findTableOrView
(
session
,
tableName
);
Table
table
=
getSchema
().
findTableOrView
(
session
,
tableName
);
if
(
table
==
null
)
{
if
(
ifTableExists
)
{
return
0
;
...
...
h2/src/main/org/h2/command/ddl/Analyze.java
浏览文件 @
f5d37007
...
...
@@ -13,8 +13,8 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.expression.Parameter
;
import
org.h2.result.ResultInterface
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.TableType
;
import
org.h2.util.StatementBuilder
;
import
org.h2.value.Value
;
...
...
@@ -34,14 +34,14 @@ public class Analyze extends DefineCommand {
/**
* used in ANALYZE TABLE...
*/
private
Abstract
Table
table
;
private
Table
table
;
public
Analyze
(
Session
session
)
{
super
(
session
);
sampleRows
=
session
.
getDatabase
().
getSettings
().
analyzeSample
;
}
public
void
setTable
(
Abstract
Table
table
)
{
public
void
setTable
(
Table
table
)
{
this
.
table
=
table
;
}
...
...
@@ -53,7 +53,7 @@ public class Analyze extends DefineCommand {
if
(
table
!=
null
)
{
analyzeTable
(
session
,
table
,
sampleRows
,
true
);
}
else
{
for
(
Abstract
Table
table
:
db
.
getAllTablesAndViews
(
false
))
{
for
(
Table
table
:
db
.
getAllTablesAndViews
(
false
))
{
analyzeTable
(
session
,
table
,
sampleRows
,
true
);
}
}
...
...
@@ -68,8 +68,8 @@ public class Analyze extends DefineCommand {
* @param sample the number of sample rows
* @param manual whether the command was called by the user
*/
public
static
void
analyzeTable
(
Session
session
,
Abstract
Table
table
,
int
sample
,
boolean
manual
)
{
public
static
void
analyzeTable
(
Session
session
,
Table
table
,
int
sample
,
boolean
manual
)
{
if
(
table
.
getTableType
()
!=
TableType
.
TABLE
||
table
.
isHidden
()
||
session
==
null
)
{
return
;
...
...
h2/src/main/org/h2/command/ddl/CreateIndex.java
浏览文件 @
f5d37007
...
...
@@ -14,8 +14,8 @@ import org.h2.engine.Session;
import
org.h2.index.IndexType
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -62,7 +62,7 @@ public class CreateIndex extends SchemaCommand {
}
Database
db
=
session
.
getDatabase
();
boolean
persistent
=
db
.
isPersistent
();
Abstract
Table
table
=
getSchema
().
findTableOrView
(
session
,
tableName
);
Table
table
=
getSchema
().
findTableOrView
(
session
,
tableName
);
if
(
table
==
null
)
{
if
(
ifTableExists
)
{
return
0
;
...
...
h2/src/main/org/h2/command/ddl/CreateLinkedTable.java
浏览文件 @
f5d37007
...
...
@@ -66,7 +66,7 @@ public class CreateLinkedTable extends SchemaCommand {
session
.
commit
(
true
);
Database
db
=
session
.
getDatabase
();
session
.
getUser
().
checkAdmin
();
if
(
getSchema
().
find
TableOrView
(
session
,
tableName
)
!=
null
)
{
if
(
getSchema
().
resolve
TableOrView
(
session
,
tableName
)
!=
null
)
{
if
(
ifNotExists
)
{
return
0
;
}
...
...
h2/src/main/org/h2/command/ddl/CreateSynonym.java
浏览文件 @
f5d37007
...
...
@@ -11,7 +11,6 @@ import org.h2.engine.Database;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.TableSynonym
;
/**
...
...
@@ -52,10 +51,15 @@ public class CreateSynonym extends SchemaCommand {
if
(!
transactional
)
{
session
.
commit
(
true
);
}
session
.
getUser
().
checkAdmin
();
Database
db
=
session
.
getDatabase
();
data
.
session
=
session
;
db
.
lockMeta
(
session
);
if
(
data
.
synonymForSchema
.
findTableOrView
(
session
,
data
.
synonymName
)
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_ALREADY_EXISTS_1
,
data
.
synonymName
);
}
if
(
data
.
synonymForSchema
.
findTableOrView
(
session
,
data
.
synonymFor
)
!=
null
)
{
return
createTableSynonym
(
db
);
}
...
...
@@ -66,11 +70,12 @@ public class CreateSynonym extends SchemaCommand {
}
private
int
createTableSynonym
(
Database
db
)
{
AbstractTable
old
=
getSchema
().
findTableOrView
(
session
,
data
.
synonymName
);
TableSynonym
old
=
getSchema
().
getSynonym
(
data
.
synonymName
);
if
(
old
!=
null
)
{
if
(
orReplace
&&
old
instanceof
TableSynonym
)
{
if
(
orReplace
)
{
// ok, we replacing the existing synonym
}
else
if
(
ifNotExists
&&
old
instanceof
TableSynonym
)
{
}
else
if
(
ifNotExists
)
{
return
0
;
}
else
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_ALREADY_EXISTS_1
,
data
.
synonymName
);
...
...
@@ -79,7 +84,7 @@ public class CreateSynonym extends SchemaCommand {
TableSynonym
table
;
if
(
old
!=
null
)
{
table
=
(
TableSynonym
)
old
;
table
=
old
;
data
.
schema
=
table
.
getSchema
();
table
.
updateData
(
data
);
table
.
setComment
(
comment
);
...
...
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
f5d37007
...
...
@@ -110,7 +110,7 @@ public class CreateTable extends SchemaCommand {
if
(!
isSessionTemporary
)
{
db
.
lockMeta
(
session
);
}
if
(
getSchema
().
find
TableOrView
(
session
,
data
.
tableName
)
!=
null
)
{
if
(
getSchema
().
resolve
TableOrView
(
session
,
data
.
tableName
)
!=
null
)
{
if
(
ifNotExists
)
{
return
0
;
}
...
...
h2/src/main/org/h2/command/ddl/CreateTrigger.java
浏览文件 @
f5d37007
...
...
@@ -13,7 +13,7 @@ import org.h2.engine.Session;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.schema.TriggerObject
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -102,7 +102,7 @@ public class CreateTrigger extends SchemaCommand {
triggerName
);
}
int
id
=
getObjectId
();
Abstract
Table
table
=
getSchema
().
getTableOrView
(
session
,
tableName
);
Table
table
=
getSchema
().
getTableOrView
(
session
,
tableName
);
TriggerObject
trigger
=
new
TriggerObject
(
getSchema
(),
id
,
triggerName
,
table
);
trigger
.
setInsteadOf
(
insteadOf
);
trigger
.
setBefore
(
before
);
...
...
h2/src/main/org/h2/command/ddl/CreateUserDataType.java
浏览文件 @
f5d37007
...
...
@@ -11,8 +11,8 @@ import org.h2.engine.Database;
import
org.h2.engine.Session
;
import
org.h2.engine.UserDataType
;
import
org.h2.message.DbException
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.value.DataType
;
/**
...
...
@@ -62,7 +62,7 @@ public class CreateUserDataType extends DefineCommand {
ErrorCode
.
USER_DATA_TYPE_ALREADY_EXISTS_1
,
typeName
);
}
Abstract
Table
table
=
session
.
getDatabase
().
getFirstUserTable
();
Table
table
=
session
.
getDatabase
().
getFirstUserTable
();
if
(
table
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
USER_DATA_TYPE_ALREADY_EXISTS_1
,
...
...
h2/src/main/org/h2/command/ddl/CreateView.java
浏览文件 @
f5d37007
...
...
@@ -15,8 +15,8 @@ import org.h2.engine.Session;
import
org.h2.expression.Parameter
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.TableType
;
import
org.h2.table.TableView
;
import
org.h2.value.Value
;
...
...
@@ -78,7 +78,7 @@ public class CreateView extends SchemaCommand {
session
.
getUser
().
checkAdmin
();
Database
db
=
session
.
getDatabase
();
TableView
view
=
null
;
Abstract
Table
old
=
getSchema
().
findTableOrView
(
session
,
viewName
);
Table
old
=
getSchema
().
findTableOrView
(
session
,
viewName
);
if
(
old
!=
null
)
{
if
(
ifNotExists
)
{
return
0
;
...
...
h2/src/main/org/h2/command/ddl/DropDatabase.java
浏览文件 @
f5d37007
...
...
@@ -15,7 +15,7 @@ import org.h2.engine.User;
import
org.h2.schema.Schema
;
import
org.h2.schema.SchemaObject
;
import
org.h2.schema.Sequence
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableType
;
import
org.h2.util.New
;
...
...
@@ -53,28 +53,28 @@ public class DropDatabase extends DefineCommand {
// so we might need to loop over them multiple times.
boolean
runLoopAgain
;
do
{
ArrayList
<
Abstract
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
ArrayList
<
Abstract
Table
>
toRemove
=
New
.
arrayList
();
for
(
Abstract
Table
t
:
tables
)
{
ArrayList
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
ArrayList
<
Table
>
toRemove
=
New
.
arrayList
();
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
TableType
.
VIEW
==
t
.
getTableType
())
{
toRemove
.
add
(
t
);
}
}
for
(
Abstract
Table
t
:
tables
)
{
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
TableType
.
TABLE_LINK
==
t
.
getTableType
())
{
toRemove
.
add
(
t
);
}
}
for
(
Abstract
Table
t
:
tables
)
{
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
TableType
.
TABLE
==
t
.
getTableType
()
&&
!
t
.
isHidden
())
{
toRemove
.
add
(
t
);
}
}
for
(
Abstract
Table
t
:
tables
)
{
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
TableType
.
EXTERNAL_TABLE_ENGINE
==
t
.
getTableType
()
&&
!
t
.
isHidden
())
{
...
...
@@ -82,7 +82,7 @@ public class DropDatabase extends DefineCommand {
}
}
runLoopAgain
=
false
;
for
(
Abstract
Table
t
:
toRemove
)
{
for
(
Table
t
:
toRemove
)
{
if
(
t
.
getName
()
==
null
)
{
// ignore, already dead
}
else
if
(
db
.
getDependentTable
(
t
,
t
)
==
null
)
{
...
...
h2/src/main/org/h2/command/ddl/DropSynonym.java
浏览文件 @
f5d37007
...
...
@@ -11,7 +11,8 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Table
;
import
org.h2.table.TableSynonym
;
import
org.h2.table.TableType
;
/**
...
...
@@ -34,17 +35,14 @@ public class DropSynonym extends SchemaCommand {
@Override
public
int
update
()
{
session
.
commit
(
true
);
AbstractTable
synonym
=
getSchema
().
findTableOrView
(
session
,
synonymName
);
session
.
getUser
().
checkAdmin
();
TableSynonym
synonym
=
getSchema
().
getSynonym
(
synonymName
);
if
(
synonym
==
null
)
{
if
(!
ifExists
)
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
synonymName
);
}
}
else
{
if
(!
TableType
.
SYNONYM
.
equals
(
synonym
.
getTableType
()))
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
synonymName
);
}
session
.
getUser
().
checkRight
(
synonym
,
Right
.
ALL
);
synonym
.
lock
(
session
,
true
,
true
);
session
.
getDatabase
().
removeSchemaObject
(
session
,
synonym
);
}
return
0
;
...
...
h2/src/main/org/h2/command/ddl/DropTable.java
浏览文件 @
f5d37007
...
...
@@ -15,7 +15,7 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableView
;
import
org.h2.util.StatementBuilder
;
...
...
@@ -27,7 +27,7 @@ public class DropTable extends SchemaCommand {
private
boolean
ifExists
;
private
String
tableName
;
private
Abstract
Table
table
;
private
Table
table
;
private
DropTable
next
;
private
int
dropAction
;
...
...
h2/src/main/org/h2/command/ddl/DropTrigger.java
浏览文件 @
f5d37007
...
...
@@ -13,7 +13,7 @@ import org.h2.engine.Session;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.schema.TriggerObject
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -46,7 +46,7 @@ public class DropTrigger extends SchemaCommand {
throw
DbException
.
get
(
ErrorCode
.
TRIGGER_NOT_FOUND_1
,
triggerName
);
}
}
else
{
Abstract
Table
table
=
trigger
.
getTable
();
Table
table
=
trigger
.
getTable
();
session
.
getUser
().
checkRight
(
table
,
Right
.
ALL
);
db
.
removeSchemaObject
(
session
,
trigger
);
}
...
...
h2/src/main/org/h2/command/ddl/DropView.java
浏览文件 @
f5d37007
...
...
@@ -13,7 +13,7 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableType
;
import
org.h2.table.TableView
;
...
...
@@ -49,7 +49,7 @@ public class DropView extends SchemaCommand {
@Override
public
int
update
()
{
session
.
commit
(
true
);
Abstract
Table
view
=
getSchema
().
findTableOrView
(
session
,
viewName
);
Table
view
=
getSchema
().
findTableOrView
(
session
,
viewName
);
if
(
view
==
null
)
{
if
(!
ifExists
)
{
throw
DbException
.
get
(
ErrorCode
.
VIEW_NOT_FOUND_1
,
viewName
);
...
...
h2/src/main/org/h2/command/ddl/GrantRevoke.java
浏览文件 @
f5d37007
...
...
@@ -17,7 +17,7 @@ import org.h2.engine.Role;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
/**
...
...
@@ -32,7 +32,7 @@ public class GrantRevoke extends DefineCommand {
private
ArrayList
<
String
>
roleNames
;
private
int
operationType
;
private
int
rightMask
;
private
final
ArrayList
<
Abstract
Table
>
tables
=
New
.
arrayList
();
private
final
ArrayList
<
Table
>
tables
=
New
.
arrayList
();
private
Schema
schema
;
private
RightOwner
grantee
;
...
...
@@ -111,7 +111,7 @@ public class GrantRevoke extends DefineCommand {
if
(
schema
!=
null
)
{
grantRight
(
schema
);
}
for
(
Abstract
Table
table
:
tables
)
{
for
(
Table
table
:
tables
)
{
grantRight
(
table
);
}
}
...
...
@@ -152,7 +152,7 @@ public class GrantRevoke extends DefineCommand {
if
(
schema
!=
null
)
{
revokeRight
(
schema
);
}
for
(
Abstract
Table
table
:
tables
)
{
for
(
Table
table
:
tables
)
{
revokeRight
(
table
);
}
}
...
...
@@ -193,7 +193,7 @@ public class GrantRevoke extends DefineCommand {
*
* @param table the table
*/
public
void
addTable
(
Abstract
Table
table
)
{
public
void
addTable
(
Table
table
)
{
tables
.
add
(
table
);
}
...
...
h2/src/main/org/h2/command/ddl/TruncateTable.java
浏览文件 @
f5d37007
...
...
@@ -10,7 +10,7 @@ import org.h2.command.CommandInterface;
import
org.h2.engine.Right
;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -18,13 +18,13 @@ import org.h2.table.AbstractTable;
*/
public
class
TruncateTable
extends
DefineCommand
{
private
Abstract
Table
table
;
private
Table
table
;
public
TruncateTable
(
Session
session
)
{
super
(
session
);
}
public
void
setTable
(
Abstract
Table
table
)
{
public
void
setTable
(
Table
table
)
{
this
.
table
=
table
;
}
...
...
h2/src/main/org/h2/command/dml/AlterSequence.java
浏览文件 @
f5d37007
...
...
@@ -15,8 +15,8 @@ import org.h2.expression.Expression;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.schema.Sequence
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -25,7 +25,7 @@ import org.h2.table.Column;
public
class
AlterSequence
extends
SchemaCommand
{
private
boolean
ifExists
;
private
Abstract
Table
table
;
private
Table
table
;
private
String
sequenceName
;
private
Sequence
sequence
;
private
Expression
start
;
...
...
h2/src/main/org/h2/command/dml/AlterTableSet.java
浏览文件 @
f5d37007
...
...
@@ -12,7 +12,7 @@ import org.h2.engine.Right;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.schema.Schema
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* This class represents the statement
...
...
@@ -52,7 +52,7 @@ public class AlterTableSet extends SchemaCommand {
@Override
public
int
update
()
{
AbstractTable
table
=
getSchema
().
find
TableOrView
(
session
,
tableName
);
Table
table
=
getSchema
().
resolve
TableOrView
(
session
,
tableName
);
if
(
table
==
null
)
{
if
(
ifTableExists
)
{
return
0
;
...
...
h2/src/main/org/h2/command/dml/Delete.java
浏览文件 @
f5d37007
...
...
@@ -16,8 +16,8 @@ import org.h2.expression.ExpressionVisitor;
import
org.h2.result.ResultInterface
;
import
org.h2.result.Row
;
import
org.h2.result.RowList
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.PlanItem
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
...
...
@@ -53,7 +53,7 @@ public class Delete extends Prepared {
public
int
update
()
{
tableFilter
.
startQuery
(
session
);
tableFilter
.
reset
();
Abstract
Table
table
=
tableFilter
.
getTable
();
Table
table
=
tableFilter
.
getTable
();
session
.
getUser
().
checkRight
(
table
,
Right
.
DELETE
);
table
.
fire
(
session
,
Trigger
.
DELETE
,
true
);
table
.
lock
(
session
,
true
,
false
);
...
...
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
f5d37007
...
...
@@ -26,8 +26,8 @@ import org.h2.mvstore.db.MVPrimaryIndex;
import
org.h2.result.ResultInterface
;
import
org.h2.result.ResultTarget
;
import
org.h2.result.Row
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
import
org.h2.value.Value
;
...
...
@@ -39,7 +39,7 @@ import org.h2.value.ValueNull;
*/
public
class
Insert
extends
Prepared
implements
ResultTarget
{
private
Abstract
Table
table
;
private
Table
table
;
private
Column
[]
columns
;
private
final
ArrayList
<
Expression
[]>
list
=
New
.
arrayList
();
private
Query
query
;
...
...
@@ -64,7 +64,7 @@ public class Insert extends Prepared implements ResultTarget {
}
}
public
void
setTable
(
Abstract
Table
table
)
{
public
void
setTable
(
Table
table
)
{
this
.
table
=
table
;
}
...
...
h2/src/main/org/h2/command/dml/Merge.java
浏览文件 @
f5d37007
...
...
@@ -21,8 +21,8 @@ import org.h2.index.Index;
import
org.h2.message.DbException
;
import
org.h2.result.ResultInterface
;
import
org.h2.result.Row
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
import
org.h2.value.Value
;
...
...
@@ -33,7 +33,7 @@ import org.h2.value.Value;
*/
public
class
Merge
extends
Prepared
{
private
Abstract
Table
table
;
private
Table
table
;
private
Column
[]
columns
;
private
Column
[]
keys
;
private
final
ArrayList
<
Expression
[]>
list
=
New
.
arrayList
();
...
...
@@ -52,7 +52,7 @@ public class Merge extends Prepared {
}
}
public
void
setTable
(
Abstract
Table
table
)
{
public
void
setTable
(
Table
table
)
{
this
.
table
=
table
;
}
...
...
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
f5d37007
...
...
@@ -22,8 +22,8 @@ import org.h2.message.DbException;
import
org.h2.result.ResultInterface
;
import
org.h2.result.ResultTarget
;
import
org.h2.result.SortOrder
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
import
org.h2.value.Value
;
...
...
@@ -157,7 +157,7 @@ public abstract class Query extends Prepared {
*
* @return the set of tables
*/
public
abstract
HashSet
<
Abstract
Table
>
getTables
();
public
abstract
HashSet
<
Table
>
getTables
();
/**
* Set the order by list.
...
...
h2/src/main/org/h2/command/dml/Replace.java
浏览文件 @
f5d37007
...
...
@@ -19,8 +19,8 @@ import org.h2.index.Index;
import
org.h2.message.DbException
;
import
org.h2.result.ResultInterface
;
import
org.h2.result.Row
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
import
org.h2.value.Value
;
...
...
@@ -32,7 +32,7 @@ import java.util.ArrayList;
*/
public
class
Replace
extends
Prepared
{
private
Abstract
Table
table
;
private
Table
table
;
private
Column
[]
columns
;
private
Column
[]
keys
;
private
final
ArrayList
<
Expression
[]>
list
=
New
.
arrayList
();
...
...
@@ -51,7 +51,7 @@ public class Replace extends Prepared {
}
}
public
void
setTable
(
Abstract
Table
table
)
{
public
void
setTable
(
Table
table
)
{
this
.
table
=
table
;
}
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
f5d37007
...
...
@@ -49,7 +49,6 @@ import org.h2.schema.Schema;
import
org.h2.schema.SchemaObject
;
import
org.h2.schema.Sequence
;
import
org.h2.schema.TriggerObject
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.PlanItem
;
import
org.h2.table.Table
;
...
...
@@ -70,7 +69,7 @@ public class ScriptCommand extends ScriptBase {
private
Charset
charset
=
Constants
.
UTF8
;
private
Set
<
String
>
schemaNames
;
private
Collection
<
Abstract
Table
>
tables
;
private
Collection
<
Table
>
tables
;
private
boolean
passwords
;
// true if we're generating the INSERT..VALUES statements for row values
...
...
@@ -103,7 +102,7 @@ public class ScriptCommand extends ScriptBase {
this
.
schemaNames
=
schemaNames
;
}
public
void
setTables
(
Collection
<
Abstract
Table
>
tables
)
{
public
void
setTables
(
Collection
<
Table
>
tables
)
{
this
.
tables
=
tables
;
}
...
...
@@ -202,18 +201,18 @@ public class ScriptCommand extends ScriptBase {
add
(
constant
.
getCreateSQL
(),
false
);
}
final
ArrayList
<
Abstract
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
final
ArrayList
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
// sort by id, so that views are after tables and views on views
// after the base views
Collections
.
sort
(
tables
,
new
Comparator
<
Abstract
Table
>()
{
Collections
.
sort
(
tables
,
new
Comparator
<
Table
>()
{
@Override
public
int
compare
(
AbstractTable
t1
,
Abstract
Table
t2
)
{
public
int
compare
(
Table
t1
,
Table
t2
)
{
return
t1
.
getId
()
-
t2
.
getId
();
}
});
// Generate the DROP XXX ... IF EXISTS
for
(
Abstract
Table
table
:
tables
)
{
for
(
Table
table
:
tables
)
{
if
(
excludeSchema
(
table
.
getSchema
()))
{
continue
;
}
...
...
@@ -263,7 +262,7 @@ public class ScriptCommand extends ScriptBase {
// Generate CREATE TABLE and INSERT...VALUES
int
count
=
0
;
for
(
Abstract
Table
table
:
tables
)
{
for
(
Table
table
:
tables
)
{
if
(
excludeSchema
(
table
.
getSchema
()))
{
continue
;
}
...
...
@@ -389,7 +388,7 @@ public class ScriptCommand extends ScriptBase {
return
r
;
}
private
int
generateInsertValues
(
int
count
,
Abstract
Table
table
)
throws
IOException
{
private
int
generateInsertValues
(
int
count
,
Table
table
)
throws
IOException
{
PlanItem
plan
=
table
.
getBestPlanItem
(
session
,
null
,
null
,
-
1
,
null
,
null
);
Index
index
=
plan
.
getIndex
();
Cursor
cursor
=
index
.
find
(
session
,
null
,
null
);
...
...
@@ -664,7 +663,7 @@ public class ScriptCommand extends ScriptBase {
}
if
(
tables
!=
null
)
{
// if filtering on specific tables, only include those schemas
for
(
Abstract
Table
table
:
schema
.
getAllTablesAndViews
())
{
for
(
Table
table
:
schema
.
getAllTablesAndViews
())
{
if
(
tables
.
contains
(
table
))
{
return
false
;
}
...
...
@@ -674,7 +673,7 @@ public class ScriptCommand extends ScriptBase {
return
false
;
}
private
boolean
excludeTable
(
Abstract
Table
table
)
{
private
boolean
excludeTable
(
Table
table
)
{
return
tables
!=
null
&&
!
tables
.
contains
(
table
);
}
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
f5d37007
...
...
@@ -33,11 +33,11 @@ import org.h2.result.ResultTarget;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.JoinBatch
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.table.TableView
;
import
org.h2.util.New
;
...
...
@@ -710,7 +710,7 @@ public class Select extends Query {
}
private
int
expandColumnList
(
TableFilter
filter
,
int
index
)
{
Abstract
Table
t
=
filter
.
getTable
();
Table
t
=
filter
.
getTable
();
String
alias
=
filter
.
getTableAlias
();
Column
[]
columns
=
t
.
getColumns
();
for
(
Column
c
:
columns
)
{
...
...
@@ -856,7 +856,7 @@ public class Select extends Query {
if
(
isGroupQuery
&&
groupIndex
==
null
&&
havingIndex
<
0
&&
filters
.
size
()
==
1
)
{
if
(
condition
==
null
)
{
Abstract
Table
t
=
filters
.
get
(
0
).
getTable
();
Table
t
=
filters
.
get
(
0
).
getTable
();
ExpressionVisitor
optimizable
=
ExpressionVisitor
.
getOptimizableVisitor
(
t
);
isQuickAggregateQuery
=
isEverything
(
optimizable
);
...
...
@@ -975,8 +975,8 @@ public class Select extends Query {
}
@Override
public
HashSet
<
Abstract
Table
>
getTables
()
{
HashSet
<
Abstract
Table
>
set
=
New
.
hashSet
();
public
HashSet
<
Table
>
getTables
()
{
HashSet
<
Table
>
set
=
New
.
hashSet
();
for
(
TableFilter
filter
:
filters
)
{
set
.
add
(
filter
.
getTable
());
}
...
...
@@ -1072,7 +1072,7 @@ public class Select extends Query {
new
Expression
[
expressions
.
size
()]);
StatementBuilder
buff
=
new
StatementBuilder
();
for
(
TableFilter
f
:
topFilters
)
{
Abstract
Table
t
=
f
.
getTable
();
Table
t
=
f
.
getTable
();
if
(
t
.
isView
()
&&
((
TableView
)
t
).
isRecursive
())
{
buff
.
append
(
"WITH RECURSIVE "
).
append
(
t
.
getName
()).
append
(
'('
);
buff
.
resetCount
();
...
...
@@ -1344,7 +1344,7 @@ public class Select extends Query {
case
ExpressionVisitor
.
GET_DEPENDENCIES
:
{
for
(
int
i
=
0
,
size
=
filters
.
size
();
i
<
size
;
i
++)
{
TableFilter
f
=
filters
.
get
(
i
);
Abstract
Table
table
=
f
.
getTable
();
Table
table
=
f
.
getTable
();
visitor
.
addDependency
(
table
);
table
.
addDependencies
(
visitor
.
getDependencies
());
}
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
f5d37007
...
...
@@ -22,9 +22,9 @@ import org.h2.result.LocalResult;
import
org.h2.result.ResultInterface
;
import
org.h2.result.ResultTarget
;
import
org.h2.result.SortOrder
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
import
org.h2.util.StringUtils
;
...
...
@@ -355,8 +355,8 @@ public class SelectUnion extends Query {
}
@Override
public
HashSet
<
Abstract
Table
>
getTables
()
{
HashSet
<
Abstract
Table
>
set
=
left
.
getTables
();
public
HashSet
<
Table
>
getTables
()
{
HashSet
<
Table
>
set
=
left
.
getTables
();
set
.
addAll
(
right
.
getTables
());
return
set
;
}
...
...
h2/src/main/org/h2/command/dml/Set.java
浏览文件 @
f5d37007
...
...
@@ -21,7 +21,7 @@ import org.h2.message.DbException;
import
org.h2.result.ResultInterface
;
import
org.h2.result.RowFactory
;
import
org.h2.schema.Schema
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.tools.CompressTool
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.StringUtils
;
...
...
@@ -145,7 +145,7 @@ public class Set extends Prepared {
if
(
old
.
equals
(
compareMode
))
{
break
;
}
Abstract
Table
table
=
database
.
getFirstUserTable
();
Table
table
=
database
.
getFirstUserTable
();
if
(
table
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
COLLATION_CHANGE_WITH_DATA_TABLE_1
,
...
...
@@ -157,7 +157,7 @@ public class Set extends Prepared {
}
case
SetTypes
.
BINARY_COLLATION
:
{
session
.
getUser
().
checkAdmin
();
Abstract
Table
table
=
database
.
getFirstUserTable
();
Table
table
=
database
.
getFirstUserTable
();
if
(
table
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
COLLATION_CHANGE_WITH_DATA_TABLE_1
,
...
...
@@ -249,7 +249,7 @@ public class Set extends Prepared {
}
case
SetTypes
.
JAVA_OBJECT_SERIALIZER
:
{
session
.
getUser
().
checkAdmin
();
Abstract
Table
table
=
database
.
getFirstUserTable
();
Table
table
=
database
.
getFirstUserTable
();
if
(
table
!=
null
)
{
throw
DbException
.
get
(
ErrorCode
.
JAVA_OBJECT_SERIALIZER_CHANGE_WITH_DATA_TABLE
,
...
...
h2/src/main/org/h2/command/dml/Update.java
浏览文件 @
f5d37007
...
...
@@ -21,9 +21,9 @@ import org.h2.message.DbException;
import
org.h2.result.ResultInterface
;
import
org.h2.result.Row
;
import
org.h2.result.RowList
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.PlanItem
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
...
...
@@ -83,7 +83,7 @@ public class Update extends Prepared {
tableFilter
.
reset
();
RowList
rows
=
new
RowList
(
session
);
try
{
Abstract
Table
table
=
tableFilter
.
getTable
();
Table
table
=
tableFilter
.
getTable
();
session
.
getUser
().
checkRight
(
table
,
Right
.
UPDATE
);
table
.
fire
(
session
,
Trigger
.
UPDATE
,
true
);
table
.
lock
(
session
,
true
,
false
);
...
...
h2/src/main/org/h2/constraint/Constraint.java
浏览文件 @
f5d37007
...
...
@@ -15,8 +15,8 @@ import org.h2.message.Trace;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.schema.SchemaObjectBase
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
/**
* The base class for constraint checking.
...
...
@@ -47,9 +47,9 @@ public abstract class Constraint extends SchemaObjectBase implements
/**
* The table for which this constraint is defined.
*/
protected
Abstract
Table
table
;
protected
Table
table
;
Constraint
(
Schema
schema
,
int
id
,
String
name
,
Abstract
Table
table
)
{
Constraint
(
Schema
schema
,
int
id
,
String
name
,
Table
table
)
{
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
CONSTRAINT
);
this
.
table
=
table
;
this
.
setTemporary
(
table
.
isTemporary
());
...
...
@@ -71,7 +71,7 @@ public abstract class Constraint extends SchemaObjectBase implements
* @param oldRow the old row
* @param newRow the new row
*/
public
abstract
void
checkRow
(
Session
session
,
Abstract
Table
t
,
Row
oldRow
,
Row
newRow
);
public
abstract
void
checkRow
(
Session
session
,
Table
t
,
Row
oldRow
,
Row
newRow
);
/**
* Check if this constraint needs the specified index.
...
...
@@ -94,7 +94,7 @@ public abstract class Constraint extends SchemaObjectBase implements
* @param table the table
* @return the set of referenced columns
*/
public
abstract
HashSet
<
Column
>
getReferencedColumns
(
Abstract
Table
table
);
public
abstract
HashSet
<
Column
>
getReferencedColumns
(
Table
table
);
/**
* Get the SQL statement to create this constraint.
...
...
@@ -142,11 +142,11 @@ public abstract class Constraint extends SchemaObjectBase implements
return
DbObject
.
CONSTRAINT
;
}
public
Abstract
Table
getTable
()
{
public
Table
getTable
()
{
return
table
;
}
public
Abstract
Table
getRefTable
()
{
public
Table
getRefTable
()
{
return
table
;
}
...
...
h2/src/main/org/h2/constraint/ConstraintCheck.java
浏览文件 @
f5d37007
...
...
@@ -16,8 +16,8 @@ import org.h2.message.DbException;
import
org.h2.result.ResultInterface
;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
import
org.h2.util.StringUtils
;
...
...
@@ -30,7 +30,7 @@ public class ConstraintCheck extends Constraint {
private
TableFilter
filter
;
private
Expression
expr
;
public
ConstraintCheck
(
Schema
schema
,
int
id
,
String
name
,
Abstract
Table
table
)
{
public
ConstraintCheck
(
Schema
schema
,
int
id
,
String
name
,
Table
table
)
{
super
(
schema
,
id
,
name
,
table
);
}
...
...
@@ -48,7 +48,7 @@ public class ConstraintCheck extends Constraint {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
forTable
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
forTable
,
String
quotedName
)
{
StringBuilder
buff
=
new
StringBuilder
(
"ALTER TABLE "
);
buff
.
append
(
forTable
.
getSQL
()).
append
(
" ADD CONSTRAINT "
);
if
(
forTable
.
isHidden
())
{
...
...
@@ -88,7 +88,7 @@ public class ConstraintCheck extends Constraint {
}
@Override
public
void
checkRow
(
Session
session
,
Abstract
Table
t
,
Row
oldRow
,
Row
newRow
)
{
public
void
checkRow
(
Session
session
,
Table
t
,
Row
oldRow
,
Row
newRow
)
{
if
(
newRow
==
null
)
{
return
;
}
...
...
@@ -118,7 +118,7 @@ public class ConstraintCheck extends Constraint {
}
@Override
public
HashSet
<
Column
>
getReferencedColumns
(
Abstract
Table
table
)
{
public
HashSet
<
Column
>
getReferencedColumns
(
Table
table
)
{
HashSet
<
Column
>
columns
=
New
.
hashSet
();
expr
.
isEverything
(
ExpressionVisitor
.
getColumnsVisitor
(
columns
));
for
(
Iterator
<
Column
>
it
=
columns
.
iterator
();
it
.
hasNext
();)
{
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
f5d37007
...
...
@@ -20,7 +20,6 @@ import org.h2.result.ResultInterface;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.Table
;
...
...
@@ -59,7 +58,7 @@ public class ConstraintReferential extends Constraint {
private
IndexColumn
[]
refColumns
;
private
int
deleteAction
;
private
int
updateAction
;
private
Abstract
Table
refTable
;
private
Table
refTable
;
private
Index
index
;
private
Index
refIndex
;
private
boolean
indexOwner
;
...
...
@@ -67,7 +66,7 @@ public class ConstraintReferential extends Constraint {
private
String
deleteSQL
,
updateSQL
;
private
boolean
skipOwnTable
;
public
ConstraintReferential
(
Schema
schema
,
int
id
,
String
name
,
Abstract
Table
table
)
{
public
ConstraintReferential
(
Schema
schema
,
int
id
,
String
name
,
Table
table
)
{
super
(
schema
,
id
,
name
,
table
);
}
...
...
@@ -101,7 +100,7 @@ public class ConstraintReferential extends Constraint {
* @return the SQL statement
*/
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
forTable
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
forTable
,
String
quotedName
)
{
return
getCreateSQLForCopy
(
forTable
,
refTable
,
quotedName
,
true
);
}
...
...
@@ -115,7 +114,7 @@ public class ConstraintReferential extends Constraint {
* @param internalIndex add the index name to the statement
* @return the SQL statement
*/
public
String
getCreateSQLForCopy
(
AbstractTable
forTable
,
Abstract
Table
forRefTable
,
public
String
getCreateSQLForCopy
(
Table
forTable
,
Table
forRefTable
,
String
quotedName
,
boolean
internalIndex
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
"ALTER TABLE "
);
String
mainTable
=
forTable
.
getSQL
();
...
...
@@ -225,7 +224,7 @@ public class ConstraintReferential extends Constraint {
}
@Override
public
HashSet
<
Column
>
getReferencedColumns
(
Abstract
Table
table
)
{
public
HashSet
<
Column
>
getReferencedColumns
(
Table
table
)
{
HashSet
<
Column
>
result
=
New
.
hashSet
();
if
(
table
==
this
.
table
)
{
for
(
IndexColumn
c
:
columns
)
{
...
...
@@ -247,7 +246,7 @@ public class ConstraintReferential extends Constraint {
return
refColumns
;
}
public
void
setRefTable
(
Abstract
Table
refTable
)
{
public
void
setRefTable
(
Table
refTable
)
{
this
.
refTable
=
refTable
;
if
(
refTable
.
isTemporary
())
{
setTemporary
(
true
);
...
...
@@ -301,7 +300,7 @@ public class ConstraintReferential extends Constraint {
}
@Override
public
void
checkRow
(
Session
session
,
Abstract
Table
t
,
Row
oldRow
,
Row
newRow
)
{
public
void
checkRow
(
Session
session
,
Table
t
,
Row
oldRow
,
Row
newRow
)
{
if
(!
database
.
getReferentialIntegrity
())
{
return
;
}
...
...
@@ -610,7 +609,7 @@ public class ConstraintReferential extends Constraint {
}
@Override
public
Abstract
Table
getRefTable
()
{
public
Table
getRefTable
()
{
return
refTable
;
}
...
...
h2/src/main/org/h2/constraint/ConstraintUnique.java
浏览文件 @
f5d37007
...
...
@@ -11,9 +11,9 @@ import org.h2.engine.Session;
import
org.h2.index.Index
;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
...
...
@@ -28,7 +28,7 @@ public class ConstraintUnique extends Constraint {
private
IndexColumn
[]
columns
;
private
final
boolean
primaryKey
;
public
ConstraintUnique
(
Schema
schema
,
int
id
,
String
name
,
Abstract
Table
table
,
public
ConstraintUnique
(
Schema
schema
,
int
id
,
String
name
,
Table
table
,
boolean
primaryKey
)
{
super
(
schema
,
id
,
name
,
table
);
this
.
primaryKey
=
primaryKey
;
...
...
@@ -40,11 +40,11 @@ public class ConstraintUnique extends Constraint {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
forTable
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
forTable
,
String
quotedName
)
{
return
getCreateSQLForCopy
(
forTable
,
quotedName
,
true
);
}
private
String
getCreateSQLForCopy
(
Abstract
Table
forTable
,
String
quotedName
,
private
String
getCreateSQLForCopy
(
Table
forTable
,
String
quotedName
,
boolean
internalIndex
)
{
StatementBuilder
buff
=
new
StatementBuilder
(
"ALTER TABLE "
);
buff
.
append
(
forTable
.
getSQL
()).
append
(
" ADD CONSTRAINT "
);
...
...
@@ -118,7 +118,7 @@ public class ConstraintUnique extends Constraint {
}
@Override
public
void
checkRow
(
Session
session
,
Abstract
Table
t
,
Row
oldRow
,
Row
newRow
)
{
public
void
checkRow
(
Session
session
,
Table
t
,
Row
oldRow
,
Row
newRow
)
{
// unique index check is enough
}
...
...
@@ -133,7 +133,7 @@ public class ConstraintUnique extends Constraint {
}
@Override
public
HashSet
<
Column
>
getReferencedColumns
(
Abstract
Table
table
)
{
public
HashSet
<
Column
>
getReferencedColumns
(
Table
table
)
{
HashSet
<
Column
>
result
=
New
.
hashSet
();
for
(
IndexColumn
c
:
columns
)
{
result
.
add
(
c
.
column
);
...
...
h2/src/main/org/h2/engine/Comment.java
浏览文件 @
f5d37007
...
...
@@ -7,7 +7,7 @@ package org.h2.engine;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.util.StringUtils
;
/**
...
...
@@ -26,7 +26,7 @@ public class Comment extends DbObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
f5d37007
...
...
@@ -50,12 +50,12 @@ import org.h2.store.LobStorageMap;
import
org.h2.store.PageStore
;
import
org.h2.store.WriterThread
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.MetaTable
;
import
org.h2.table.Table
;
import
org.h2.table.TableLinkConnection
;
import
org.h2.table.TableSynonym
;
import
org.h2.table.TableType
;
import
org.h2.table.TableView
;
import
org.h2.tools.DeleteDbFiles
;
...
...
@@ -834,7 +834,7 @@ public class Database implements DataHandler {
boolean
atLeastOneRecompiledSuccessfully
;
do
{
atLeastOneRecompiledSuccessfully
=
false
;
for
(
Abstract
Table
obj
:
getAllTablesAndViews
(
false
))
{
for
(
Table
obj
:
getAllTablesAndViews
(
false
))
{
if
(
obj
instanceof
TableView
)
{
TableView
view
=
(
TableView
)
obj
;
if
(
view
.
isInvalid
())
{
...
...
@@ -1264,7 +1264,7 @@ public class Database implements DataHandler {
try
{
if
(
systemSession
!=
null
)
{
if
(
powerOffCount
!=
-
1
)
{
for
(
Abstract
Table
table
:
getAllTablesAndViews
(
false
))
{
for
(
Table
table
:
getAllTablesAndViews
(
false
))
{
if
(
table
.
isGlobalTemporary
())
{
table
.
removeChildrenAndResources
(
systemSession
);
}
else
{
...
...
@@ -1532,27 +1532,40 @@ public class Database implements DataHandler {
* tables are only included if they are already initialized)
* @return all objects of that type
*/
public
ArrayList
<
Abstract
Table
>
getAllTablesAndViews
(
boolean
includeMeta
)
{
public
ArrayList
<
Table
>
getAllTablesAndViews
(
boolean
includeMeta
)
{
if
(
includeMeta
)
{
initMetaTables
();
}
ArrayList
<
Abstract
Table
>
list
=
New
.
arrayList
();
ArrayList
<
Table
>
list
=
New
.
arrayList
();
for
(
Schema
schema
:
schemas
.
values
())
{
list
.
addAll
(
schema
.
getAllTablesAndViews
());
}
return
list
;
}
/**
* Get all synonyms.
*
* @return all objects of that type
*/
public
ArrayList
<
TableSynonym
>
getAllSynonyms
()
{
ArrayList
<
TableSynonym
>
list
=
New
.
arrayList
();
for
(
Schema
schema
:
schemas
.
values
())
{
list
.
addAll
(
schema
.
getAllSynonyms
());
}
return
list
;
}
/**
* Get the tables with the given name, if any.
*
* @param name the table name
* @return the list
*/
public
ArrayList
<
Abstract
Table
>
getTableOrViewByName
(
String
name
)
{
ArrayList
<
Abstract
Table
>
list
=
New
.
arrayList
();
public
ArrayList
<
Table
>
getTableOrViewByName
(
String
name
)
{
ArrayList
<
Table
>
list
=
New
.
arrayList
();
for
(
Schema
schema
:
schemas
.
values
())
{
Abstract
Table
table
=
schema
.
getTableOrViewByName
(
name
);
Table
table
=
schema
.
getTableOrViewByName
(
name
);
if
(
table
!=
null
)
{
list
.
add
(
table
);
}
...
...
@@ -1791,7 +1804,7 @@ public class Database implements DataHandler {
* @param except the table to exclude (or null)
* @return the first dependent table, or null
*/
public
AbstractTable
getDependentTable
(
SchemaObject
obj
,
Abstract
Table
except
)
{
public
Table
getDependentTable
(
SchemaObject
obj
,
Table
except
)
{
switch
(
obj
.
getType
())
{
case
DbObject
.
COMMENT
:
case
DbObject
.
CONSTRAINT
:
...
...
@@ -1803,7 +1816,7 @@ public class Database implements DataHandler {
default
:
}
HashSet
<
DbObject
>
set
=
New
.
hashSet
();
for
(
Abstract
Table
t
:
getAllTablesAndViews
(
false
))
{
for
(
Table
t
:
getAllTablesAndViews
(
false
))
{
if
(
except
==
t
)
{
continue
;
}
else
if
(
TableType
.
VIEW
==
t
.
getTableType
())
{
...
...
@@ -1828,7 +1841,7 @@ public class Database implements DataHandler {
SchemaObject
obj
)
{
int
type
=
obj
.
getType
();
if
(
type
==
DbObject
.
TABLE_OR_VIEW
)
{
AbstractTable
table
=
(
Abstract
Table
)
obj
;
Table
table
=
(
Table
)
obj
;
if
(
table
.
isTemporary
()
&&
!
table
.
isGlobalTemporary
())
{
session
.
removeLocalTempTable
(
table
);
return
;
...
...
@@ -1842,7 +1855,7 @@ public class Database implements DataHandler {
}
}
else
if
(
type
==
DbObject
.
CONSTRAINT
)
{
Constraint
constraint
=
(
Constraint
)
obj
;
Abstract
Table
table
=
constraint
.
getTable
();
Table
table
=
constraint
.
getTable
();
if
(
table
.
isTemporary
()
&&
!
table
.
isGlobalTemporary
())
{
session
.
removeLocalTempTableConstraint
(
constraint
);
return
;
...
...
@@ -1858,7 +1871,7 @@ public class Database implements DataHandler {
obj
.
getSchema
().
remove
(
obj
);
int
id
=
obj
.
getId
();
if
(!
starting
)
{
Abstract
Table
t
=
getDependentTable
(
obj
,
null
);
Table
t
=
getDependentTable
(
obj
,
null
);
if
(
t
!=
null
)
{
obj
.
getSchema
().
add
(
obj
);
throw
DbException
.
get
(
ErrorCode
.
CANNOT_DROP_2
,
obj
.
getSQL
(),
...
...
@@ -2499,8 +2512,8 @@ public class Database implements DataHandler {
*
* @return the table or null if no table is defined
*/
public
Abstract
Table
getFirstUserTable
()
{
for
(
Abstract
Table
table
:
getAllTablesAndViews
(
false
))
{
public
Table
getFirstUserTable
()
{
for
(
Table
table
:
getAllTablesAndViews
(
false
))
{
if
(
table
.
getCreateSQL
()
!=
null
)
{
if
(
table
.
isHidden
())
{
// LOB tables
...
...
h2/src/main/org/h2/engine/DbObject.java
浏览文件 @
f5d37007
...
...
@@ -6,8 +6,7 @@
package
org
.
h2
.
engine
;
import
java.util.ArrayList
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Table
;
/**
* A database object such as a table, an index, or a user.
...
...
@@ -90,6 +89,11 @@ public interface DbObject {
*/
int
AGGREGATE
=
14
;
/**
* This object is a synonym.
*/
int
SYNONYM
=
15
;
/**
* Get the SQL name of this object (may be quoted).
*
...
...
@@ -134,7 +138,7 @@ public interface DbObject {
* @param quotedName the quoted name
* @return the SQL statement
*/
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
);
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
);
/**
* Construct the original CREATE ... SQL statement for this object.
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
f5d37007
...
...
@@ -20,7 +20,7 @@ import org.h2.message.DbException;
import
org.h2.message.Trace
;
import
org.h2.schema.Schema
;
import
org.h2.schema.SchemaObjectBase
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.New
;
import
org.h2.util.SourceCompiler
;
...
...
@@ -194,7 +194,7 @@ public class FunctionAlias extends SchemaObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/engine/MetaRecord.java
浏览文件 @
f5d37007
...
...
@@ -127,14 +127,16 @@ public class MetaRecord implements Comparable<MetaRecord> {
return
9
;
case
DbObject
.
TRIGGER
:
return
10
;
case
DbObject
.
ROLE
:
case
DbObject
.
SYNONYM
:
return
11
;
case
DbObject
.
R
IGHT
:
case
DbObject
.
R
OLE
:
return
12
;
case
DbObject
.
AGGREGATE
:
case
DbObject
.
RIGHT
:
return
13
;
case
DbObject
.
COMMENT
:
case
DbObject
.
AGGREGATE
:
return
14
;
case
DbObject
.
COMMENT
:
return
15
;
default
:
throw
DbException
.
throwInternalError
(
"type="
+
objectType
);
}
...
...
h2/src/main/org/h2/engine/Right.java
浏览文件 @
f5d37007
...
...
@@ -8,7 +8,6 @@ package org.h2.engine;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Table
;
/**
...
...
@@ -128,7 +127,7 @@ public class Right extends DbObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
return
getCreateSQLForCopy
(
table
);
}
...
...
h2/src/main/org/h2/engine/RightOwner.java
浏览文件 @
f5d37007
...
...
@@ -7,7 +7,7 @@ package org.h2.engine;
import
java.util.HashMap
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
/**
...
...
@@ -63,7 +63,7 @@ public abstract class RightOwner extends DbObjectBase {
* @param rightMask the right mask to check
* @return true if the right was already granted
*/
boolean
isRightGrantedRecursive
(
Abstract
Table
table
,
int
rightMask
)
{
boolean
isRightGrantedRecursive
(
Table
table
,
int
rightMask
)
{
Right
right
;
if
(
grantedRights
!=
null
)
{
if
(
table
!=
null
)
{
...
...
h2/src/main/org/h2/engine/Role.java
浏览文件 @
f5d37007
...
...
@@ -7,7 +7,7 @@ package org.h2.engine;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* Represents a role. Roles can be granted to users, and to other roles.
...
...
@@ -22,7 +22,7 @@ public class Role extends RightOwner {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
f5d37007
...
...
@@ -38,7 +38,6 @@ import org.h2.schema.Schema;
import
org.h2.store.DataHandler
;
import
org.h2.store.InDoubtTransaction
;
import
org.h2.store.LobStorageFrontend
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.SubQueryInfo
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
...
...
@@ -373,7 +372,7 @@ public class Session extends SessionWithState {
*
* @param table the table
*/
public
void
removeLocalTempTable
(
Abstract
Table
table
)
{
public
void
removeLocalTempTable
(
Table
table
)
{
modificationId
++;
localTempTables
.
remove
(
table
.
getName
());
synchronized
(
database
)
{
...
...
@@ -878,7 +877,7 @@ public class Session extends SessionWithState {
* @param operation the operation type (see {@link UndoLogRecord})
* @param row the row
*/
public
void
log
(
Abstract
Table
table
,
short
operation
,
Row
row
)
{
public
void
log
(
Table
table
,
short
operation
,
Row
row
)
{
if
(
table
.
isMVStore
())
{
return
;
}
...
...
h2/src/main/org/h2/engine/Setting.java
浏览文件 @
f5d37007
...
...
@@ -7,7 +7,7 @@ package org.h2.engine;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* A persistent database setting.
...
...
@@ -38,7 +38,7 @@ public class Setting extends DbObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/engine/UndoLog.java
浏览文件 @
f5d37007
...
...
@@ -10,7 +10,7 @@ import java.util.HashMap;
import
org.h2.message.DbException
;
import
org.h2.store.Data
;
import
org.h2.store.FileStore
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
/**
...
...
@@ -25,7 +25,7 @@ public class UndoLog {
private
Data
rowBuff
;
private
int
memoryUndo
;
private
int
storedEntries
;
private
HashMap
<
Integer
,
Abstract
Table
>
tables
;
private
HashMap
<
Integer
,
Table
>
tables
;
private
final
boolean
largeTransactions
;
/**
...
...
@@ -220,7 +220,7 @@ public class UndoLog {
* @param table the table
* @return the id
*/
int
getTableId
(
Abstract
Table
table
)
{
int
getTableId
(
Table
table
)
{
int
id
=
table
.
getId
();
if
(
tables
==
null
)
{
tables
=
New
.
hashMap
();
...
...
@@ -238,7 +238,7 @@ public class UndoLog {
* @param id the table id
* @return the table object
*/
Abstract
Table
getTable
(
int
id
)
{
Table
getTable
(
int
id
)
{
return
tables
.
get
(
id
);
}
...
...
h2/src/main/org/h2/engine/UndoLogRecord.java
浏览文件 @
f5d37007
...
...
@@ -10,7 +10,7 @@ import org.h2.message.DbException;
import
org.h2.result.Row
;
import
org.h2.store.Data
;
import
org.h2.store.FileStore
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.value.Value
;
/**
...
...
@@ -29,7 +29,7 @@ public class UndoLogRecord {
public
static
final
short
DELETE
=
1
;
private
static
final
int
IN_MEMORY
=
0
,
STORED
=
1
,
IN_MEMORY_INVALID
=
2
;
private
Abstract
Table
table
;
private
Table
table
;
private
Row
row
;
private
short
operation
;
private
short
state
;
...
...
@@ -42,7 +42,7 @@ public class UndoLogRecord {
* @param op the operation type
* @param row the row that was deleted or inserted
*/
UndoLogRecord
(
Abstract
Table
table
,
short
op
,
Row
row
)
{
UndoLogRecord
(
Table
table
,
short
op
,
Row
row
)
{
this
.
table
=
table
;
this
.
row
=
row
;
this
.
operation
=
op
;
...
...
@@ -233,7 +233,7 @@ public class UndoLogRecord {
*
* @return the table
*/
public
Abstract
Table
getTable
()
{
public
Table
getTable
()
{
return
table
;
}
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
f5d37007
...
...
@@ -12,9 +12,9 @@ import org.h2.message.DbException;
import
org.h2.message.Trace
;
import
org.h2.schema.Schema
;
import
org.h2.security.SHA256
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.MetaTable
;
import
org.h2.table.RangeTable
;
import
org.h2.table.Table
;
import
org.h2.table.TableType
;
import
org.h2.table.TableView
;
import
org.h2.util.MathUtils
;
...
...
@@ -75,7 +75,7 @@ public class User extends RightOwner {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
@@ -96,7 +96,7 @@ public class User extends RightOwner {
* @param rightMask the rights required
* @throws DbException if this user does not have the required rights
*/
public
void
checkRight
(
Abstract
Table
table
,
int
rightMask
)
{
public
void
checkRight
(
Table
table
,
int
rightMask
)
{
if
(!
hasRight
(
table
,
rightMask
))
{
throw
DbException
.
get
(
ErrorCode
.
NOT_ENOUGH_RIGHTS_FOR_1
,
table
.
getSQL
());
}
...
...
@@ -109,7 +109,7 @@ public class User extends RightOwner {
* @param rightMask the rights required
* @return true if the user has the rights
*/
public
boolean
hasRight
(
Abstract
Table
table
,
int
rightMask
)
{
public
boolean
hasRight
(
Table
table
,
int
rightMask
)
{
if
(
rightMask
!=
Right
.
SELECT
&&
!
systemUser
&&
table
!=
null
)
{
table
.
checkWritingAllowed
();
}
...
...
h2/src/main/org/h2/engine/UserAggregate.java
浏览文件 @
f5d37007
...
...
@@ -12,7 +12,7 @@ import org.h2.api.AggregateFunction;
import
org.h2.command.Parser
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.util.JdbcUtils
;
import
org.h2.value.DataType
;
...
...
@@ -53,7 +53,7 @@ public class UserAggregate extends DbObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/engine/UserDataType.java
浏览文件 @
f5d37007
...
...
@@ -7,8 +7,8 @@ package org.h2.engine;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.Table
;
/**
* Represents a domain (user-defined data type).
...
...
@@ -22,7 +22,7 @@ public class UserDataType extends DbObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
f5d37007
...
...
@@ -18,9 +18,9 @@ import org.h2.index.Index;
import
org.h2.message.DbException
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
...
...
@@ -281,7 +281,7 @@ public class Aggregate extends Expression {
switch
(
type
)
{
case
COUNT:
case
COUNT_ALL:
Abstract
Table
table
=
select
.
getTopTableFilter
().
getTable
();
Table
table
=
select
.
getTopTableFilter
().
getTable
();
return
ValueLong
.
get
(
table
.
getRowCount
(
session
));
case
MIN:
case
MAX:
...
...
@@ -580,7 +580,7 @@ public class Aggregate extends Expression {
Column
column
=
col
.
getColumn
();
TableFilter
filter
=
col
.
getTableFilter
();
if
(
filter
!=
null
)
{
Abstract
Table
table
=
filter
.
getTable
();
Table
table
=
filter
.
getTable
();
Index
index
=
table
.
getIndexForColumn
(
column
,
true
,
false
);
return
index
;
}
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
f5d37007
...
...
@@ -16,9 +16,9 @@ import org.h2.index.IndexCondition;
import
org.h2.message.DbException
;
import
org.h2.schema.Constant
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.value.Value
;
import
org.h2.value.ValueBoolean
;
...
...
@@ -240,13 +240,13 @@ public class ExpressionColumn extends Expression {
@Override
public
String
getSchemaName
()
{
Abstract
Table
table
=
column
.
getTable
();
Table
table
=
column
.
getTable
();
return
table
==
null
?
null
:
table
.
getSchema
().
getName
();
}
@Override
public
String
getTableName
()
{
Abstract
Table
table
=
column
.
getTable
();
Table
table
=
column
.
getTable
();
return
table
==
null
?
null
:
table
.
getName
();
}
...
...
h2/src/main/org/h2/expression/ExpressionVisitor.java
浏览文件 @
f5d37007
...
...
@@ -7,9 +7,9 @@ package org.h2.expression;
import
java.util.HashSet
;
import
org.h2.engine.DbObject
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
...
...
@@ -111,14 +111,14 @@ public class ExpressionVisitor {
private
final
int
queryLevel
;
private
final
HashSet
<
DbObject
>
dependencies
;
private
final
HashSet
<
Column
>
columns
;
private
final
Abstract
Table
table
;
private
final
Table
table
;
private
final
long
[]
maxDataModificationId
;
private
final
ColumnResolver
resolver
;
private
ExpressionVisitor
(
int
type
,
int
queryLevel
,
HashSet
<
DbObject
>
dependencies
,
HashSet
<
Column
>
columns
,
Abstract
Table
table
,
ColumnResolver
resolver
,
HashSet
<
Column
>
columns
,
Table
table
,
ColumnResolver
resolver
,
long
[]
maxDataModificationId
)
{
this
.
type
=
type
;
this
.
queryLevel
=
queryLevel
;
...
...
@@ -157,7 +157,7 @@ public class ExpressionVisitor {
* @param table the table
* @return the new visitor
*/
public
static
ExpressionVisitor
getOptimizableVisitor
(
Abstract
Table
table
)
{
public
static
ExpressionVisitor
getOptimizableVisitor
(
Table
table
)
{
return
new
ExpressionVisitor
(
OPTIMIZABLE_MIN_MAX_COUNT_ALL
,
0
,
null
,
null
,
table
,
null
,
null
);
}
...
...
@@ -274,7 +274,7 @@ public class ExpressionVisitor {
*
* @return the table
*/
public
Abstract
Table
getTable
()
{
public
Table
getTable
()
{
return
table
;
}
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
f5d37007
...
...
@@ -37,10 +37,10 @@ import org.h2.security.BlockCipher;
import
org.h2.security.CipherFactory
;
import
org.h2.security.SHA256
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.ColumnResolver
;
import
org.h2.table.LinkSchema
;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.tools.CompressTool
;
import
org.h2.tools.Csv
;
...
...
@@ -1160,7 +1160,7 @@ public class Function extends Expression implements FunctionCall {
private
static
long
getDiskSpaceUsed
(
Session
session
,
Value
v0
)
{
Parser
p
=
new
Parser
(
session
);
String
sql
=
v0
.
getString
();
Abstract
Table
table
=
p
.
parseTableName
(
sql
);
Table
table
=
p
.
parseTableName
(
sql
);
return
table
.
getDiskSpaceUsed
();
}
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
f5d37007
...
...
@@ -17,7 +17,6 @@ import org.h2.result.Row;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
import
org.h2.schema.SchemaObjectBase
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.Table
;
...
...
@@ -397,7 +396,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
targetTable
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
targetTable
,
String
quotedName
)
{
StringBuilder
buff
=
new
StringBuilder
(
"CREATE "
);
buff
.
append
(
indexType
.
getSQL
());
buff
.
append
(
' '
);
...
...
h2/src/main/org/h2/index/MultiVersionIndex.java
浏览文件 @
f5d37007
...
...
@@ -16,7 +16,6 @@ import org.h2.result.Row;
import
org.h2.result.SearchRow
;
import
org.h2.result.SortOrder
;
import
org.h2.schema.Schema
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.RegularTable
;
...
...
@@ -252,7 +251,7 @@ public class MultiVersionIndex implements Index {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
forTable
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
forTable
,
String
quotedName
)
{
return
base
.
getCreateSQLForCopy
(
forTable
,
quotedName
);
}
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
f5d37007
...
...
@@ -12,6 +12,7 @@ import java.sql.ResultSet;
import
java.sql.RowIdLifetime
;
import
java.sql.SQLException
;
import
java.sql.Types
;
import
java.util.Arrays
;
import
java.util.Properties
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
...
...
@@ -153,7 +154,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements
}
else
{
tableType
=
"TRUE"
;
}
PreparedStatement
prep
=
conn
.
prepareAutoCloseStatement
(
"SELECT "
String
tableSelect
=
"SELECT "
+
"TABLE_CATALOG TABLE_CAT, "
+
"TABLE_SCHEMA TABLE_SCHEM, "
+
"TABLE_NAME, "
...
...
@@ -169,16 +171,55 @@ public class JdbcDatabaseMetaData extends TraceObject implements
+
"WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
+
"AND TABLE_SCHEMA LIKE ? ESCAPE ? "
+
"AND TABLE_NAME LIKE ? ESCAPE ? "
+
"AND ("
+
tableType
+
") "
+
"ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME"
);
+
"AND ("
+
tableType
+
") "
;
boolean
includeSynonyms
=
types
==
null
||
Arrays
.
asList
(
types
).
contains
(
"SYNONYM"
);
String
synonymSelect
=
"SELECT "
+
"SYNONYM_CATALOG TABLE_CAT, "
+
"SYNONYM_SCHEMA TABLE_SCHEM, "
+
"SYNONYM_NAME as TABLE_NAME, "
+
"TYPE_NAME AS TABLE_TYPE, "
+
"REMARKS, "
+
"TYPE_NAME TYPE_CAT, "
+
"TYPE_NAME TYPE_SCHEM, "
+
"TYPE_NAME AS TYPE_NAME, "
+
"TYPE_NAME SELF_REFERENCING_COL_NAME, "
+
"TYPE_NAME REF_GENERATION, "
+
"NULL AS SQL "
+
"FROM INFORMATION_SCHEMA.SYNONYMS "
+
"WHERE SYNONYM_CATALOG LIKE ? ESCAPE ? "
+
"AND SYNONYM_SCHEMA LIKE ? ESCAPE ? "
+
"AND SYNONYM_NAME LIKE ? ESCAPE ? "
+
"AND ("
+
includeSynonyms
+
") "
;
PreparedStatement
prep
=
conn
.
prepareAutoCloseStatement
(
"SELECT "
+
"TABLE_CAT, "
+
"TABLE_SCHEM, "
+
"TABLE_NAME, "
+
"TABLE_TYPE, "
+
"REMARKS, "
+
"TYPE_CAT, "
+
"TYPE_SCHEM, "
+
"TYPE_NAME, "
+
"SELF_REFERENCING_COL_NAME, "
+
"REF_GENERATION, "
+
"SQL "
+
"FROM ("
+
synonymSelect
+
" UNION "
+
tableSelect
+
") "
+
"ORDER BY TABLE_TYPE, TABLE_SCHEM, TABLE_NAME"
);
prep
.
setString
(
1
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
2
,
"\\"
);
prep
.
setString
(
3
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
4
,
"\\"
);
prep
.
setString
(
5
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
6
,
"\\"
);
prep
.
setString
(
7
,
getCatalogPattern
(
catalogPattern
));
prep
.
setString
(
8
,
"\\"
);
prep
.
setString
(
9
,
getSchemaPattern
(
schemaPattern
));
prep
.
setString
(
10
,
"\\"
);
prep
.
setString
(
11
,
getPattern
(
tableNamePattern
));
prep
.
setString
(
12
,
"\\"
);
for
(
int
i
=
0
;
types
!=
null
&&
i
<
types
.
length
;
i
++)
{
prep
.
setString
(
7
+
i
,
types
[
i
]);
prep
.
setString
(
13
+
i
,
types
[
i
]);
}
return
prep
.
executeQuery
();
}
catch
(
Exception
e
)
{
...
...
h2/src/main/org/h2/schema/Constant.java
浏览文件 @
f5d37007
...
...
@@ -10,7 +10,7 @@ import org.h2.engine.Session;
import
org.h2.expression.ValueExpression
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.value.Value
;
/**
...
...
@@ -27,7 +27,7 @@ public class Constant extends SchemaObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
f5d37007
...
...
@@ -25,7 +25,6 @@ import org.h2.index.Index;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.mvstore.db.MVTableEngine
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.RegularTable
;
import
org.h2.table.Table
;
import
org.h2.table.TableLink
;
...
...
@@ -43,7 +42,8 @@ public class Schema extends DbObjectBase {
private
final
boolean
system
;
private
ArrayList
<
String
>
tableEngineParams
;
private
final
ConcurrentHashMap
<
String
,
AbstractTable
>
tablesAndViews
;
private
final
ConcurrentHashMap
<
String
,
Table
>
tablesAndViews
;
private
final
ConcurrentHashMap
<
String
,
TableSynonym
>
synonyms
;
private
final
ConcurrentHashMap
<
String
,
Index
>
indexes
;
private
final
ConcurrentHashMap
<
String
,
Sequence
>
sequences
;
private
final
ConcurrentHashMap
<
String
,
TriggerObject
>
triggers
;
...
...
@@ -71,6 +71,7 @@ public class Schema extends DbObjectBase {
public
Schema
(
Database
database
,
int
id
,
String
schemaName
,
User
owner
,
boolean
system
)
{
tablesAndViews
=
database
.
newConcurrentStringMap
();
synonyms
=
database
.
newConcurrentStringMap
();
indexes
=
database
.
newConcurrentStringMap
();
sequences
=
database
.
newConcurrentStringMap
();
triggers
=
database
.
newConcurrentStringMap
();
...
...
@@ -92,7 +93,7 @@ public class Schema extends DbObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
@@ -132,7 +133,7 @@ public class Schema extends DbObjectBase {
runLoopAgain
=
false
;
if
(
tablesAndViews
!=
null
)
{
// Loop over a copy because the map is modified underneath us.
for
(
Abstract
Table
obj
:
New
.
arrayList
(
tablesAndViews
.
values
()))
{
for
(
Table
obj
:
New
.
arrayList
(
tablesAndViews
.
values
()))
{
// Check for null because multiple tables might be deleted
// in one go underneath us.
if
(
obj
.
getName
()
!=
null
)
{
...
...
@@ -204,6 +205,9 @@ public class Schema extends DbObjectBase {
case
DbObject
.
TABLE_OR_VIEW
:
result
=
tablesAndViews
;
break
;
case
DbObject
.
SYNONYM
:
result
=
synonyms
;
break
;
case
DbObject
.
SEQUENCE
:
result
=
sequences
;
break
;
...
...
@@ -276,20 +280,53 @@ public class Schema extends DbObjectBase {
/**
* Try to find a table or view with this name. This method returns null if
* no object with this name exists. Local temporary tables are also
* returned.
* returned.
Synonyms are not returned or resolved.
*
* @param session the session
* @param name the object name
* @return the object or null
*/
public
Abstract
Table
findTableOrView
(
Session
session
,
String
name
)
{
Abstract
Table
table
=
tablesAndViews
.
get
(
name
);
public
Table
findTableOrView
(
Session
session
,
String
name
)
{
Table
table
=
tablesAndViews
.
get
(
name
);
if
(
table
==
null
&&
session
!=
null
)
{
table
=
session
.
findLocalTempTable
(
name
);
}
return
table
;
}
/**
* Try to find a table or view with this name. This method returns null if
* no object with this name exists. Local temporary tables are also
* returned. If a synonym with this name exists, the backing table of the
* synonym is returned
*
* @param session the session
* @param name the object name
* @return the object or null
*/
public
Table
resolveTableOrView
(
Session
session
,
String
name
)
{
Table
table
=
findTableOrView
(
session
,
name
);
if
(
table
==
null
)
{
TableSynonym
synonym
=
synonyms
.
get
(
name
);
if
(
synonym
!=
null
)
{
return
synonym
.
getSynonymFor
();
}
return
null
;
}
return
table
;
}
/**
* Try to find a synonym with this name. This method returns null if
* no object with this name exists.
*
* @param name the object name
* @return the object or null
*/
public
TableSynonym
getSynonym
(
String
name
)
{
return
synonyms
.
get
(
name
);
}
/**
* Try to find an index with this name. This method returns null if
* no object with this name exists.
...
...
@@ -412,7 +449,7 @@ public class Schema extends DbObjectBase {
* @param table the constraint table
* @return the unique name
*/
public
String
getUniqueConstraintName
(
Session
session
,
Abstract
Table
table
)
{
public
String
getUniqueConstraintName
(
Session
session
,
Table
table
)
{
Map
<
String
,
Constraint
>
tableConstraints
;
if
(
table
.
isTemporary
()
&&
!
table
.
isGlobalTemporary
())
{
tableConstraints
=
session
.
getLocalTempTableConstraints
();
...
...
@@ -430,7 +467,7 @@ public class Schema extends DbObjectBase {
* @param prefix the index name prefix
* @return the unique name
*/
public
String
getUniqueIndexName
(
Session
session
,
Abstract
Table
table
,
String
prefix
)
{
public
String
getUniqueIndexName
(
Session
session
,
Table
table
,
String
prefix
)
{
Map
<
String
,
Index
>
tableIndexes
;
if
(
table
.
isTemporary
()
&&
!
table
.
isGlobalTemporary
())
{
tableIndexes
=
session
.
getLocalTempTableIndexes
();
...
...
@@ -449,8 +486,8 @@ public class Schema extends DbObjectBase {
* @return the table or view
* @throws DbException if no such object exists
*/
public
Abstract
Table
getTableOrView
(
Session
session
,
String
name
)
{
Abstract
Table
table
=
tablesAndViews
.
get
(
name
);
public
Table
getTableOrView
(
Session
session
,
String
name
)
{
Table
table
=
tablesAndViews
.
get
(
name
);
if
(
table
==
null
)
{
if
(
session
!=
null
)
{
table
=
session
.
findLocalTempTable
(
name
);
...
...
@@ -555,19 +592,26 @@ public class Schema extends DbObjectBase {
*
* @return a (possible empty) list of all objects
*/
public
ArrayList
<
Abstract
Table
>
getAllTablesAndViews
()
{
public
ArrayList
<
Table
>
getAllTablesAndViews
()
{
synchronized
(
database
)
{
return
New
.
arrayList
(
tablesAndViews
.
values
());
}
}
public
ArrayList
<
TableSynonym
>
getAllSynonyms
()
{
synchronized
(
database
)
{
return
New
.
arrayList
(
synonyms
.
values
());
}
}
/**
* Get the table with the given name, if any.
*
* @param name the table name
* @return the table or null if not found
*/
public
Abstract
Table
getTableOrViewByName
(
String
name
)
{
public
Table
getTableOrViewByName
(
String
name
)
{
synchronized
(
database
)
{
return
tablesAndViews
.
get
(
name
);
}
...
...
h2/src/main/org/h2/schema/Sequence.java
浏览文件 @
f5d37007
...
...
@@ -11,7 +11,7 @@ import org.h2.engine.DbObject;
import
org.h2.engine.Session
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
/**
* A sequence is created using the statement
...
...
@@ -206,7 +206,7 @@ public class Sequence extends SchemaObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
throw
DbException
.
throwInternalError
(
toString
());
}
...
...
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
f5d37007
...
...
@@ -18,7 +18,7 @@ import org.h2.engine.Session;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.result.Row
;
import
org.h2.table.
Abstract
Table
;
import
org.h2.table.Table
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.SourceCompiler
;
import
org.h2.util.StatementBuilder
;
...
...
@@ -45,12 +45,12 @@ public class TriggerObject extends SchemaObjectBase {
// TODO trigger: support queue and noWait = false as well
private
int
queueSize
=
DEFAULT_QUEUE_SIZE
;
private
boolean
noWait
;
private
Abstract
Table
table
;
private
Table
table
;
private
String
triggerClassName
;
private
String
triggerSource
;
private
Trigger
triggerCallback
;
public
TriggerObject
(
Schema
schema
,
int
id
,
String
name
,
Abstract
Table
table
)
{
public
TriggerObject
(
Schema
schema
,
int
id
,
String
name
,
Table
table
)
{
initSchemaObjectBase
(
schema
,
id
,
name
,
Trace
.
TRIGGER
);
this
.
table
=
table
;
setTemporary
(
table
.
isTemporary
());
...
...
@@ -318,7 +318,7 @@ public class TriggerObject extends SchemaObjectBase {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
targetTable
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
targetTable
,
String
quotedName
)
{
StringBuilder
buff
=
new
StringBuilder
(
"CREATE FORCE TRIGGER "
);
buff
.
append
(
quotedName
);
if
(
insteadOf
)
{
...
...
@@ -409,7 +409,7 @@ public class TriggerObject extends SchemaObjectBase {
*
* @return the table
*/
public
Abstract
Table
getTable
()
{
public
Table
getTable
()
{
return
table
;
}
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
f5d37007
...
...
@@ -37,7 +37,6 @@ import org.h2.message.Trace;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.table.AbstractTable
;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.RegularTable
;
...
...
@@ -553,12 +552,12 @@ public class PageStore implements CacheWriter {
log
.
checkpoint
();
writeBack
();
cache
.
clear
();
ArrayList
<
Abstract
Table
>
tables
=
database
.
getAllTablesAndViews
(
false
);
ArrayList
<
Table
>
tables
=
database
.
getAllTablesAndViews
(
false
);
recordedPagesList
=
New
.
arrayList
();
recordedPagesIndex
=
new
IntIntHashMap
();
recordPageReads
=
true
;
Session
sysSession
=
database
.
getSystemSession
();
for
(
Abstract
Table
table
:
tables
)
{
for
(
Table
table
:
tables
)
{
if
(!
table
.
isTemporary
()
&&
TableType
.
TABLE
==
table
.
getTableType
())
{
Index
scanIndex
=
table
.
getScanIndex
(
sysSession
);
Cursor
cursor
=
scanIndex
.
find
(
sysSession
,
null
,
null
);
...
...
h2/src/main/org/h2/table/AbstractTable.java
deleted
100644 → 0
浏览文件 @
810a0771
差异被折叠。
点击展开。
h2/src/main/org/h2/table/Column.java
浏览文件 @
f5d37007
...
...
@@ -70,7 +70,7 @@ public class Column {
private
int
scale
;
private
String
[]
enumerators
;
private
int
displaySize
;
private
Abstract
Table
table
;
private
Table
table
;
private
String
name
;
private
int
columnId
;
private
boolean
nullable
=
true
;
...
...
@@ -224,12 +224,12 @@ public class Column {
* @param table the table
* @param columnId the column index
*/
public
void
setTable
(
Abstract
Table
table
,
int
columnId
)
{
public
void
setTable
(
Table
table
,
int
columnId
)
{
this
.
table
=
table
;
this
.
columnId
=
columnId
;
}
public
Abstract
Table
getTable
()
{
public
Table
getTable
()
{
return
table
;
}
...
...
h2/src/main/org/h2/table/IndexColumn.java
浏览文件 @
f5d37007
...
...
@@ -69,7 +69,7 @@ public class IndexColumn {
* @param indexColumns the column list with column names set
* @param table the table from where to map the column names to columns
*/
public
static
void
mapColumns
(
IndexColumn
[]
indexColumns
,
Abstract
Table
table
)
{
public
static
void
mapColumns
(
IndexColumn
[]
indexColumns
,
Table
table
)
{
for
(
IndexColumn
col
:
indexColumns
)
{
col
.
column
=
table
.
getColumn
(
col
.
columnName
);
}
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
f5d37007
...
...
@@ -546,6 +546,7 @@ public class MetaTable extends Table {
"SYNONYM_SCHEMA"
,
"SYNONYM_NAME"
,
"SYNONYM_FOR"
,
"TYPE_NAME"
,
"STATUS"
,
"REMARKS"
,
"ID INT"
...
...
@@ -624,18 +625,18 @@ public class MetaTable extends Table {
return
s
;
}
private
ArrayList
<
Abstract
Table
>
getAllTables
(
Session
session
)
{
ArrayList
<
Abstract
Table
>
tables
=
database
.
getAllTablesAndViews
(
true
);
private
ArrayList
<
Table
>
getAllTables
(
Session
session
)
{
ArrayList
<
Table
>
tables
=
database
.
getAllTablesAndViews
(
true
);
ArrayList
<
Table
>
tempTables
=
session
.
getLocalTempTables
();
tables
.
addAll
(
tempTables
);
return
tables
;
}
private
ArrayList
<
Abstract
Table
>
getTablesByName
(
Session
session
,
String
tableName
)
{
private
ArrayList
<
Table
>
getTablesByName
(
Session
session
,
String
tableName
)
{
if
(
database
.
getMode
().
lowerCaseIdentifiers
)
{
tableName
=
StringUtils
.
toUpperEnglish
(
tableName
);
}
ArrayList
<
Abstract
Table
>
tables
=
database
.
getTableOrViewByName
(
tableName
);
ArrayList
<
Table
>
tables
=
database
.
getTableOrViewByName
(
tableName
);
for
(
Table
temp
:
session
.
getLocalTempTables
())
{
if
(
temp
.
getName
().
equals
(
tableName
))
{
tables
.
add
(
temp
);
...
...
@@ -669,7 +670,7 @@ public class MetaTable extends Table {
return
s
==
null
?
""
:
s
;
}
private
boolean
hideTable
(
Abstract
Table
table
,
Session
session
)
{
private
boolean
hideTable
(
Table
table
,
Session
session
)
{
return
table
.
isHidden
()
&&
session
!=
database
.
getSystemSession
();
}
...
...
@@ -700,7 +701,7 @@ public class MetaTable extends Table {
boolean
admin
=
session
.
getUser
().
isAdmin
();
switch
(
type
)
{
case
TABLES:
{
for
(
Abstract
Table
table
:
getAllTables
(
session
))
{
for
(
Table
table
:
getAllTables
(
session
))
{
String
tableName
=
identifier
(
table
.
getName
());
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
...
...
@@ -758,14 +759,14 @@ public class MetaTable extends Table {
case
COLUMNS:
{
// reduce the number of tables to scan - makes some metadata queries
// 10x faster
final
ArrayList
<
Abstract
Table
>
tablesToList
;
final
ArrayList
<
Table
>
tablesToList
;
if
(
indexFrom
!=
null
&&
indexTo
!=
null
&&
indexFrom
.
equals
(
indexTo
))
{
String
tableName
=
identifier
(
indexFrom
.
getString
());
tablesToList
=
getTablesByName
(
session
,
tableName
);
}
else
{
tablesToList
=
getAllTables
(
session
);
}
for
(
Abstract
Table
table
:
tablesToList
)
{
for
(
Table
table
:
tablesToList
)
{
String
tableName
=
identifier
(
table
.
getName
());
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
...
...
@@ -835,14 +836,14 @@ public class MetaTable extends Table {
case
INDEXES:
{
// reduce the number of tables to scan - makes some metadata queries
// 10x faster
final
ArrayList
<
Abstract
Table
>
tablesToList
;
final
ArrayList
<
Table
>
tablesToList
;
if
(
indexFrom
!=
null
&&
indexTo
!=
null
&&
indexFrom
.
equals
(
indexTo
))
{
String
tableName
=
identifier
(
indexFrom
.
getString
());
tablesToList
=
getTablesByName
(
session
,
tableName
);
}
else
{
tablesToList
=
getAllTables
(
session
);
}
for
(
Abstract
Table
table
:
tablesToList
)
{
for
(
Table
table
:
tablesToList
)
{
String
tableName
=
identifier
(
table
.
getName
());
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
...
...
@@ -1488,7 +1489,7 @@ public class MetaTable extends Table {
break
;
}
case
VIEWS:
{
for
(
Abstract
Table
table
:
getAllTables
(
session
))
{
for
(
Table
table
:
getAllTables
(
session
))
{
if
(
table
.
getTableType
()
!=
TableType
.
VIEW
)
{
continue
;
}
...
...
@@ -1544,8 +1545,8 @@ public class MetaTable extends Table {
ConstraintReferential
ref
=
(
ConstraintReferential
)
constraint
;
IndexColumn
[]
cols
=
ref
.
getColumns
();
IndexColumn
[]
refCols
=
ref
.
getRefColumns
();
Abstract
Table
tab
=
ref
.
getTable
();
Abstract
Table
refTab
=
ref
.
getRefTable
();
Table
tab
=
ref
.
getTable
();
Table
refTab
=
ref
.
getRefTable
();
String
tableName
=
identifier
(
refTab
.
getName
());
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
...
...
@@ -1594,7 +1595,7 @@ public class MetaTable extends Table {
String
constraintType
=
constraint
.
getConstraintType
();
String
checkExpression
=
null
;
IndexColumn
[]
indexColumns
=
null
;
Abstract
Table
table
=
constraint
.
getTable
();
Table
table
=
constraint
.
getTable
();
if
(
hideTable
(
table
,
session
))
{
continue
;
}
...
...
@@ -1719,7 +1720,7 @@ public class MetaTable extends Table {
for
(
SchemaObject
obj
:
database
.
getAllSchemaObjects
(
DbObject
.
TRIGGER
))
{
TriggerObject
trigger
=
(
TriggerObject
)
obj
;
Abstract
Table
table
=
trigger
.
getTable
();
Table
table
=
trigger
.
getTable
();
add
(
rows
,
// TRIGGER_CATALOG
catalog
,
...
...
@@ -1878,23 +1879,20 @@ public class MetaTable extends Table {
break
;
}
case
SYNONYMS:
{
for
(
AbstractTable
table
:
getAllTables
(
session
))
{
if
(!
table
.
getTableType
().
equals
(
TableType
.
SYNONYM
))
{
continue
;
}
String
synonymName
=
identifier
(
table
.
getName
());
TableSynonym
synonym
=
(
TableSynonym
)
table
;
for
(
TableSynonym
synonym
:
database
.
getAllSynonyms
())
{
add
(
rows
,
// SYNONYM_CATALOG
catalog
,
// SYNONYM_SCHEMA
identifier
(
table
.
getSchema
().
getName
()),
identifier
(
synonym
.
getSchema
().
getName
()),
// SYNONYM_NAME
synonymName
,
identifier
(
synonym
.
getName
())
,
// SYNONYM_FOR
synonym
.
getSynonymForName
(),
// TYPE NAME
"SYNONYM"
,
// STATUS
synonym
.
isInvalid
()
?
"INVALID"
:
"VALID"
,
"VALID"
,
// REMARKS
replaceNullWithEmpty
(
synonym
.
getComment
()),
// ID
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
f5d37007
差异被折叠。
点击展开。
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
f5d37007
...
...
@@ -51,7 +51,7 @@ public class TableFilter implements ColumnResolver {
private
Session
session
;
private
final
Abstract
Table
table
;
private
final
Table
table
;
private
final
Select
select
;
private
String
alias
;
private
Index
index
;
...
...
@@ -128,7 +128,7 @@ public class TableFilter implements ColumnResolver {
* @param orderInFrom original order number (index) of this table filter in
* @param indexHints the index hints to be used by the query planner
*/
public
TableFilter
(
Session
session
,
Abstract
Table
table
,
String
alias
,
public
TableFilter
(
Session
session
,
Table
table
,
String
alias
,
boolean
rightsChecked
,
Select
select
,
int
orderInFrom
,
IndexHints
indexHints
)
{
this
.
session
=
session
;
this
.
table
=
table
;
...
...
@@ -162,7 +162,7 @@ public class TableFilter implements ColumnResolver {
return
select
;
}
public
Abstract
Table
getTable
()
{
public
Table
getTable
()
{
return
table
;
}
...
...
h2/src/main/org/h2/table/TableSynonym.java
浏览文件 @
f5d37007
差异被折叠。
点击展开。
h2/src/main/org/h2/table/TableType.java
浏览文件 @
f5d37007
...
...
@@ -33,12 +33,7 @@ public enum TableType {
/**
* The table type name for external table engines.
*/
EXTERNAL_TABLE_ENGINE
,
/**
* The table type name for synonyms.
*/
SYNONYM
;
EXTERNAL_TABLE_ENGINE
;
@Override
public
String
toString
()
{
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
f5d37007
...
...
@@ -45,7 +45,7 @@ public class TableView extends Table {
private
static
final
long
ROW_COUNT_APPROXIMATION
=
100
;
private
String
querySQL
;
private
ArrayList
<
Abstract
Table
>
tables
;
private
ArrayList
<
Table
>
tables
;
private
Column
[]
columnTemplates
;
private
Query
viewQuery
;
private
ViewIndex
index
;
...
...
@@ -265,7 +265,7 @@ public class TableView extends Table {
if
(!
super
.
isQueryComparable
())
{
return
false
;
}
for
(
Abstract
Table
t
:
tables
)
{
for
(
Table
t
:
tables
)
{
if
(!
t
.
isQueryComparable
())
{
return
false
;
}
...
...
@@ -287,7 +287,7 @@ public class TableView extends Table {
}
@Override
public
String
getCreateSQLForCopy
(
Abstract
Table
table
,
String
quotedName
)
{
public
String
getCreateSQLForCopy
(
Table
table
,
String
quotedName
)
{
return
getCreateSQL
(
false
,
true
,
quotedName
);
}
...
...
@@ -502,7 +502,7 @@ public class TableView extends Table {
private
void
removeViewFromTables
()
{
if
(
tables
!=
null
)
{
for
(
Abstract
Table
t
:
tables
)
{
for
(
Table
t
:
tables
)
{
t
.
removeView
(
this
);
}
tables
.
clear
();
...
...
@@ -510,7 +510,7 @@ public class TableView extends Table {
}
private
void
addViewToTables
()
{
for
(
Abstract
Table
t
:
tables
)
{
for
(
Table
t
:
tables
)
{
t
.
addView
(
this
);
}
}
...
...
@@ -620,7 +620,7 @@ public class TableView extends Table {
public
void
addDependencies
(
HashSet
<
DbObject
>
dependencies
)
{
super
.
addDependencies
(
dependencies
);
if
(
tables
!=
null
)
{
for
(
Abstract
Table
t
:
tables
)
{
for
(
Table
t
:
tables
)
{
if
(
TableType
.
VIEW
!=
t
.
getTableType
())
{
t
.
addDependencies
(
dependencies
);
}
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
f5d37007
...
...
@@ -95,6 +95,7 @@ public class TestPreparedStatement extends TestBase {
testColumnMetaDataWithIn
(
conn
);
conn
.
close
();
testPreparedStatementWithLiteralsNone
();
testPreparedStatementWithIndexedParameterAndLiteralsNone
();
deleteDb
(
"preparedStatement"
);
}
...
...
@@ -1420,6 +1421,27 @@ public class TestPreparedStatement extends TestBase {
deleteDb
(
"preparedStatement"
);
}
private
void
testPreparedStatementWithIndexedParameterAndLiteralsNone
()
throws
SQLException
{
// make sure that when the analyze table kicks in,
// it works with ALLOW_LITERALS=NONE
deleteDb
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement;ANALYZE_AUTO=100"
);
conn
.
createStatement
().
execute
(
"SET ALLOW_LITERALS NONE"
);
conn
.
prepareStatement
(
"CREATE TABLE test (id INT)"
).
execute
();
PreparedStatement
ps
=
conn
.
prepareStatement
(
"INSERT INTO test (id) VALUES (?1)"
);
ps
.
setInt
(
1
,
1
);
ps
.
executeUpdate
();
conn
.
close
();
deleteDb
(
"preparedStatement"
);
}
private
void
checkBigDecimal
(
ResultSet
rs
,
String
[]
value
)
throws
SQLException
{
for
(
String
v
:
value
)
{
assertTrue
(
rs
.
next
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论