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

#6203 PG Partition Manager

上级 8a4ed76c
......@@ -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.expr.name=Partition Expression
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.expr.description=
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.partitionExpression.name=Partition Expression
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition.partitionExpression.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.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.PostgreTablePartition.partitionExpression.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.partitionExpression.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
......
......@@ -53,7 +53,7 @@
<icon if="object.system" icon="#schema_system"/>
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTable" label="%tree.tables.node.name" icon="#folder_table" description="%tree.tables.node.tip">
<items label="%tree.table.node.name" path="table" property="tables" icon="#table">
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableColumn" label="%tree.columns.node.name" icon="#columns" description="%tree.columns.node.tip">
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableColumn" label="%tree.columns.node.name" icon="#columns" description="%tree.columns.node.tip" visibleIf="!object.isPartition()">
<items label="%tree.column.node.name" path="attribute" property="attributes" icon="#column">
</items>
</folder>
......@@ -84,11 +84,11 @@
</items>
</items>
</folder>
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition" label="%tree.partitions.node.name" icon="#folder_table" description="%tree.partitions.node.tip" virtual="true" visibleIf="object.dataSource.serverType.supportsPartitions()">
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition" label="%tree.partitions.node.name" icon="#folder_table" description="%tree.partitions.node.tip" virtual="true" visibleIf="object.dataSource.serverType.supportsPartitions() &amp;&amp; !object.isPartition()">
<items label="%tree.partitions.node.name" path="partition" property="partitions" icon="#partition" virtual="true" recursive="../..">
</items>
</folder>
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal" label="%tree.tablechildren.node.name" icon="#folder_table" description="Table children" virtual="true" visibleIf="object.hasSubClasses()">
<folder type="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableReal" label="%tree.tablechildren.node.name" icon="#folder_table" description="Table children" virtual="true" visibleIf="object.hasSubClasses() &amp;&amp; !object.isPartition()">
<items label="%tree.tablechildren.node.name" path="subTables" property="subTables" icon="#table" virtual="true" recursive="../.." >
</items>
</folder>
......@@ -432,9 +432,9 @@
<extension point="org.jkiss.dbeaver.objectManager">
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgreDatabaseManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgreSchemaManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgrePartitionManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgreTableManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreTable"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgreTableColumnManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableColumn"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgrePartitionManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreTablePartition"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgreSequenceManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreSequence"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgreConstraintManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraint"/>
<manager class="org.jkiss.dbeaver.ext.postgresql.edit.PostgreForeignKeyManager" objectType="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableForeignKey"/>
......
......@@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ext.postgresql.model.*;
......@@ -34,16 +35,15 @@ public class PostgrePartitionManager extends PostgreTableManager {
private static final Log log = Log.getLog(PostgrePartitionManager.class);
private static final Class<?>[] CHILD_TYPES_PART = {
PostgreTableConstraint.class,
PostgreTableForeignKey.class,
PostgreIndex.class
};
protected PostgreTablePartition createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, Object container, Object copyFrom, Map<String, Object> options) {
PostgreTable owner = (PostgreTable)container;
final PostgreTablePartition table = new PostgreTablePartition(owner.getSchema());
try {
setTableName(monitor, owner.getSchema(), table);
} catch (DBException e) {
// Never be here
log.error(e);
}
final PostgreTablePartition table = new PostgreTablePartition(owner.getSchema(),owner);
return table;
}
......@@ -57,7 +57,9 @@ public class PostgrePartitionManager extends PostgreTableManager {
return "";
}
if (superTables == null || superTables.size() != 1) {
if (superTables == null && partition.getPartitionOf() != null) {
return partition.getPartitionOf().getSchema().getName() + "." + partition.getPartitionOf().getName();
} else if (superTables == null || superTables.size() > 1) {
log.error("Unable to get parent");
return "";
}
......@@ -87,7 +89,7 @@ public class PostgrePartitionManager extends PostgreTableManager {
@Override
public boolean canEditObject(PostgreTableBase object) {
return false;
return object instanceof PostgreTablePartition;
}
@Override
......@@ -97,7 +99,15 @@ public class PostgrePartitionManager extends PostgreTableManager {
@Override
public boolean canDeleteObject(PostgreTableBase object) {
return false;
return true;
}
@NotNull
@Override
public Class<?>[] getChildTypes()
{
return CHILD_TYPES_PART;
}
}
......@@ -50,7 +50,7 @@ public abstract class PostgreTableBase extends JDBCTable<PostgreDataSource, Post
private long oid;
private long ownerId;
private String description;
private boolean isPartition;
protected boolean isPartition;
private boolean hasPartitions;
private String part_key;
private Object acl;
......
......@@ -20,11 +20,11 @@ package org.jkiss.dbeaver.ext.postgresql.model;
import java.sql.ResultSet;
import java.util.Map;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSEntity;
import org.jkiss.dbeaver.model.struct.DBStructUtils;
public class PostgreTablePartition extends PostgreTable
......@@ -32,84 +32,40 @@ public class PostgreTablePartition extends PostgreTable
public static final String CAT_PARTITIONING = "Partitioning";
private String expr;
private String partitionExpression;
private PostgreTable partitionOf;
public PostgreTablePartition(PostgreSchema catalog) {
public PostgreTablePartition(PostgreSchema catalog, PostgreTable partitionOf) {
super(catalog);
this.partitionExpression = "FOR VALUES ";
this.isPartition = true;
this.setName("newpartition");
this.partitionOf = partitionOf;
}
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;
}
@Override
public String getObjectDefinitionText(DBRProgressMonitor monitor, Map<String, Object> options) throws DBException {
return DBStructUtils.generateTableDDL(monitor, this, options, false);
}
/*
public PostgreTablePartition(PostgreSchema container, DBSEntity source, boolean persisted) {
super(container, source, persisted);
}
@Property(category = CAT_PARTITIONING, editable = false, viewable = true, order = 50)
public String getPartKeys() {
return "this.oid";
}
private final PostgreTableBase partitionTable;
private int sequenceNum;
//select * from pg_partitioned_table where partrelid = ?
public PostgreTablePartition(
@NotNull PostgreTableBase table,
@NotNull PostgreTableBase partitionTable,
int sequenceNum,
boolean persisted)
{
super(table,
table.getFullyQualifiedName(DBPEvaluationContext.DDL) + "->" + partitionTable.getFullyQualifiedName(DBPEvaluationContext.DDL),
DBSEntityConstraintType.INHERITANCE);
this.setPersisted(persisted);
this.partitionTable = partitionTable;
this.sequenceNum = sequenceNum;
this.partitionExpression = JDBCUtils.safeGetString(dbResult, "partition_expr");
}
@Property(viewable = true, editable = true, updatable = true, order = 60)
@Nullable
@Override
public DBSEntityConstraint getReferencedConstraint() {
return this;
public String getPartitionExpression() {
return partitionExpression;
}
@Override
@Property(viewable = true)
public PostgreTableBase getAssociatedEntity() {
return this.partitionTable;
public void setPartitionExpression(String expr) {
this.partitionExpression = expr;
}
@Property(viewable = true)
public int getSequenceNum() {
return sequenceNum;
}
@Nullable
@Override
public List<PostgreTableForeignKeyColumn> getAttributeReferences(DBRProgressMonitor monitor) throws DBException {
return null;
public String getObjectDefinitionText(DBRProgressMonitor monitor, Map<String, Object> options) throws DBException {
return DBStructUtils.generateTableDDL(monitor, this, options, false);
}
@Override
void cacheAttributes(DBRProgressMonitor monitor, List<? extends PostgreTableConstraintColumn> children, boolean secondPass) {
public PostgreTable getPartitionOf() {
return partitionOf;
}
*/
}
......@@ -241,7 +241,7 @@ public abstract class PostgreServerExtensionBase implements PostgreServerExtensi
}
}
if (tableBase instanceof PostgreTablePartition && !alter) {
ddl.append(((PostgreTablePartition) tableBase).getExpr());
ddl.append(((PostgreTablePartition) tableBase).getPartitionExpression());
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册