Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3b67839d
提交
3b67839d
authored
9月 10, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Trying to create a view with parameters in the query will now throw an exception.
上级
c2e881d0
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
4 行删除
+38
-4
changelog.html
h2/src/docsrc/html/changelog.html
+3
-1
CreateView.java
h2/src/main/org/h2/command/ddl/CreateView.java
+7
-3
TestView.java
h2/src/test/org/h2/test/db/TestView.java
+28
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
3b67839d
...
@@ -18,7 +18,9 @@ Change Log
...
@@ -18,7 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
New experimental feature SHUTDOWN DEFRAG.
<ul><li>
Trying to create a view with parameters in the query will now throw an exception.
So far, creating the view was allowed, but the parameter value was not used (null was used instead).
</li><li>
New experimental feature SHUTDOWN DEFRAG.
This option re-orders the pages while closing the database so that table scans are faster.
This option re-orders the pages while closing the database so that table scans are faster.
</li><li>
When using the MULTI_THREADED option, concurrently reading from a database
</li><li>
When using the MULTI_THREADED option, concurrently reading from a database
(specially from a larger database, or when using a small cache size) could throw an exception.
(specially from a larger database, or when using a small cache size) could throw an exception.
...
...
h2/src/main/org/h2/command/ddl/CreateView.java
浏览文件 @
3b67839d
...
@@ -13,7 +13,9 @@ import org.h2.engine.Constants;
...
@@ -13,7 +13,9 @@ import org.h2.engine.Constants;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.expression.Parameter
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.TraceObject
;
import
org.h2.schema.Schema
;
import
org.h2.schema.Schema
;
import
org.h2.table.Table
;
import
org.h2.table.Table
;
import
org.h2.table.TableView
;
import
org.h2.table.TableView
;
...
@@ -89,7 +91,6 @@ public class CreateView extends SchemaCommand {
...
@@ -89,7 +91,6 @@ public class CreateView extends SchemaCommand {
if
(
ifNotExists
)
{
if
(
ifNotExists
)
{
return
0
;
return
0
;
}
}
if
(
orReplace
&&
existingView
.
getTableType
().
equals
(
Table
.
VIEW
))
{
if
(
orReplace
&&
existingView
.
getTableType
().
equals
(
Table
.
VIEW
))
{
db
.
renameSchemaObject
(
session
,
existingView
,
db
.
getTempTableName
(
session
));
db
.
renameSchemaObject
(
session
,
existingView
,
db
.
getTempTableName
(
session
));
loadDependentViewSql
(
existingView
,
dependentViewSql
);
loadDependentViewSql
(
existingView
,
dependentViewSql
);
...
@@ -102,7 +103,11 @@ public class CreateView extends SchemaCommand {
...
@@ -102,7 +103,11 @@ public class CreateView extends SchemaCommand {
if
(
select
==
null
)
{
if
(
select
==
null
)
{
querySQL
=
selectSQL
;
querySQL
=
selectSQL
;
}
else
{
}
else
{
querySQL
=
select
.
getSQL
();
ArrayList
<
Parameter
>
params
=
select
.
getParameters
();
if
(
params
!=
null
&&
params
.
size
()
>
0
)
{
throw
DbException
.
get
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
,
"parameters in views"
);
}
querySQL
=
TraceObject
.
toString
(
select
.
getSQL
(),
select
.
getParameters
());
}
}
Session
sysSession
=
db
.
getSystemSession
();
Session
sysSession
=
db
.
getSystemSession
();
TableView
view
;
TableView
view
;
...
@@ -120,7 +125,6 @@ public class CreateView extends SchemaCommand {
...
@@ -120,7 +125,6 @@ public class CreateView extends SchemaCommand {
// this is not strictly required - ignore exceptions, specially when using FORCE
// this is not strictly required - ignore exceptions, specially when using FORCE
}
}
db
.
addSchemaObject
(
session
,
view
);
db
.
addSchemaObject
(
session
,
view
);
if
(
existingView
!=
null
)
{
if
(
existingView
!=
null
)
{
recreateDependentViews
(
db
,
existingView
,
dependentViewSql
,
view
);
recreateDependentViews
(
db
,
existingView
,
dependentViewSql
,
view
);
}
}
...
...
h2/src/test/org/h2/test/db/TestView.java
浏览文件 @
3b67839d
...
@@ -30,6 +30,7 @@ public class TestView extends TestBase {
...
@@ -30,6 +30,7 @@ public class TestView extends TestBase {
}
}
public
void
test
()
throws
SQLException
{
public
void
test
()
throws
SQLException
{
testParameterizedView
();
testCache
();
testCache
();
testCacheFunction
(
true
);
testCacheFunction
(
true
);
testCacheFunction
(
false
);
testCacheFunction
(
false
);
...
@@ -39,6 +40,33 @@ public class TestView extends TestBase {
...
@@ -39,6 +40,33 @@ public class TestView extends TestBase {
deleteDb
(
"view"
);
deleteDb
(
"view"
);
}
}
private
void
testParameterizedView
()
throws
SQLException
{
deleteDb
(
"view"
);
Connection
conn
=
getConnection
(
"view"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE TABLE Test(id INT AUTO_INCREMENT NOT NULL, f1 VARCHAR NOT NULL, f2 VARCHAR NOT NULL)"
);
stat
.
execute
(
"INSERT INTO Test(f1, f2) VALUES ('value1','value2')"
);
stat
.
execute
(
"INSERT INTO Test(f1, f2) VALUES ('value1','value3')"
);
PreparedStatement
ps
=
conn
.
prepareStatement
(
"CREATE VIEW Test_View AS SELECT f2 FROM Test WHERE f1=?"
);
ps
.
setString
(
1
,
"value1"
);
try
{
ps
.
executeUpdate
();
fail
();
}
catch
(
SQLException
e
)
{
assertKnownException
(
e
);
}
// ResultSet rs;
// rs = stat.executeQuery("SELECT * FROM Test_View");
// assertTrue(rs.next());
// assertFalse(rs.next());
// rs = stat.executeQuery("select VIEW_DEFINITION " +
// "from information_schema.views " +
// "where TABLE_NAME='TEST_VIEW'");
// rs.next();
// assertEquals("...", rs.getString(1));
conn
.
close
();
}
private
void
testCacheFunction
(
boolean
deterministic
)
throws
SQLException
{
private
void
testCacheFunction
(
boolean
deterministic
)
throws
SQLException
{
deleteDb
(
"view"
);
deleteDb
(
"view"
);
Connection
conn
=
getConnection
(
"view"
);
Connection
conn
=
getConnection
(
"view"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论