Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
13cc74ae
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,发现更多精彩内容 >>
提交
13cc74ae
编写于
9月 25, 2020
作者:
N
Nikita Akilov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#9518 add role choosing to pg
Former-commit-id:
8ea4b44f
上级
59a86a1f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
19 deletion
+36
-19
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPage.java
...kiss/dbeaver/ext/postgresql/ui/PostgreConnectionPage.java
+12
-1
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/PostgreConstants.java
...rc/org/jkiss/dbeaver/ext/postgresql/PostgreConstants.java
+1
-0
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataSource.java
...jkiss/dbeaver/ext/postgresql/model/PostgreDataSource.java
+10
-15
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreExecutionContext.java
...dbeaver/ext/postgresql/model/PostgreExecutionContext.java
+13
-3
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/PostgreConnectionPage.java
浏览文件 @
13cc74ae
...
...
@@ -49,6 +49,7 @@ public class PostgreConnectionPage extends ConnectionPageWithAuth implements ICo
private
Text
hostText
;
private
Text
portText
;
private
Text
dbText
;
private
Text
roleText
;
private
ClientHomesSelector
homesSelector
;
private
boolean
activated
=
false
;
...
...
@@ -100,6 +101,11 @@ public class PostgreConnectionPage extends ConnectionPageWithAuth implements ICo
Group
advancedGroup
=
UIUtils
.
createControlGroup
(
mainGroup
,
"Advanced"
,
2
,
GridData
.
HORIZONTAL_ALIGN_BEGINNING
,
0
);
roleText
=
UIUtils
.
createLabelText
(
advancedGroup
,
"Role"
,
null
,
SWT
.
BORDER
);
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
|
GridData
.
HORIZONTAL_ALIGN_BEGINNING
);
roleText
.
setLayoutData
(
gd
);
roleText
.
addModifyListener
(
textListener
);
homesSelector
=
new
ClientHomesSelector
(
advancedGroup
,
PostgreMessages
.
dialog_setting_connection_localClient
,
false
);
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
|
GridData
.
HORIZONTAL_ALIGN_BEGINNING
);
homesSelector
.
getPanel
().
setLayoutData
(
gd
);
...
...
@@ -156,6 +162,9 @@ public class PostgreConnectionPage extends ConnectionPageWithAuth implements ICo
}
dbText
.
setText
(
databaseName
);
}
if
(
roleText
!=
null
)
{
roleText
.
setText
(
CommonUtils
.
notEmpty
(
connectionInfo
.
getProviderProperty
(
PostgreConstants
.
PROP_CHOSEN_ROLE
)));
}
homesSelector
.
populateHomes
(
driver
,
connectionInfo
.
getClientHomeId
(),
site
.
isNew
());
activated
=
true
;
...
...
@@ -174,6 +183,9 @@ public class PostgreConnectionPage extends ConnectionPageWithAuth implements ICo
if
(
dbText
!=
null
)
{
connectionInfo
.
setDatabaseName
(
dbText
.
getText
().
trim
());
}
if
(
roleText
!=
null
)
{
connectionInfo
.
setProviderProperty
(
PostgreConstants
.
PROP_CHOSEN_ROLE
,
roleText
.
getText
().
trim
());
}
if
(
homesSelector
!=
null
)
{
connectionInfo
.
setClientHomeId
(
homesSelector
.
getSelectedHome
());
}
...
...
@@ -189,5 +201,4 @@ public class PostgreConnectionPage extends ConnectionPageWithAuth implements ICo
new
DriverPropertiesDialogPage
(
this
)
};
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/PostgreConstants.java
浏览文件 @
13cc74ae
...
...
@@ -38,6 +38,7 @@ public class PostgreConstants {
public
static
final
String
DEFAULT_DATA_TYPE
=
"varchar"
;
public
static
final
String
DEFAULT_USER
=
"postgres"
;
public
static
final
String
PROP_CHOSEN_ROLE
=
DBConstants
.
INTERNAL_PROP_PREFIX
+
"chosen-role@"
;
public
static
final
String
PROP_SHOW_NON_DEFAULT_DB
=
DBConstants
.
INTERNAL_PROP_PREFIX
+
"show-non-default-db@"
;
public
static
final
String
PROP_SHOW_UNAVAILABLE_DB
=
DBConstants
.
INTERNAL_PROP_PREFIX
+
"show-unavailable-db@"
;
public
static
final
String
PROP_SHOW_TEMPLATES_DB
=
DBConstants
.
INTERNAL_PROP_PREFIX
+
"show-template-db@"
;
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataSource.java
浏览文件 @
13cc74ae
...
...
@@ -186,7 +186,7 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
return
props
;
}
private
void
initServerSSL
(
Map
<
String
,
String
>
props
,
DBWHandlerConfiguration
sslConfig
)
throws
Exception
{
private
void
initServerSSL
(
Map
<
String
,
String
>
props
,
DBWHandlerConfiguration
sslConfig
)
{
props
.
put
(
PostgreConstants
.
PROP_SSL
,
"true"
);
final
String
rootCertProp
=
sslConfig
.
getStringProperty
(
PostgreConstants
.
PROP_SSL_ROOT_CERT
);
...
...
@@ -213,7 +213,7 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
props
.
put
(
"sslpasswordcallback"
,
DefaultCallbackHandler
.
class
.
getName
());
}
private
void
initProxySSL
(
Map
<
String
,
String
>
props
,
DBWHandlerConfiguration
sslConfig
)
throws
Exception
{
private
void
initProxySSL
(
Map
<
String
,
String
>
props
,
DBWHandlerConfiguration
sslConfig
)
{
// No special config
//initServerSSL(props, sslConfig);
}
...
...
@@ -231,6 +231,8 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
((
PostgreExecutionContext
)
context
).
setDefaultSchema
(
monitor
,
activeSchema
);
}
}
final
String
roleName
=
getContainer
().
getConnectionConfiguration
().
getProviderProperty
(
PostgreConstants
.
PROP_CHOSEN_ROLE
);
((
PostgreExecutionContext
)
context
).
useRoleWithName
(
monitor
,
roleName
);
}
public
DatabaseCache
getDatabaseCache
()
...
...
@@ -282,24 +284,18 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
}
@Override
public
Collection
<?
extends
PostgreDatabase
>
getChildren
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
public
Collection
<?
extends
PostgreDatabase
>
getChildren
(
@NotNull
DBRProgressMonitor
monitor
)
{
return
getDatabases
();
}
@Override
public
PostgreDatabase
getChild
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
String
childName
)
throws
DBException
{
public
PostgreDatabase
getChild
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
String
childName
)
{
return
getDatabase
(
childName
);
}
@NotNull
@Override
public
Class
<?
extends
PostgreDatabase
>
getPrimaryChildType
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
public
Class
<?
extends
PostgreDatabase
>
getPrimaryChildType
(
@NotNull
DBRProgressMonitor
monitor
)
{
return
PostgreDatabase
.
class
;
}
...
...
@@ -333,9 +329,9 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
if
(
CommonUtils
.
isEmpty
(
conConfig
.
getUrl
())
||
!
CommonUtils
.
isEmpty
(
conConfig
.
getHostName
()))
{
conConfig
.
setDatabaseName
(
instance
.
getName
());
conConfig
.
setUrl
(
getContainer
().
getDriver
().
getDataSourceProvider
().
getConnectionURL
(
getContainer
().
getDriver
(),
conConfig
));
}
else
{
}
//
else {
//String url = conConfig.getUrl();
}
//
}
pgConnection
=
super
.
openConnection
(
monitor
,
context
,
purpose
);
}
...
...
@@ -585,7 +581,7 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
}
}
private
Pattern
ERROR_POSITION_PATTERN
=
Pattern
.
compile
(
"\\n\\s*\\p{L}+\\s*: ([0-9]+)"
);
private
final
Pattern
ERROR_POSITION_PATTERN
=
Pattern
.
compile
(
"\\n\\s*\\p{L}+\\s*: ([0-9]+)"
);
@Nullable
@Override
...
...
@@ -654,5 +650,4 @@ public class PostgreDataSource extends JDBCDataSource implements DBSInstanceCont
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreExecutionContext.java
浏览文件 @
13cc74ae
...
...
@@ -19,7 +19,6 @@ package org.jkiss.dbeaver.ext.postgresql.model;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreConstants
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
...
...
@@ -29,6 +28,7 @@ import org.jkiss.dbeaver.model.exec.DBCExecutionPurpose;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
...
...
@@ -43,8 +43,6 @@ import java.util.List;
* PostgreExecutionContext
*/
public
class
PostgreExecutionContext
extends
JDBCExecutionContext
implements
DBCExecutionContextDefaults
<
PostgreDatabase
,
PostgreSchema
>
{
private
static
final
Log
log
=
Log
.
getLog
(
PostgreExecutionContext
.
class
);
private
PostgreSchema
activeSchema
;
private
final
List
<
String
>
searchPath
=
new
ArrayList
<>();
private
List
<
String
>
defaultSearchPath
=
new
ArrayList
<>();
...
...
@@ -244,4 +242,16 @@ public class PostgreExecutionContext extends JDBCExecutionContext implements DBC
}
}
void
useRoleWithName
(
final
DBRProgressMonitor
monitor
,
String
roleName
)
throws
DBCException
{
if
(
roleName
==
null
||
roleName
.
isEmpty
())
{
roleName
=
"NONE"
;
}
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active role"
))
{
try
(
JDBCStatement
dbStat
=
session
.
createStatement
())
{
dbStat
.
executeUpdate
(
"SET ROLE "
+
roleName
);
}
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
this
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录