Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
c492c76c
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c492c76c
编写于
8月 24, 2019
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#6523 SQL parameters ignore support
上级
be7a12a3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
14 deletion
+42
-14
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
...s.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
+5
-3
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/dialogs/SQLQueryParameterBindDialog.java
...r/ui/editors/sql/dialogs/SQLQueryParameterBindDialog.java
+17
-0
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/execute/SQLQueryJob.java
...org/jkiss/dbeaver/ui/editors/sql/execute/SQLQueryJob.java
+20
-11
未找到文件。
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
浏览文件 @
c492c76c
...
@@ -1582,7 +1582,7 @@ public class SQLEditor extends SQLEditorBase implements
...
@@ -1582,7 +1582,7 @@ public class SQLEditor extends SQLEditorBase implements
}
}
// Transform query parameters
// Transform query parameters
if
(
sqlQuery
!=
null
)
{
if
(
sqlQuery
!=
null
)
{
new
SQLQueryJob
(
SQLQueryJob
queryJob
=
new
SQLQueryJob
(
getSite
(),
getSite
(),
"Plan query"
,
"Plan query"
,
getExecutionContext
(),
getExecutionContext
(),
...
@@ -1590,8 +1590,10 @@ public class SQLEditor extends SQLEditorBase implements
...
@@ -1590,8 +1590,10 @@ public class SQLEditor extends SQLEditorBase implements
Collections
.
emptyList
(),
Collections
.
emptyList
(),
this
.
globalScriptContext
,
this
.
globalScriptContext
,
null
,
null
,
null
)
null
);
.
transformQueryWithParameters
(
sqlQuery
);
if
(!
queryJob
.
transformQueryWithParameters
(
sqlQuery
))
{
return
null
;
}
}
}
ExplainPlanViewer
planView
=
null
;
ExplainPlanViewer
planView
=
null
;
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/dialogs/SQLQueryParameterBindDialog.java
浏览文件 @
c492c76c
...
@@ -16,11 +16,13 @@
...
@@ -16,11 +16,13 @@
*/
*/
package
org.jkiss.dbeaver.ui.editors.sql.dialogs
;
package
org.jkiss.dbeaver.ui.editors.sql.dialogs
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.dialogs.IDialogSettings
;
import
org.eclipse.jface.dialogs.StatusDialog
;
import
org.eclipse.jface.dialogs.StatusDialog
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.*
;
import
org.eclipse.swt.events.*
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.*
;
import
org.eclipse.swt.widgets.*
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.sql.SQLQueryParameter
;
import
org.jkiss.dbeaver.model.sql.SQLQueryParameter
;
...
@@ -198,6 +200,21 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
...
@@ -198,6 +200,21 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
}
}
}
}
@Override
protected
void
createButtonsForButtonBar
(
Composite
parent
)
{
Button
skipButton
=
UIUtils
.
createDialogButton
(
parent
,
IDialogConstants
.
IGNORE_LABEL
,
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
setReturnCode
(
IDialogConstants
.
IGNORE_ID
);
close
();
}
});
skipButton
.
setToolTipText
(
"Ignore parameters and execute query/script as is"
);
((
GridLayout
)
parent
.
getLayout
()).
numColumns
++;
super
.
createButtonsForButtonBar
(
parent
);
}
@Override
@Override
protected
void
okPressed
()
protected
void
okPressed
()
{
{
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/execute/SQLQueryJob.java
浏览文件 @
c492c76c
...
@@ -111,6 +111,7 @@ public class SQLQueryJob extends DataSourceJob
...
@@ -111,6 +111,7 @@ public class SQLQueryJob extends DataSourceJob
private
boolean
skipConfirmation
;
private
boolean
skipConfirmation
;
private
int
fetchSize
;
private
int
fetchSize
;
private
long
readFlags
;
private
long
readFlags
;
private
boolean
ignoreParameters
;
public
SQLQueryJob
(
public
SQLQueryJob
(
@NotNull
IWorkbenchPartSite
partSite
,
@NotNull
IWorkbenchPartSite
partSite
,
...
@@ -619,6 +620,10 @@ public class SQLQueryJob extends DataSourceJob
...
@@ -619,6 +620,10 @@ public class SQLQueryJob extends DataSourceJob
}
}
public
boolean
prepareStatementParameters
(
SQLQuery
sqlStatement
)
{
public
boolean
prepareStatementParameters
(
SQLQuery
sqlStatement
)
{
if
(
ignoreParameters
)
{
return
true
;
}
// Bind parameters
// Bind parameters
List
<
SQLQueryParameter
>
parameters
=
sqlStatement
.
getParameters
();
List
<
SQLQueryParameter
>
parameters
=
sqlStatement
.
getParameters
();
if
(
CommonUtils
.
isEmpty
(
parameters
))
{
if
(
CommonUtils
.
isEmpty
(
parameters
))
{
...
@@ -632,6 +637,9 @@ public class SQLQueryJob extends DataSourceJob
...
@@ -632,6 +637,9 @@ public class SQLQueryJob extends DataSourceJob
}
}
}
}
if
(
ignoreParameters
)
{
return
true
;
}
// Set values for all parameters
// Set values for all parameters
// Replace parameter tokens with parameter values
// Replace parameter tokens with parameter values
String
query
=
sqlStatement
.
getText
();
String
query
=
sqlStatement
.
getText
();
...
@@ -670,17 +678,14 @@ public class SQLQueryJob extends DataSourceJob
...
@@ -670,17 +678,14 @@ public class SQLQueryJob extends DataSourceJob
return
true
;
return
true
;
}
}
boolean
okPressed
=
new
UIConfirmation
()
{
int
paramsResult
=
UITask
.
run
(()
->
{
@Override
SQLQueryParameterBindDialog
dialog
=
new
SQLQueryParameterBindDialog
(
public
Boolean
runTask
()
{
partSite
.
getShell
(),
SQLQueryParameterBindDialog
dialog
=
new
SQLQueryParameterBindDialog
(
parameters
);
partSite
.
getShell
(),
return
dialog
.
open
();
parameters
);
});
return
(
dialog
.
open
()
==
IDialogConstants
.
OK_ID
);
}
}.
execute
();
if
(
okPressed
)
{
if
(
paramsResult
==
IDialogConstants
.
OK_ID
)
{
// Save values back to script context
// Save values back to script context
for
(
SQLQueryParameter
param
:
parameters
)
{
for
(
SQLQueryParameter
param
:
parameters
)
{
if
(
param
.
isNamed
()
&&
scriptContext
.
hasVariable
(
param
.
getVarName
()))
{
if
(
param
.
isNamed
()
&&
scriptContext
.
hasVariable
(
param
.
getVarName
()))
{
...
@@ -688,8 +693,12 @@ public class SQLQueryJob extends DataSourceJob
...
@@ -688,8 +693,12 @@ public class SQLQueryJob extends DataSourceJob
scriptContext
.
setVariable
(
param
.
getVarName
(),
strValue
);
scriptContext
.
setVariable
(
param
.
getVarName
(),
strValue
);
}
}
}
}
return
true
;
}
else
if
(
paramsResult
==
IDialogConstants
.
IGNORE_ID
)
{
ignoreParameters
=
true
;
return
true
;
}
}
return
okPressed
;
return
false
;
}
}
private
boolean
fetchQueryData
(
DBCSession
session
,
DBCResultSet
resultSet
,
SQLQueryResult
result
,
SQLQueryResult
.
ExecuteResult
executeResult
,
DBDDataReceiver
dataReceiver
,
boolean
updateStatistics
)
private
boolean
fetchQueryData
(
DBCSession
session
,
DBCResultSet
resultSet
,
SQLQueryResult
result
,
SQLQueryResult
.
ExecuteResult
executeResult
,
DBDDataReceiver
dataReceiver
,
boolean
updateStatistics
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录