Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
491f515e
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,发现更多精彩内容 >>
提交
491f515e
编写于
12月 14, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#5172 PG isolated context reinit. QM model update (context reinitialization)
Former-commit-id:
23e1f708
上级
134f5eac
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
26 deletion
+46
-26
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreExecutionContext.java
...dbeaver/ext/postgresql/model/PostgreExecutionContext.java
+12
-2
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/JDBCExecutionContext.java
...g/jkiss/dbeaver/model/impl/jdbc/JDBCExecutionContext.java
+19
-10
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/meta/QMMSessionInfo.java
...l/src/org/jkiss/dbeaver/model/qm/meta/QMMSessionInfo.java
+12
-7
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/qm/QMMCollectorImpl.java
...el/src/org/jkiss/dbeaver/runtime/qm/QMMCollectorImpl.java
+1
-1
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
+2
-6
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreExecutionContext.java
浏览文件 @
491f515e
...
...
@@ -84,11 +84,21 @@ public class PostgreExecutionContext extends JDBCExecutionContext implements DBC
return
true
;
}
// FIXME: Now it changes default database for entire datasource. Perhaps we need to change it only for current editor?
@Override
public
void
setDefaultCatalog
(
DBRProgressMonitor
monitor
,
PostgreDatabase
catalog
,
PostgreSchema
schema
)
throws
DBCException
{
PostgreDataSource
dataSource
=
getDefaultCatalog
().
getDataSource
();
PostgreDatabase
defaultInstance
=
dataSource
.
getDefaultInstance
();
try
{
getDefaultCatalog
().
getDataSource
().
setDefaultInstance
(
monitor
,
catalog
,
schema
);
if
(
defaultInstance
.
getDefaultContext
()
==
this
)
{
dataSource
.
setDefaultInstance
(
monitor
,
catalog
,
schema
);
}
else
{
disconnect
();
setOwnerInstance
(
catalog
);
connect
(
monitor
,
null
,
null
,
false
,
false
);
if
(
schema
!=
null
)
{
setDefaultSchema
(
monitor
,
schema
);
}
}
}
catch
(
DBException
e
)
{
throw
new
DBCException
(
"Error changing default database"
,
e
);
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/JDBCExecutionContext.java
浏览文件 @
491f515e
...
...
@@ -67,6 +67,10 @@ public class JDBCExecutionContext extends AbstractExecutionContext<JDBCDataSourc
return
instance
;
}
protected
void
setOwnerInstance
(
@NotNull
JDBCRemoteInstance
instance
)
{
this
.
instance
=
instance
;
}
@NotNull
private
Connection
getConnection
()
{
return
connection
;
...
...
@@ -76,7 +80,7 @@ public class JDBCExecutionContext extends AbstractExecutionContext<JDBCDataSourc
connect
(
monitor
,
null
,
null
,
false
,
true
);
}
void
connect
(
@NotNull
DBRProgressMonitor
monitor
,
Boolean
autoCommit
,
@Nullable
Integer
txnLevel
,
boolean
forceActiveObject
,
boolean
addContext
)
throws
DBCException
{
protected
void
connect
(
@NotNull
DBRProgressMonitor
monitor
,
Boolean
autoCommit
,
@Nullable
Integer
txnLevel
,
boolean
forceActiveObject
,
boolean
addContext
)
throws
DBCException
{
if
(
connection
!=
null
&&
addContext
)
{
log
.
error
(
"Reopening not-closed connection"
);
close
();
...
...
@@ -157,6 +161,19 @@ public class JDBCExecutionContext extends AbstractExecutionContext<JDBCDataSourc
}
}
protected
void
disconnect
()
{
// [JDBC] Need sync here because real connection close could take some time
// while UI may invoke callbacks to operate with connection
synchronized
(
this
)
{
if
(
this
.
connection
!=
null
)
{
this
.
dataSource
.
closeConnection
(
connection
,
purpose
);
}
this
.
connection
=
null
;
}
// Notify QM
super
.
closeContext
();
}
@NotNull
public
Connection
getConnection
(
DBRProgressMonitor
monitor
)
throws
SQLException
{
if
(
connection
==
null
)
{
...
...
@@ -223,15 +240,7 @@ public class JDBCExecutionContext extends AbstractExecutionContext<JDBCDataSourc
}
private
void
closeContext
(
boolean
removeContext
)
{
// [JDBC] Need sync here because real connection close could take some time
// while UI may invoke callbacks to operate with connection
synchronized
(
this
)
{
if
(
this
.
connection
!=
null
)
{
this
.
dataSource
.
closeConnection
(
connection
,
purpose
);
}
this
.
connection
=
null
;
super
.
closeContext
();
}
disconnect
();
if
(
removeContext
)
{
// Remove self from context list
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/qm/meta/QMMSessionInfo.java
浏览文件 @
491f515e
...
...
@@ -29,12 +29,12 @@ import org.jkiss.utils.CommonUtils;
public
class
QMMSessionInfo
extends
QMMObject
{
private
final
String
containerId
;
private
final
String
containerName
;
private
final
String
driverId
;
private
String
containerName
;
@Nullable
private
final
DBPConnectionConfiguration
connectionConfiguration
;
private
final
String
instanceId
;
private
final
String
contextName
;
private
DBPConnectionConfiguration
connectionConfiguration
;
private
String
instanceId
;
private
String
contextName
;
@Nullable
private
SQLDialect
sqlDialect
;
private
boolean
transactional
;
...
...
@@ -47,8 +47,13 @@ public class QMMSessionInfo extends QMMObject {
public
QMMSessionInfo
(
DBCExecutionContext
context
,
boolean
transactional
)
{
this
.
containerId
=
context
.
getDataSource
().
getContainer
().
getId
();
this
.
containerName
=
context
.
getDataSource
().
getContainer
().
getName
();
this
.
driverId
=
context
.
getDataSource
().
getContainer
().
getDriver
().
getId
();
initFromContext
(
context
,
transactional
);
}
private
void
initFromContext
(
DBCExecutionContext
context
,
boolean
transactional
)
{
this
.
containerName
=
context
.
getDataSource
().
getContainer
().
getName
();
this
.
connectionConfiguration
=
context
.
getDataSource
().
getContainer
().
getConnectionConfiguration
();
this
.
instanceId
=
context
.
getOwnerInstance
().
getName
();
this
.
contextName
=
context
.
getContextName
();
...
...
@@ -89,8 +94,8 @@ public class QMMSessionInfo extends QMMObject {
super
.
close
();
}
public
void
reopen
(
)
{
public
void
reopen
(
DBCExecutionContext
context
)
{
initFromContext
(
context
,
transactional
);
super
.
reopen
();
}
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/runtime/qm/QMMCollectorImpl.java
浏览文件 @
491f515e
...
...
@@ -173,7 +173,7 @@ public class QMMCollectorImpl extends DefaultExecutionHandler implements QMMColl
}
else
{
// This session may already be in cache in case of reconnect/invalidate
// (when context closed and reopened without new context object creation)
session
.
reopen
();
session
.
reopen
(
context
);
}
// Remove from closed sessions (in case of re-opened connection)
...
...
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLEditor.java
浏览文件 @
491f515e
...
...
@@ -116,8 +116,8 @@ import org.jkiss.utils.CommonUtils;
import
java.io.*
;
import
java.net.URI
;
import
java.util.List
;
import
java.util.*
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -370,11 +370,7 @@ public class SQLEditor extends SQLEditorBase implements
final
DBPDataSource
dataSource
=
dataSourceContainer
.
getDataSource
();
if
(
dataSource
==
null
)
{
releaseExecutionContext
();
}
else
if
(
curDataSource
!=
dataSource
||
(
curDataSource
.
getContainer
().
getPreferenceStore
().
getBoolean
(
SQLPreferenceConstants
.
EDITOR_SEPARATE_CONNECTION
)
&&
executionContext
!=
null
&&
curDataSource
.
getDefaultInstance
()
!=
executionContext
.
getOwnerInstance
()))
{
}
else
if
(
curDataSource
!=
dataSource
)
{
// Datasource was changed or instance was changed (PG)
releaseExecutionContext
();
curDataSource
=
dataSource
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录