Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5d7d2dd8
提交
5d7d2dd8
authored
3月 24, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
If a value of a result set was itself a result set, the result could only be read once.
上级
94520f3f
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
179 行增加
和
152 行删除
+179
-152
changelog.html
h2/src/docsrc/html/changelog.html
+3
-1
TableFunction.java
h2/src/main/org/h2/expression/TableFunction.java
+1
-0
SimpleResultSet.java
h2/src/main/org/h2/tools/SimpleResultSet.java
+161
-151
TestResultSet.java
h2/src/test/org/h2/test/jdbc/TestResultSet.java
+14
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
5d7d2dd8
...
...
@@ -18,7 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Column constraints are also visible in views (patch from Nicolas Fortin for H2GIS).
<ul><li>
If a value of a result set was itself a result set, the result
could only be read once.
</li><li>
Column constraints are also visible in views (patch from Nicolas Fortin for H2GIS).
</li><li>
Granting a additional right to a role that already had a right for that table was not working.
</li><li>
Spatial index: a few bugs have been fixed (using spatial constraints in views,
transferring geometry objects over TCP/IP).
...
...
h2/src/main/org/h2/expression/TableFunction.java
浏览文件 @
5d7d2dd8
...
...
@@ -135,6 +135,7 @@ public class TableFunction extends Function {
int
maxrows
)
{
int
columnCount
=
rs
.
getVisibleColumnCount
();
SimpleResultSet
simple
=
new
SimpleResultSet
();
simple
.
setAutoClose
(
false
);
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
String
name
=
rs
.
getColumnName
(
i
);
int
sqlType
=
DataType
.
convertTypeToSQLType
(
rs
.
getColumnType
(
i
));
...
...
h2/src/main/org/h2/tools/SimpleResultSet.java
浏览文件 @
5d7d2dd8
...
...
@@ -64,149 +64,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
private
ArrayList
<
Column
>
columns
=
New
.
arrayList
();
private
boolean
autoClose
=
true
;
/**
* This class holds the data of a result column.
*/
static
class
Column
{
/**
* The column label.
*/
String
name
;
/**
* The column type Name
*/
String
sqlTypeName
;
/**
* The SQL type.
*/
int
sqlType
;
/**
* The precision.
*/
int
precision
;
/**
* The scale.
*/
int
scale
;
}
/**
* A simple array implementation,
* backed by an object array
*/
public
static
class
SimpleArray
implements
Array
{
private
final
Object
[]
value
;
SimpleArray
(
Object
[]
value
)
{
this
.
value
=
value
;
}
/**
* Get the object array.
*
* @return the object array
*/
@Override
public
Object
getArray
()
{
return
value
;
}
/**
* INTERNAL
*/
@Override
public
Object
getArray
(
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
Object
getArray
(
long
index
,
int
count
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
Object
getArray
(
long
index
,
int
count
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* Get the base type of this array.
*
* @return Types.NULL
*/
@Override
public
int
getBaseType
()
{
return
Types
.
NULL
;
}
/**
* Get the base type name of this array.
*
* @return "NULL"
*/
@Override
public
String
getBaseTypeName
()
{
return
"NULL"
;
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
()
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
(
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
(
long
index
,
int
count
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
(
long
index
,
int
count
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
void
free
()
{
// nothing to do
}
}
/**
* This constructor is used if the result set is later populated with
* addRow.
...
...
@@ -324,14 +181,18 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
}
/**
* Returns ResultSet.TYPE_FORWARD_ONLY.
* Returns the result set type. This is ResultSet.TYPE_FORWARD_ONLY for
* auto-close result sets, and ResultSet.TYPE_SCROLL_INSENSITIVE for others.
*
* @return TYPE_FORWARD_ONLY
* @return TYPE_FORWARD_ONLY
or TYPE_SCROLL_INSENSITIVE
*/
@Override
public
int
getType
()
{
if
(
autoClose
)
{
return
ResultSet
.
TYPE_FORWARD_ONLY
;
}
return
ResultSet
.
TYPE_SCROLL_INSENSITIVE
;
}
/**
* Closes the result set and releases the resources.
...
...
@@ -375,11 +236,14 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
}
/**
* Moves the current position to before the first row, that means
resets the
*
result
set.
* Moves the current position to before the first row, that means
the result
*
set is re
set.
*/
@Override
public
void
beforeFirst
()
throws
SQLException
{
if
(
autoClose
)
{
throw
DbException
.
get
(
ErrorCode
.
RESULT_SET_NOT_SCROLLABLE
);
}
rowId
=
-
1
;
if
(
source
!=
null
)
{
source
.
reset
();
...
...
@@ -2337,7 +2201,8 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* INTERNAL
*/
static
SQLException
getUnsupportedException
()
{
return
DbException
.
get
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
).
getSQLException
();
return
DbException
.
get
(
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
).
getSQLException
();
}
private
void
checkColumnIndex
(
int
columnIndex
)
throws
SQLException
{
...
...
@@ -2349,11 +2214,13 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
private
Object
get
(
int
columnIndex
)
throws
SQLException
{
if
(
currentRow
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
NO_DATA_AVAILABLE
).
getSQLException
();
throw
DbException
.
get
(
ErrorCode
.
NO_DATA_AVAILABLE
).
getSQLException
();
}
checkColumnIndex
(
columnIndex
);
columnIndex
--;
Object
o
=
columnIndex
<
currentRow
.
length
?
currentRow
[
columnIndex
]
:
null
;
Object
o
=
columnIndex
<
currentRow
.
length
?
currentRow
[
columnIndex
]
:
null
;
wasNull
=
o
==
null
;
return
o
;
}
...
...
@@ -2418,4 +2285,147 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
return
autoClose
;
}
/**
* This class holds the data of a result column.
*/
static
class
Column
{
/**
* The column label.
*/
String
name
;
/**
* The column type Name
*/
String
sqlTypeName
;
/**
* The SQL type.
*/
int
sqlType
;
/**
* The precision.
*/
int
precision
;
/**
* The scale.
*/
int
scale
;
}
/**
* A simple array implementation,
* backed by an object array
*/
public
static
class
SimpleArray
implements
Array
{
private
final
Object
[]
value
;
SimpleArray
(
Object
[]
value
)
{
this
.
value
=
value
;
}
/**
* Get the object array.
*
* @return the object array
*/
@Override
public
Object
getArray
()
{
return
value
;
}
/**
* INTERNAL
*/
@Override
public
Object
getArray
(
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
Object
getArray
(
long
index
,
int
count
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
Object
getArray
(
long
index
,
int
count
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* Get the base type of this array.
*
* @return Types.NULL
*/
@Override
public
int
getBaseType
()
{
return
Types
.
NULL
;
}
/**
* Get the base type name of this array.
*
* @return "NULL"
*/
@Override
public
String
getBaseTypeName
()
{
return
"NULL"
;
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
()
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
(
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
(
long
index
,
int
count
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
ResultSet
getResultSet
(
long
index
,
int
count
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
throw
getUnsupportedException
();
}
/**
* INTERNAL
*/
@Override
public
void
free
()
{
// nothing to do
}
}
}
h2/src/test/org/h2/test/jdbc/TestResultSet.java
浏览文件 @
5d7d2dd8
...
...
@@ -64,6 +64,7 @@ public class TestResultSet extends TestBase {
stat
=
conn
.
createStatement
();
testReuseSimpleResult
();
testUnsupportedOperations
();
testAmbiguousColumnNames
();
testInsertRowWithUpdatableResultSetDefault
();
...
...
@@ -102,6 +103,19 @@ public class TestResultSet extends TestBase {
}
private
void
testReuseSimpleResult
()
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"select table(x array=((1)))"
);
while
(
rs
.
next
())
{
rs
.
getString
(
1
);
}
rs
.
close
();
rs
=
stat
.
executeQuery
(
"select table(x array=((1)))"
);
while
(
rs
.
next
())
{
rs
.
getString
(
1
);
}
rs
.
close
();
}
@SuppressWarnings
(
"deprecation"
)
private
void
testUnsupportedOperations
()
throws
SQLException
{
ResultSet
rs
=
stat
.
executeQuery
(
"select 1 as x from dual"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论