Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
见谅
dbeaver
提交
bfaad6ed
D
dbeaver
项目概览
见谅
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
6
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,体验更适合开发者的 AI 搜索 >>
提交
bfaad6ed
编写于
2月 10, 2021
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/devel' into devel
上级
ca0adb35
a34dcd8c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
95 addition
and
117 deletion
+95
-117
plugins/org.jkiss.dbeaver.data.transfer.ui/src/org/jkiss/dbeaver/tools/transfer/ui/pages/database/ColumnsMappingDialog.java
...ools/transfer/ui/pages/database/ColumnsMappingDialog.java
+4
-4
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/config/PostgreProcedureConfigurator.java
...xt/postgresql/ui/config/PostgreProcedureConfigurator.java
+2
-2
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreAttribute.java
.../jkiss/dbeaver/ext/postgresql/model/PostgreAttribute.java
+1
-1
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataType.java
...g/jkiss/dbeaver/ext/postgresql/model/PostgreDataType.java
+30
-16
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataTypeCache.java
...ss/dbeaver/ext/postgresql/model/PostgreDataTypeCache.java
+28
-27
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDatabase.java
...g/jkiss/dbeaver/ext/postgresql/model/PostgreDatabase.java
+12
-51
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreProcedure.java
.../jkiss/dbeaver/ext/postgresql/model/PostgreProcedure.java
+1
-1
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java
...org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java
+12
-10
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCTableColumn.java
...jkiss/dbeaver/model/impl/jdbc/struct/JDBCTableColumn.java
+3
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/struct/DBStructUtils.java
...del/src/org/jkiss/dbeaver/model/struct/DBStructUtils.java
+2
-2
未找到文件。
plugins/org.jkiss.dbeaver.data.transfer.ui/src/org/jkiss/dbeaver/tools/transfer/ui/pages/database/ColumnsMappingDialog.java
浏览文件 @
bfaad6ed
...
...
@@ -277,13 +277,13 @@ class ColumnsMappingDialog extends BaseDialog {
DatabaseMappingAttribute
attrMapping
=
(
DatabaseMappingAttribute
)
element
;
Set
<
String
>
types
=
new
TreeSet
<>();
DBPData
Source
dataSource
=
settings
.
getTargetDataSource
(
attrMapping
);
if
(
data
Source
instanceof
DBPDataTypeProvider
)
{
for
(
DBSDataType
type
:
((
DBPDataTypeProvider
)
dataSource
)
.
getLocalDataTypes
())
{
DBPData
TypeProvider
dataTypeProvider
=
DBUtils
.
getParentOfType
(
DBPDataTypeProvider
.
class
,
settings
.
getContainer
()
);
if
(
data
TypeProvider
!=
null
)
{
for
(
DBSDataType
type
:
dataTypeProvider
.
getLocalDataTypes
())
{
types
.
add
(
type
.
getName
());
}
}
types
.
add
(
attrMapping
.
getTargetType
(
dataSource
,
true
));
types
.
add
(
attrMapping
.
getTargetType
(
settings
.
getTargetDataSource
(
attrMapping
)
,
true
));
return
new
CustomComboBoxCellEditor
(
mappingViewer
,
mappingViewer
.
getTable
(),
types
.
toArray
(
new
String
[
0
]),
SWT
.
BORDER
);
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.ui/src/org/jkiss/dbeaver/ext/postgresql/ui/config/PostgreProcedureConfigurator.java
浏览文件 @
bfaad6ed
...
...
@@ -130,7 +130,7 @@ public class PostgreProcedureConfigurator implements DBEObjectConfigurator<Postg
languageCombo
.
setText
(
"sql"
);
}
{
List
<
PostgreDataType
>
dataTypes
=
new
ArrayList
<>(
parent
.
getDatabase
().
get
DataSource
().
get
LocalDataTypes
());
List
<
PostgreDataType
>
dataTypes
=
new
ArrayList
<>(
parent
.
getDatabase
().
getLocalDataTypes
());
returnTypeCombo
=
UIUtils
.
createLabelCombo
(
group
,
"Return type"
,
SWT
.
DROP_DOWN
);
for
(
PostgreDataType
dt
:
dataTypes
)
{
returnTypeCombo
.
add
(
dt
.
getName
());
...
...
@@ -139,7 +139,7 @@ public class PostgreProcedureConfigurator implements DBEObjectConfigurator<Postg
returnTypeCombo
.
addModifyListener
(
e
->
{
String
dtName
=
returnTypeCombo
.
getText
();
if
(!
CommonUtils
.
isEmpty
(
dtName
))
{
returnType
=
parent
.
getDatabase
().
get
DataSource
().
get
LocalDataType
(
dtName
);
returnType
=
parent
.
getDatabase
().
getLocalDataType
(
dtName
);
}
else
{
returnType
=
null
;
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreAttribute.java
浏览文件 @
bfaad6ed
...
...
@@ -395,7 +395,7 @@ public abstract class PostgreAttribute<OWNER extends DBSEntity & PostgreObject>
public
Object
[]
getPossibleValues
(
PostgreAttribute
column
)
{
Set
<
PostgreDataType
>
types
=
new
TreeSet
<>(
Comparator
.
comparing
(
JDBCDataType:
:
getTypeName
));
types
.
addAll
(
column
.
getData
Sourc
e
().
getLocalDataTypes
());
types
.
addAll
(
column
.
getData
bas
e
().
getLocalDataTypes
());
return
types
.
toArray
(
new
PostgreDataType
[
0
]);
}
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataType.java
浏览文件 @
bfaad6ed
...
...
@@ -49,7 +49,7 @@ import java.util.*;
/**
* PostgreTypeType
*/
public
class
PostgreDataType
extends
JDBCDataType
<
Postgre
Schema
>
implements
PostgreClass
,
PostgreScriptObject
,
DBPQualifiedObject
,
DBPImageProvider
public
class
PostgreDataType
extends
JDBCDataType
<
Postgre
Database
>
implements
PostgreClass
,
PostgreScriptObject
,
DBPQualifiedObject
,
DBPImageProvider
{
private
static
final
Log
log
=
Log
.
getLog
(
PostgreDataType
.
class
);
...
...
@@ -75,6 +75,7 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
private
final
boolean
alias
;
private
long
typeId
;
private
PostgreSchema
typeSchema
;
private
PostgreTypeType
typeType
;
private
PostgreTypeCategory
typeCategory
;
private
DBPDataKind
dataKind
;
...
...
@@ -110,10 +111,11 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
private
final
AttributeCache
attributeCache
;
private
Object
[]
enumValues
;
public
PostgreDataType
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Schema
owner
,
long
typeId
,
int
valueType
,
String
name
,
int
length
,
JDBCResultSet
dbResult
)
throws
DBException
{
public
PostgreDataType
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Database
owner
,
PostgreSchema
schema
,
long
typeId
,
int
valueType
,
String
name
,
int
length
,
JDBCResultSet
dbResult
)
throws
DBException
{
super
(
owner
,
valueType
,
name
,
null
,
false
,
true
,
length
,
-
1
,
-
1
);
this
.
typeSchema
=
schema
;
this
.
alias
=
false
;
if
(
owner
.
isCatalogSchema
())
{
if
(
schema
.
isCatalogSchema
())
{
this
.
canonicalName
=
PostgreConstants
.
DATA_TYPE_CANONICAL_NAMES
.
get
(
name
);
}
this
.
typeId
=
typeId
;
...
...
@@ -208,6 +210,8 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
setName
(
aliasName
);
this
.
alias
=
true
;
this
.
typeSchema
=
realType
.
getParentObject
().
getCatalogSchema
();
this
.
typeId
=
realType
.
typeId
;
this
.
typeType
=
realType
.
typeType
;
this
.
typeCategory
=
realType
.
typeCategory
;
...
...
@@ -241,8 +245,9 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
}
@ForTest
PostgreDataType
(
PostgreSchema
schema
,
int
valueType
,
String
name
)
{
super
(
schema
,
valueType
,
name
,
null
,
false
,
false
,
-
1
,
-
1
,
-
1
);
PostgreDataType
(
PostgreDatabase
database
,
int
valueType
,
String
name
)
{
super
(
database
,
valueType
,
name
,
null
,
false
,
false
,
-
1
,
-
1
,
-
1
);
this
.
typeSchema
=
database
.
getCatalogSchema
();
alias
=
false
;
ownerId
=
0
;
attributeCache
=
null
;
...
...
@@ -325,7 +330,7 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
@NotNull
@Override
public
PostgreDatabase
getDatabase
()
{
return
getParentObject
()
.
getDatabase
()
;
return
getParentObject
();
}
@Override
...
...
@@ -580,14 +585,17 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
return
enumValues
;
}
public
PostgreSchema
getTypeSchema
()
{
return
typeSchema
;
}
@NotNull
@Override
public
String
getFullyQualifiedName
(
DBPEvaluationContext
context
)
{
final
PostgreSchema
owner
=
getParentObject
();
if
(
owner
==
null
||
owner
.
getName
().
equals
(
PostgreConstants
.
PUBLIC_SCHEMA_NAME
)
||
owner
.
getName
().
equals
(
PostgreConstants
.
CATALOG_SCHEMA_NAME
))
{
if
(
typeSchema
==
null
||
typeSchema
.
getName
().
equals
(
PostgreConstants
.
PUBLIC_SCHEMA_NAME
)
||
typeSchema
.
getName
().
equals
(
PostgreConstants
.
CATALOG_SCHEMA_NAME
))
{
return
getName
();
}
else
{
return
DBUtils
.
getQuotedIdentifier
(
owner
)
+
"."
+
DBUtils
.
getQuotedIdentifier
(
this
);
return
DBUtils
.
getQuotedIdentifier
(
typeSchema
)
+
"."
+
DBUtils
.
getQuotedIdentifier
(
this
);
}
}
...
...
@@ -650,15 +658,17 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
break
;
}
case
r:
{
sql
.
append
(
"CREATE TYPE "
).
append
(
getFullyQualifiedName
(
DBPEvaluationContext
.
DDL
)).
append
(
" AS RANGE (\n"
);
//$NON-NLS-1$ //$NON-NLS-2$
PostgreCollation
collation
=
getCollationId
(
monitor
);
appendCreateTypeParameter
(
sql
,
"COLLATION "
,
collation
.
getName
());
appendCreateTypeParameter
(
sql
,
"CANONICAL"
,
canonicalName
);
// TODO: read data from pg_range
if
(
collation
!=
null
)
{
sql
.
append
(
"CREATE TYPE "
).
append
(
getFullyQualifiedName
(
DBPEvaluationContext
.
DDL
)).
append
(
" AS RANGE (\n"
);
//$NON-NLS-1$ //$NON-NLS-2$
appendCreateTypeParameter
(
sql
,
"COLLATION "
,
collation
.
getName
());
appendCreateTypeParameter
(
sql
,
"CANONICAL"
,
canonicalName
);
// TODO: read data from pg_range
// if (!CommonUtils.isEmpty(su)) {
// sql.append("\n\tCOLLATION ").append(canonicalName);
// }
sql
.
append
(
");\n"
);
//$NON-NLS-1$
sql
.
append
(
");\n"
);
//$NON-NLS-1$
}
break
;
}
case
b:
{
...
...
@@ -784,7 +794,7 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
this
.
description
=
description
;
}
public
static
PostgreDataType
readDataType
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Schema
schema
,
@NotNull
JDBCResultSet
dbResult
,
boolean
skipTables
)
throws
SQLException
,
DBException
public
static
PostgreDataType
readDataType
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Database
database
,
@NotNull
JDBCResultSet
dbResult
,
boolean
skipTables
)
throws
SQLException
,
DBException
{
//long schemaId = JDBCUtils.safeGetLong(dbResult, "typnamespace");
long
typeId
=
JDBCUtils
.
safeGetLong
(
dbResult
,
"oid"
);
//$NON-NLS-1$
...
...
@@ -994,9 +1004,13 @@ public class PostgreDataType extends JDBCDataType<PostgreSchema> implements Post
return
null
;
}
int
schemaId
=
JDBCUtils
.
safeGetInt
(
dbResult
,
"typnamespace"
);
PostgreSchema
dataTypeSchema
=
database
.
getSchema
(
session
.
getProgressMonitor
(),
schemaId
);
return
new
PostgreDataType
(
session
,
schema
,
database
,
dataTypeSchema
,
typeId
,
valueType
,
name
,
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDataTypeCache.java
浏览文件 @
bfaad6ed
...
...
@@ -40,7 +40,7 @@ import java.util.*;
/**
* PostgreDataTypeCache
*/
public
class
PostgreDataTypeCache
extends
JDBCObjectCache
<
Postgre
Schema
,
PostgreDataType
>
public
class
PostgreDataTypeCache
extends
JDBCObjectCache
<
Postgre
Database
,
PostgreDataType
>
{
private
static
final
Log
log
=
Log
.
getLog
(
PostgreDataTypeCache
.
class
);
...
...
@@ -56,13 +56,13 @@ public class PostgreDataTypeCache extends JDBCObjectCache<PostgreSchema, Postgre
}
@Override
protected
synchronized
void
loadObjects
(
DBRProgressMonitor
monitor
,
Postgre
Schema
schema
)
throws
DBException
{
super
.
loadObjects
(
monitor
,
schema
);
mapAliases
(
schema
);
protected
synchronized
void
loadObjects
(
DBRProgressMonitor
monitor
,
Postgre
Database
database
)
throws
DBException
{
super
.
loadObjects
(
monitor
,
database
);
mapAliases
(
database
);
}
void
loadDefaultTypes
(
Postgre
Schema
schema
)
{
void
loadDefaultTypes
(
Postgre
Database
database
)
{
List
<
PostgreDataType
>
types
=
new
ArrayList
<>();
for
(
Field
oidField
:
PostgreOid
.
class
.
getDeclaredFields
())
{
...
...
@@ -74,12 +74,12 @@ public class PostgreDataTypeCache extends JDBCObjectCache<PostgreSchema, Postgre
String
fieldName
=
oidField
.
getName
().
toLowerCase
(
Locale
.
ENGLISH
);
if
(
fieldName
.
endsWith
(
"_array"
))
{
fieldName
=
fieldName
.
substring
(
0
,
fieldName
.
length
()
-
6
)
+
"_"
;
//PostgreDataType type = new PostgreDataType(
schema
, CommonUtils.toInt(typeId), fieldName);
//PostgreDataType type = new PostgreDataType(
database
, CommonUtils.toInt(typeId), fieldName);
//types.add(type);
// Ignore array types
continue
;
}
else
{
PostgreDataType
type
=
new
PostgreDataType
(
schema
,
CommonUtils
.
toInt
(
typeId
),
fieldName
);
PostgreDataType
type
=
new
PostgreDataType
(
database
,
CommonUtils
.
toInt
(
typeId
),
fieldName
);
types
.
add
(
type
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -88,17 +88,15 @@ public class PostgreDataTypeCache extends JDBCObjectCache<PostgreSchema, Postgre
}
setCache
(
types
);
// Cache aliases
mapAliases
(
schema
);
mapAliases
(
database
);
}
private
void
mapAliases
(
Postgre
Schema
schema
)
{
private
void
mapAliases
(
Postgre
Database
database
)
{
// Cache aliases
if
(
schema
.
isCatalogSchema
())
{
PostgreServerExtension
serverType
=
schema
.
getDataSource
().
getServerType
();
mapDataTypeAliases
(
serverType
.
getDataTypeAliases
(),
false
);
if
(
serverType
.
supportSerialTypes
())
{
mapDataTypeAliases
(
PostgreConstants
.
SERIAL_TYPES
,
true
);
}
PostgreServerExtension
serverType
=
database
.
getDataSource
().
getServerType
();
mapDataTypeAliases
(
serverType
.
getDataTypeAliases
(),
false
);
if
(
serverType
.
supportSerialTypes
())
{
mapDataTypeAliases
(
PostgreConstants
.
SERIAL_TYPES
,
true
);
}
}
...
...
@@ -175,28 +173,29 @@ public class PostgreDataTypeCache extends JDBCObjectCache<PostgreSchema, Postgre
@NotNull
@Override
protected
JDBCStatement
prepareObjectsStatement
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Schema
owner
)
throws
SQLException
{
protected
JDBCStatement
prepareObjectsStatement
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Database
owner
)
throws
SQLException
{
// Initially cache only base types (everything but composite and arrays)
String
sql
=
"SELECT t.oid,t.*,c.relkind,"
+
getBaseTypeNameClause
(
owner
.
getDataSource
())
+
", d.description"
+
"\nFROM pg_catalog.pg_type t"
+
"\nLEFT OUTER JOIN pg_catalog.pg_class c ON c.oid=t.typrelid"
+
"\nLEFT OUTER JOIN pg_catalog.pg_description d ON t.oid=d.objoid"
+
"\nWHERE typnamespace=? "
+
"\nORDER by t.oid"
;
final
JDBCPreparedStatement
dbStat
=
session
.
prepareStatement
(
sql
);
dbStat
.
setLong
(
1
,
owner
.
getObjectId
());
return
dbStat
;
"\nWHERE t.typname IS NOT null"
+
"\nAND t.typcategory <> 'A'"
+
// Do not read array types
"\nAND c.relkind is null or c.relkind = 'c'"
;
// 'c' == custom types
//"\nWHERE typnamespace=? " +
//"\nORDER by t.oid";
return
session
.
prepareStatement
(
sql
);
}
@Override
protected
PostgreDataType
fetchObject
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Schema
owner
,
@NotNull
JDBCResultSet
dbResult
)
throws
SQLException
,
DBException
protected
PostgreDataType
fetchObject
(
@NotNull
JDBCSession
session
,
@NotNull
Postgre
Database
owner
,
@NotNull
JDBCResultSet
dbResult
)
throws
SQLException
,
DBException
{
return
PostgreDataType
.
readDataType
(
session
,
owner
,
dbResult
,
true
);
}
@Override
protected
void
invalidateObjects
(
DBRProgressMonitor
monitor
,
Postgre
Schema
postgreSchema
,
Iterator
<
PostgreDataType
>
objectIter
)
{
protected
void
invalidateObjects
(
DBRProgressMonitor
monitor
,
Postgre
Database
database
,
Iterator
<
PostgreDataType
>
objectIter
)
{
// Resolve value type IDs (#3731)
while
(
objectIter
.
hasNext
())
{
PostgreDataType
dt
=
objectIter
.
next
();
...
...
@@ -224,7 +223,7 @@ public class PostgreDataTypeCache extends JDBCObjectCache<PostgreSchema, Postgre
if
(
schema
==
null
)
{
throw
new
DBException
(
"Schema "
+
schemaOid
+
" not found for data type "
+
oid
);
}
PostgreDataType
dataType
=
PostgreDataType
.
readDataType
(
session
,
schema
,
dbResult
,
false
);
PostgreDataType
dataType
=
PostgreDataType
.
readDataType
(
session
,
database
,
dbResult
,
false
);
if
(
dataType
!=
null
)
{
return
dataType
;
}
...
...
@@ -251,10 +250,12 @@ public class PostgreDataTypeCache extends JDBCObjectCache<PostgreSchema, Postgre
if
(
schema
==
null
)
{
throw
new
DBException
(
"Schema "
+
schemaOid
+
" not found for data type "
+
name
);
}
return
PostgreDataType
.
readDataType
(
session
,
schema
,
dbResult
,
false
);
}
else
{
throw
new
DBException
(
"Data type "
+
name
+
" not found in database "
+
database
.
getName
());
PostgreDataType
dataType
=
PostgreDataType
.
readDataType
(
session
,
database
,
dbResult
,
false
);
if
(
dataType
!=
null
)
{
return
dataType
;
}
}
throw
new
DBException
(
"Data type "
+
name
+
" not found in database "
+
database
.
getName
());
}
}
//dbStat;
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreDatabase.java
浏览文件 @
bfaad6ed
...
...
@@ -97,7 +97,7 @@ public class PostgreDatabase extends JDBCRemoteInstance
public
final
AvailableExtensionCache
availableExtensionCache
=
new
AvailableExtensionCache
();
public
final
CollationCache
collationCache
=
new
CollationCache
();
public
final
TablespaceCache
tablespaceCache
=
new
TablespaceCache
();
public
final
LongKeyMap
<
PostgreDataType
>
dataTypeCache
=
new
LongKeyMap
<>
();
public
final
PostgreDataTypeCache
dataTypeCache
=
new
PostgreDataTypeCache
();
public
JDBCObjectLookupCache
<
PostgreDatabase
,
PostgreSchema
>
schemaCache
;
...
...
@@ -159,7 +159,7 @@ public class PostgreDatabase extends JDBCRemoteInstance
this
.
name
=
databaseName
;
this
.
initCaches
();
PostgreSchema
sysSchema
=
new
PostgreSchema
(
this
,
PostgreConstants
.
CATALOG_SCHEMA_NAME
);
sysSchema
.
getDataTypeCache
().
loadDefaultTypes
(
sysSchema
);
dataTypeCache
.
loadDefaultTypes
(
this
);
schemaCache
.
cacheObject
(
sysSchema
);
}
...
...
@@ -488,6 +488,8 @@ public class PostgreDatabase extends JDBCRemoteInstance
///////////////////////////////////////////////
// Data types
@NotNull
@Override
public
DBPDataKind
resolveDataKind
(
@NotNull
String
typeName
,
int
typeID
)
{
...
...
@@ -501,11 +503,7 @@ public class PostgreDatabase extends JDBCRemoteInstance
@Override
public
Collection
<
PostgreDataType
>
getLocalDataTypes
()
{
final
PostgreSchema
schema
=
getCatalogSchema
();
if
(
schema
!=
null
)
{
return
schema
.
getDataTypeCache
().
getCachedObjects
();
}
return
null
;
return
dataTypeCache
.
getCachedObjects
();
}
@Override
...
...
@@ -583,14 +581,10 @@ public class PostgreDatabase extends JDBCRemoteInstance
}
void
cacheDataTypes
(
DBRProgressMonitor
monitor
,
boolean
forceRefresh
)
throws
DBException
{
if
(
dataTypeCache
.
isEmpty
()
||
forceRefresh
)
{
dataTypeCache
.
clear
();
if
(
!
dataTypeCache
.
isFullyCached
()
||
forceRefresh
)
{
dataTypeCache
.
clear
Cache
();
// Cache data types
for
(
final
PostgreSchema
pgSchema
:
getSchemas
(
monitor
))
{
if
(
PostgreConstants
.
CATALOG_SCHEMA_NAME
.
equals
(
pgSchema
.
getName
()))
{
pgSchema
.
getDataTypes
(
monitor
);
}
}
dataTypeCache
.
loadObjects
(
monitor
,
this
);
}
}
...
...
@@ -718,21 +712,14 @@ public class PostgreDatabase extends JDBCRemoteInstance
if
(
typeId
<=
0
)
{
return
null
;
}
PostgreDataType
dataType
=
dataTypeCache
.
get
(
typeId
);
PostgreDataType
dataType
=
dataTypeCache
.
get
DataType
(
typeId
);
if
(
dataType
!=
null
)
{
return
dataType
;
}
for
(
PostgreSchema
schema
:
schemaCache
.
getCachedObjects
())
{
dataType
=
schema
.
getDataTypeCache
().
getDataType
(
typeId
);
if
(
dataType
!=
null
)
{
dataTypeCache
.
put
(
typeId
,
dataType
);
return
dataType
;
}
}
// Type not found. Let's resolve it
try
{
dataType
=
PostgreDataTypeCache
.
resolveDataType
(
monitor
,
this
,
typeId
);
dataType
.
getParentObject
().
getDataTypeCache
()
.
cacheObject
(
dataType
);
dataType
Cache
.
cacheObject
(
dataType
);
return
dataType
;
}
catch
(
Exception
e
)
{
log
.
debug
(
"Can't resolve data type "
+
typeId
,
e
);
...
...
@@ -746,33 +733,7 @@ public class PostgreDatabase extends JDBCRemoteInstance
typeName
=
"_"
+
typeName
.
substring
(
0
,
typeName
.
length
()
-
2
);
}
{
// First check system catalog
final
PostgreSchema
schema
=
getCatalogSchema
();
if
(
schema
!=
null
)
{
final
PostgreDataType
dataType
=
schema
.
getDataTypeCache
().
getCachedObject
(
typeName
);
if
(
dataType
!=
null
)
{
return
dataType
;
}
}
}
// Check schemas in search path
List
<
String
>
searchPath
=
getMetaContext
().
getSearchPath
();
for
(
String
schemaName
:
searchPath
)
{
final
PostgreSchema
schema
=
schemaCache
.
getCachedObject
(
schemaName
);
if
(
schema
!=
null
)
{
final
PostgreDataType
dataType
=
schema
.
getDataTypeCache
().
getCachedObject
(
typeName
);
if
(
dataType
!=
null
)
{
return
dataType
;
}
}
}
// Check the rest
for
(
PostgreSchema
schema
:
schemaCache
.
getCachedObjects
())
{
if
(
searchPath
.
contains
(
schema
.
getName
()))
{
continue
;
}
final
PostgreDataType
dataType
=
schema
.
getDataTypeCache
().
getCachedObject
(
typeName
);
PostgreDataType
dataType
=
dataTypeCache
.
getCachedObject
(
typeName
);
if
(
dataType
!=
null
)
{
return
dataType
;
}
...
...
@@ -785,7 +746,7 @@ public class PostgreDatabase extends JDBCRemoteInstance
// Type not found. Let's resolve it
try
{
PostgreDataType
dataType
=
PostgreDataTypeCache
.
resolveDataType
(
monitor
,
this
,
typeName
);
dataType
.
getParentObject
().
getDataTypeCache
()
.
cacheObject
(
dataType
);
dataType
Cache
.
cacheObject
(
dataType
);
return
dataType
;
}
catch
(
Exception
e
)
{
log
.
debug
(
"Can't resolve data type '"
+
typeName
+
"' in database '"
+
getName
()
+
"'"
);
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreProcedure.java
浏览文件 @
bfaad6ed
...
...
@@ -611,7 +611,7 @@ public class PostgreProcedure extends AbstractProcedure<PostgreDataSource, Postg
paramsSignature
.
append
(
param
.
getName
()).
append
(
' '
);
}
final
PostgreDataType
dataType
=
param
.
getParameterType
();
final
PostgreSchema
typeContainer
=
dataType
.
get
ParentObject
();
final
PostgreSchema
typeContainer
=
dataType
.
get
TypeSchema
();
if
(
typeContainer
==
null
||
typeContainer
.
isPublicSchema
()
||
typeContainer
.
isCatalogSchema
())
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java
浏览文件 @
bfaad6ed
...
...
@@ -88,7 +88,7 @@ public class PostgreSchema implements
private
final
ConstraintCache
constraintCache
;
private
final
ProceduresCache
proceduresCache
;
private
final
IndexCache
indexCache
;
private
final
PostgreDataTypeCache
dataTypeCache
;
private
List
<
PostgreDataType
>
dataTypeList
;
protected
volatile
boolean
hasStatistics
;
PostgreSchema
(
PostgreDatabase
database
,
String
name
)
{
...
...
@@ -101,7 +101,7 @@ public class PostgreSchema implements
constraintCache
=
createConstraintCache
();
indexCache
=
new
IndexCache
();
proceduresCache
=
createProceduresCache
();
dataType
Cache
=
new
PostgreDataTypeCache
();
dataType
List
=
new
ArrayList
<>
();
}
@NotNull
...
...
@@ -276,8 +276,8 @@ public class PostgreSchema implements
return
indexCache
;
}
public
PostgreDataTypeCache
getDataTypeCache
()
{
return
dataType
Cache
;
public
List
<
PostgreDataType
>
getDataTypeList
()
{
return
dataType
List
;
}
@Association
...
...
@@ -455,14 +455,16 @@ public class PostgreSchema implements
//@Property
@Association
public
Collection
<
PostgreDataType
>
getDataTypes
(
DBRProgressMonitor
monitor
)
throws
DBException
{
List
<
PostgreDataType
>
types
=
new
ArrayList
<>();
for
(
PostgreDataType
dt
:
dataTypeCache
.
getAllObjects
(
monitor
,
this
))
{
if
(
dt
.
getParentObject
()
==
this
)
{
types
.
add
(
dt
);
if
(
CommonUtils
.
isEmpty
(
dataTypeList
))
{
Collection
<
PostgreDataType
>
allDatabaseTypes
=
getDatabase
().
getLocalDataTypes
();
for
(
PostgreDataType
dt
:
allDatabaseTypes
)
{
if
(
dt
.
getTypeSchema
()
==
this
)
{
dataTypeList
.
add
(
dt
);
}
}
DBUtils
.
orderObjects
(
dataTypeList
);
}
DBUtils
.
orderObjects
(
types
);
return
types
;
return
dataTypeList
;
}
@Override
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCTableColumn.java
浏览文件 @
bfaad6ed
...
...
@@ -119,9 +119,9 @@ public abstract class JDBCTableColumn<TABLE_TYPE extends DBSEntity> extends JDBC
@Override
public
void
setTypeName
(
String
typeName
)
{
super
.
setTypeName
(
typeName
);
final
DBPData
Source
dataSource
=
getDataSource
(
);
if
(
data
Source
instanceof
DBPDataTypeProvider
)
{
DBSDataType
dataType
=
((
DBPDataTypeProvider
)
dataSource
)
.
getLocalDataType
(
typeName
);
final
DBPData
TypeProvider
dataTypeProvider
=
DBUtils
.
getParentOfType
(
DBPDataTypeProvider
.
class
,
this
);
if
(
data
TypeProvider
!=
null
)
{
DBSDataType
dataType
=
dataTypeProvider
.
getLocalDataType
(
typeName
);
if
(
dataType
!=
null
)
{
this
.
valueType
=
dataType
.
getTypeID
();
if
(
this
instanceof
DBSTypedObjectExt4
)
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/struct/DBStructUtils.java
浏览文件 @
bfaad6ed
...
...
@@ -218,8 +218,8 @@ public final class DBStructUtils {
String
typeName
=
typedObject
.
getTypeName
();
String
typeNameLower
=
typeName
.
toLowerCase
(
Locale
.
ENGLISH
);
DBPDataKind
dataKind
=
typedObject
.
getDataKind
();
if
(
objectContainer
instanceof
DBPDataTypeProvider
)
{
DBPDataTypeProvider
dataTypeProvider
=
(
DBPDataTypeProvider
)
objectContainer
;
DBPDataTypeProvider
dataTypeProvider
=
DBUtils
.
getParentOfType
(
DBPDataTypeProvider
.
class
,
objectContainer
);
if
(
dataTypeProvider
!=
null
)
{
DBSDataType
dataType
=
dataTypeProvider
.
getLocalDataType
(
typeName
);
if
(
dataType
==
null
&&
typeNameLower
.
equals
(
"double"
))
{
dataType
=
dataTypeProvider
.
getLocalDataType
(
"DOUBLE PRECISION"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录