提交 24279fed 编写于 作者: S serge-rider

PG 10 support fix (partitions)

上级 10477553
......@@ -71,7 +71,7 @@
</items>
</items>
</folder>
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition" label="%tree.partitions.node.name" icon="#folder_table" description="Table partitions" virtual="true">
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition" label="%tree.partitions.node.name" icon="#folder_table" description="Table partitions" virtual="true" if="object.dataSource.isServerVersionAtLeast(10, 0)">
<items label="%tree.partitions.node.name" path="partition" property="partitions" icon="#partition" virtual="true" recursive="../..">
</items>
</folder>
......
......@@ -237,10 +237,13 @@ public abstract class PostgreTable extends PostgreTableReal implements DBDPseudo
public List<PostgreTableInheritance> getSubInheritance(@NotNull DBRProgressMonitor monitor) throws DBException {
if (subTables == null) {
try (JDBCSession session = DBUtils.openMetaSession(monitor, getDataSource(), "Load table inheritance info")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement(
"SELECT i.*,c.relnamespace " +
String sql = "SELECT i.*,c.relnamespace " +
"FROM pg_catalog.pg_inherits i,pg_catalog.pg_class c " +
"WHERE i.inhparent=? AND c.oid=i.inhrelid AND c.relispartition=false")) {
"WHERE i.inhparent=? AND c.oid=i.inhrelid";
if (getDataSource().isServerVersionAtLeast(10, 0)) {
sql += " AND c.relispartition=false";
}
try (JDBCPreparedStatement dbStat = session.prepareStatement(sql)) {
dbStat.setLong(1, getObjectId());
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
while (dbResult.next()) {
......
......@@ -130,14 +130,14 @@ public abstract class SQLTableManager<OBJECT_TYPE extends JDBCTable, CONTAINER_T
}
protected void setTableName(DBRProgressMonitor monitor, CONTAINER_TYPE container, OBJECT_TYPE table) throws DBException {
table.setName(getTableName(monitor, container));
table.setName(getNewChildName(monitor, container));
}
protected String getTableName(DBRProgressMonitor monitor, CONTAINER_TYPE container) throws DBException {
return getTableName(monitor, container, BASE_TABLE_NAME);
protected String getNewChildName(DBRProgressMonitor monitor, CONTAINER_TYPE container) throws DBException {
return getNewChildName(monitor, container, BASE_TABLE_NAME);
}
protected String getTableName(DBRProgressMonitor monitor, CONTAINER_TYPE container, String baseName) throws DBException {
protected String getNewChildName(DBRProgressMonitor monitor, CONTAINER_TYPE container, String baseName) throws DBException {
for (int i = 0; ; i++) {
String tableName = DBObjectNameCaseTransformer.transformName(container.getDataSource(), i == 0 ? baseName : (baseName + "_" + i));
DBSObject child = container.getChild(monitor, tableName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册