diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle.properties b/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle.properties index a233e28a2a61b18064b78bef1de3865b943aa21e..e47d20070ddc279aceb419c6aabfb746ce211be8 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle.properties +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle.properties @@ -421,8 +421,8 @@ meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.diskSpace.name=Disk meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.diskSpace.description=Total disk space used by the specified table, including all indexes and TOAST data meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.relationSize.name=Rel Size meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.relationSize.description=Disk space used by the fork 'main' -meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.partKeys.name=Partition Keys -meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.partKeys.description= +meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.expr.name=Partition Expression +meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.expr.description= meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablespace.name.name=Name meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablespace.name.description= meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablespace.options.name=Options diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle_ru.properties b/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle_ru.properties index 053bc45982eedb9a9d7e9a31a935f1e30a838445..6fd5c81247b359d51244948013b061b0ca8a92a2 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle_ru.properties +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/OSGI-INF/l10n/bundle_ru.properties @@ -372,8 +372,8 @@ meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.diskSpace.name=\u04 meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.diskSpace.description=\u041E\u0431\u0449\u0435\u0435 \u0434\u0438\u0441\u043A\u043E\u0432\u043E\u0435 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u043E, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u043C\u043E\u0435 \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u043E\u0439 \u0442\u0430\u0431\u043B\u0438\u0446\u0435\u0439 meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.relationSize.name=\u0420\u0435\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440 meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal.relationSize.description=\u0414\u0438\u0441\u043A\u043E\u0432\u043E\u0435 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u043E, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u043C\u043E\u0435 fork 'main' -meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.partKeys.name=\u041A\u043B\u044E\u0447\u0438 \u0441\u0435\u043A\u0446\u0438\u0438 -meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.partKeys.description=Partition Keys - \u043A\u043B\u044E\u0447\u0438 \u0441\u0435\u043A\u0446\u0438\u0438 / \u0440\u0430\u0437\u0434\u0435\u043B\u0430 / \u043F\u0430\u0440\u0442\u0438\u0446\u0438\u0438 +meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.expr.name=\u0412\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0434\u043B\u044F \u043F\u0430\u0440\u0442\u0438\u0446\u0438\u0438 +meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.expr.description=\u0412\u044B\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u043F\u043E \u043A\u0442\u043E\u0440\u043E\u043C\u0443 \u0441\u043E\u0437\u0434\u0430\u0432\u0430\u043B\u0430\u0441\u044C \u043F\u0430\u0440\u0442\u0438\u0446\u0438\u044F meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablespace.name.name=\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablespace.name.description= meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablespace.options.name=\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreClass.java b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreClass.java index 0cbb4369a62c08154641134a5def8f1d9de49c28..a0ebec745311345ba5e38ab58330fbd6576036e9 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreClass.java +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreClass.java @@ -35,6 +35,7 @@ public interface PostgreClass extends PostgreObject, DBSEntity, DBPRefreshableOb public static final RelKind t = new RelKind("t"); // TOAST table public static final RelKind f = new RelKind("f"); // = foreign table public static final RelKind p = new RelKind("p"); // partitionedtable + public static final RelKind R = new RelKind("R"); // partition // Redshift public static final RelKind e = new RelKind("e"); public static final RelKind s = new RelKind("s");; diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java index e88c7ae8ec180072f0afe050416fd30c7f172395..4eaba01573dd22193df1f989d88805e4b1a7c55b 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java @@ -488,6 +488,9 @@ public class PostgreSchema implements DBSSchema, DBPNamedObject2, DBPSaveableObj public JDBCStatement prepareLookupStatement(@NotNull JDBCSession session, @NotNull PostgreSchema postgreSchema, @Nullable PostgreTableBase object, @Nullable String objectName) throws SQLException { StringBuilder sql = new StringBuilder(); sql.append("SELECT c.oid,c.*,d.description"); + if (getDataSource().isServerVersionAtLeast(10, 0)) { + sql.append(",pg_catalog.pg_get_expr(c.relpartbound, c.oid) as partition_expr"); + } sql.append("\nFROM pg_catalog.pg_class c\n") .append("LEFT OUTER JOIN pg_catalog.pg_description d ON d.objoid=c.oid AND d.objsubid=0\n") .append("WHERE c.relnamespace=? AND c.relkind not in ('i','c')") @@ -503,7 +506,11 @@ public class PostgreSchema implements DBSSchema, DBPNamedObject2, DBPSaveableObj protected PostgreTableBase fetchObject(@NotNull JDBCSession session, @NotNull PostgreSchema owner, @NotNull JDBCResultSet dbResult) throws SQLException, DBException { - final String kindString = JDBCUtils.safeGetString(dbResult, "relkind"); + final String kindString = getDataSource().isServerVersionAtLeast(10, 0) + && JDBCUtils.safeGetString(dbResult, "relkind").equals(PostgreClass.RelKind.r.getCode()) + && JDBCUtils.safeGetBoolean(dbResult, "relispartition") + ? PostgreClass.RelKind.R.getCode() : JDBCUtils.safeGetString(dbResult, "relkind"); + PostgreClass.RelKind kind = PostgreClass.RelKind.valueOf(kindString); return owner.getDataSource().getServerType().createRelationOfClass(PostgreSchema.this, kind, dbResult); } diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTablePartition.java b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTablePartition.java index 87c91beab6b0a3db4e28ce8f3d507040a1d14608..f07e33a45b5fce0b137414c04737cf9de9e43107 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTablePartition.java +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTablePartition.java @@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ext.postgresql.model; import java.sql.ResultSet; +import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils; import org.jkiss.dbeaver.model.meta.Property; import org.jkiss.dbeaver.model.struct.DBSEntity; @@ -26,6 +27,8 @@ public class PostgreTablePartition extends PostgreTable { public static final String CAT_PARTITIONING = "Partitioning"; + + private String expr; public PostgreTablePartition(PostgreSchema catalog) { super(catalog); @@ -33,10 +36,17 @@ public class PostgreTablePartition extends PostgreTable public PostgreTablePartition(PostgreSchema catalog, ResultSet dbResult) { super(catalog, dbResult); + this.expr = JDBCUtils.safeGetString(dbResult, "partition_expr"); } + @Property(category = CAT_PARTITIONING, editable = false, viewable = true, order = 90) + public String getExpr() { + return expr; + } + + /* public PostgreTablePartition(PostgreSchema container, DBSEntity source, boolean persisted) { super(container, source, persisted); } @@ -47,7 +57,7 @@ public class PostgreTablePartition extends PostgreTable } - /* + private final PostgreTableBase partitionTable; private int sequenceNum; //select * from pg_partitioned_table where partrelid = ? diff --git a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/PostgreServerExtensionBase.java b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/PostgreServerExtensionBase.java index b63d15fc85a399113e5cdce02d78be9d0a0d2552..64a99b9f66ea28700c9bb5ca809596a04e446a73 100644 --- a/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/PostgreServerExtensionBase.java +++ b/plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/PostgreServerExtensionBase.java @@ -160,6 +160,8 @@ public abstract class PostgreServerExtensionBase implements PostgreServerExtensi public PostgreTableBase createRelationOfClass(PostgreSchema schema, PostgreClass.RelKind kind, JDBCResultSet dbResult) { if (kind == PostgreClass.RelKind.r) { return new PostgreTableRegular(schema, dbResult); + } else if (kind == PostgreClass.RelKind.R) { + return new PostgreTablePartition(schema, dbResult); } else if (kind == PostgreClass.RelKind.v) { return new PostgreView(schema, dbResult); } else if (kind == PostgreClass.RelKind.m) {