Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
076e7531
提交
076e7531
authored
3月 14, 2016
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'igelbox-recursive-with-parameters'
上级
945c1631
1057b352
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
71 行增加
和
4 行删除
+71
-4
Parser.java
h2/src/main/org/h2/command/Parser.java
+7
-2
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+5
-1
_text_en.prop
h2/src/main/org/h2/server/web/res/_text_en.prop
+3
-0
_text_pt_br.prop
h2/src/main/org/h2/server/web/res/_text_pt_br.prop
+3
-0
header.jsp
h2/src/main/org/h2/server/web/res/header.jsp
+12
-0
query.jsp
h2/src/main/org/h2/server/web/res/query.jsp
+26
-1
TestRecursiveQueries.java
h2/src/test/org/h2/test/db/TestRecursiveQueries.java
+15
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
076e7531
...
@@ -220,6 +220,7 @@ public class Parser {
...
@@ -220,6 +220,7 @@ public class Parser {
private
boolean
recompileAlways
;
private
boolean
recompileAlways
;
private
ArrayList
<
Parameter
>
indexedParameterList
;
private
ArrayList
<
Parameter
>
indexedParameterList
;
private
int
orderInFrom
;
private
int
orderInFrom
;
private
ArrayList
<
Parameter
>
suppliedParameterList
;
public
Parser
(
Session
session
)
{
public
Parser
(
Session
session
)
{
this
.
database
=
session
.
getDatabase
();
this
.
database
=
session
.
getDatabase
();
...
@@ -311,7 +312,7 @@ public class Parser {
...
@@ -311,7 +312,7 @@ public class Parser {
currentPrepared
=
null
;
currentPrepared
=
null
;
createView
=
null
;
createView
=
null
;
recompileAlways
=
false
;
recompileAlways
=
false
;
indexedParameterList
=
null
;
indexedParameterList
=
suppliedParameterList
;
read
();
read
();
return
parsePrepared
();
return
parsePrepared
();
}
}
...
@@ -4757,7 +4758,7 @@ public class Parser {
...
@@ -4757,7 +4758,7 @@ public class Parser {
}
}
int
id
=
database
.
allocateObjectId
();
int
id
=
database
.
allocateObjectId
();
TableView
view
=
new
TableView
(
schema
,
id
,
tempViewName
,
querySQL
,
TableView
view
=
new
TableView
(
schema
,
id
,
tempViewName
,
querySQL
,
null
,
cols
,
session
,
true
);
parameters
,
cols
,
session
,
true
);
view
.
setTableExpression
(
true
);
view
.
setTableExpression
(
true
);
view
.
setTemporary
(
true
);
view
.
setTemporary
(
true
);
session
.
addLocalTempTable
(
view
);
session
.
addLocalTempTable
(
view
);
...
@@ -6099,6 +6100,10 @@ public class Parser {
...
@@ -6099,6 +6100,10 @@ public class Parser {
this
.
rightsChecked
=
rightsChecked
;
this
.
rightsChecked
=
rightsChecked
;
}
}
public
void
setSuppliedParameterList
(
ArrayList
<
Parameter
>
suppliedParameterList
)
{
this
.
suppliedParameterList
=
suppliedParameterList
;
}
/**
/**
* Parse a SQL code snippet that represents an expression.
* Parse a SQL code snippet that represents an expression.
*
*
...
...
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
076e7531
...
@@ -9,6 +9,7 @@ import java.util.ArrayList;
...
@@ -9,6 +9,7 @@ import java.util.ArrayList;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.Parser
;
import
org.h2.command.Prepared
;
import
org.h2.command.Prepared
;
import
org.h2.command.dml.Query
;
import
org.h2.command.dml.Query
;
import
org.h2.command.dml.SelectUnion
;
import
org.h2.command.dml.SelectUnion
;
...
@@ -184,7 +185,10 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
...
@@ -184,7 +185,10 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
return
new
ViewCursor
(
this
,
recResult
,
first
,
last
);
return
new
ViewCursor
(
this
,
recResult
,
first
,
last
);
}
}
if
(
query
==
null
)
{
if
(
query
==
null
)
{
query
=
(
Query
)
createSession
.
prepare
(
querySQL
,
true
);
Parser
parser
=
new
Parser
(
createSession
);
parser
.
setRightsChecked
(
true
);
parser
.
setSuppliedParameterList
(
originalParameters
);
query
=
(
Query
)
parser
.
prepare
(
querySQL
);
}
}
if
(!
query
.
isUnion
())
{
if
(!
query
.
isUnion
())
{
throw
DbException
.
get
(
ErrorCode
.
SYNTAX_ERROR_2
,
throw
DbException
.
get
(
ErrorCode
.
SYNTAX_ERROR_2
,
...
...
h2/src/main/org/h2/server/web/res/_text_en.prop
浏览文件 @
076e7531
...
@@ -98,6 +98,9 @@ toolbar.autoComplete=Auto complete
...
@@ -98,6 +98,9 @@ toolbar.autoComplete=Auto complete
toolbar.autoComplete.full=Full
toolbar.autoComplete.full=Full
toolbar.autoComplete.normal=Normal
toolbar.autoComplete.normal=Normal
toolbar.autoComplete.off=Off
toolbar.autoComplete.off=Off
toolbar.autoSelect=Auto select
toolbar.autoSelect.off=Off
toolbar.autoSelect.on=On
toolbar.cancelStatement=Cancel the current statement
toolbar.cancelStatement=Cancel the current statement
toolbar.clear=Clear
toolbar.clear=Clear
toolbar.commit=Commit
toolbar.commit=Commit
...
...
h2/src/main/org/h2/server/web/res/_text_pt_br.prop
浏览文件 @
076e7531
...
@@ -98,6 +98,9 @@ toolbar.autoComplete=Auto complete
...
@@ -98,6 +98,9 @@ toolbar.autoComplete=Auto complete
toolbar.autoComplete.full=Total
toolbar.autoComplete.full=Total
toolbar.autoComplete.normal=Normal
toolbar.autoComplete.normal=Normal
toolbar.autoComplete.off=Desligado
toolbar.autoComplete.off=Desligado
toolbar.autoSelect=Auto seleção
toolbar.autoSelect.off=Desligado
toolbar.autoSelect.on=Ligado
toolbar.cancelStatement=Cancelar o comando que está em execução
toolbar.cancelStatement=Cancelar o comando que está em execução
toolbar.clear=Limpar
toolbar.clear=Limpar
toolbar.commit=Commit
toolbar.commit=Commit
...
...
h2/src/main/org/h2/server/web/res/header.jsp
浏览文件 @
076e7531
...
@@ -128,6 +128,18 @@ Initial Developer: H2 Group
...
@@ -128,6 +128,18 @@ Initial Developer: H2 Group
<option
value=
"2"
>
<option
value=
"2"
>
${text.toolbar.autoComplete.full}
${text.toolbar.autoComplete.full}
</option>
</option>
</select>
</td>
<td
class=
"toolbar"
>
${text.toolbar.autoSelect}
<select
name=
"autoSelect"
size=
"1"
onchange=
"javascript:parent.h2query.setAutoSelect(this.value)"
>
<option
value=
"0"
>
${text.toolbar.autoSelect.off}
</option>
<option
selected=
"selected"
value=
"1"
>
${text.toolbar.autoSelect.on}
</option>
</select>
</select>
</td>
</td>
<td
class=
"toolbar"
>
<td
class=
"toolbar"
>
...
...
h2/src/main/org/h2/server/web/res/query.jsp
浏览文件 @
076e7531
...
@@ -15,6 +15,7 @@ Initial Developer: H2 Group
...
@@ -15,6 +15,7 @@ Initial Developer: H2 Group
var
agent
=
navigator
.
userAgent
.
toLowerCase
();
var
agent
=
navigator
.
userAgent
.
toLowerCase
();
var
is_opera
=
agent
.
indexOf
(
"opera"
)
>=
0
;
var
is_opera
=
agent
.
indexOf
(
"opera"
)
>=
0
;
var
autoComplete
=
0
;
// 0: off, 1: normal, 2: full
var
autoComplete
=
0
;
// 0: off, 1: normal, 2: full
var
autoSelect
=
1
;
// 0: off, 1: on
var
selectedRow
=
-
1
;
var
selectedRow
=
-
1
;
var
lastList
=
''
;
var
lastList
=
''
;
var
lastQuery
=
null
;
var
lastQuery
=
null
;
...
@@ -294,6 +295,10 @@ function setAutoComplete(value) {
...
@@ -294,6 +295,10 @@ function setAutoComplete(value) {
}
}
}
}
function
setAutoSelect
(
value
)
{
autoSelect
=
value
;
}
function
manualAutoComplete
()
{
function
manualAutoComplete
()
{
autoCompleteManual
=
true
;
autoCompleteManual
=
true
;
lastQuery
=
null
;
lastQuery
=
null
;
...
@@ -471,7 +476,13 @@ function submitSelected() {
...
@@ -471,7 +476,13 @@ function submitSelected() {
var
field
=
document
.
h2query
.
sql
;
var
field
=
document
.
h2query
.
sql
;
//alert('contents ' + field.selectionStart + ' ' + field.selectionEnd);
//alert('contents ' + field.selectionStart + ' ' + field.selectionEnd);
if
(
field
.
selectionStart
==
field
.
selectionEnd
)
{
if
(
field
.
selectionStart
==
field
.
selectionEnd
)
{
return
;
if
(
autoSelect
==
0
)
{
return
;
}
doAutoSelect
();
if
(
field
.
selectionStart
==
field
.
selectionEnd
)
{
return
;
}
}
}
var
startPos
=
field
.
selectionStart
;
var
startPos
=
field
.
selectionStart
;
var
endPos
=
field
.
selectionEnd
;
var
endPos
=
field
.
selectionEnd
;
...
@@ -480,6 +491,20 @@ function submitSelected() {
...
@@ -480,6 +491,20 @@ function submitSelected() {
document
.
h2querysubmit
.
submit
();
document
.
h2querysubmit
.
submit
();
}
}
function
doAutoSelect
()
{
var
field
=
document
.
h2query
.
sql
;
var
position
=
field
.
selectionStart
;
try
{
var
prevDoubleLine
=
field
.
value
.
lastIndexOf
(
'
\
n
\
n'
,
position
-
1
)
+
2
;
if
(
prevDoubleLine
==
1
)
prevDoubleLine
=
0
;
var
nextDoubleLine
=
field
.
value
.
indexOf
(
'
\
n
\
n'
,
position
);
if
(
nextDoubleLine
==
-
1
)
nextDoubleLine
=
field
.
value
.
length
;
field
.
setSelectionRange
(
prevDoubleLine
,
nextDoubleLine
);
}
catch
(
e
)
{
field
.
selectionStart
=
field
.
selectionEnd
=
position
;
}
}
//-->
//-->
</script>
</script>
</head>
</head>
...
...
h2/src/test/org/h2/test/db/TestRecursiveQueries.java
浏览文件 @
076e7531
...
@@ -123,6 +123,21 @@ public class TestRecursiveQueries extends TestBase {
...
@@ -123,6 +123,21 @@ public class TestRecursiveQueries extends TestBase {
assertEquals
(
103
,
rs
.
getInt
(
1
));
assertEquals
(
103
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
prep
=
conn
.
prepareStatement
(
"with recursive t(n) as "
+
"(select ? union all select n+? from t where n<?) "
+
"select * from t"
);
prep
.
setInt
(
1
,
10
);
prep
.
setInt
(
2
,
2
);
prep
.
setInt
(
3
,
14
);
rs
=
prep
.
executeQuery
();
assertResultSetOrdered
(
rs
,
new
String
[][]{{
"10"
},
{
"12"
},
{
"14"
}});
prep
.
setInt
(
1
,
100
);
prep
.
setInt
(
2
,
3
);
prep
.
setInt
(
3
,
103
);
rs
=
prep
.
executeQuery
();
assertResultSetOrdered
(
rs
,
new
String
[][]{{
"100"
},
{
"103"
}});
conn
.
close
();
conn
.
close
();
deleteDb
(
"recursiveQueries"
);
deleteDb
(
"recursiveQueries"
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论