提交 b1231775 编写于 作者: A Andrew Khitrin

5780 Postrges partition expression


Former-commit-id: 31aff396
上级 47136937
......@@ -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
......
......@@ -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
......
......@@ -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");;
......
......@@ -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);
}
......
......@@ -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;
......@@ -27,16 +28,25 @@ public class PostgreTablePartition extends PostgreTable
public static final String CAT_PARTITIONING = "Partitioning";
private String expr;
public PostgreTablePartition(PostgreSchema catalog) {
super(catalog);
}
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 = ?
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册