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

#3644 PG: materialized view tablespace. Comment editor fix.


Former-commit-id: 93ac380f
上级 34f7e599
......@@ -399,6 +399,8 @@ meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreViewBase.name.name=Name
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreViewBase.name.description=
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreViewBase.objectDefinitionText.name=Source
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreViewBase.objectDefinitionText.description=
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreMaterializedView.tablespace.name=Tablespace
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreMaterializedView.tablespace.description=Materialized view tablespace
meta.org.jkiss.dbeaver.ext.postgresql.model.plan.PostgrePlanNode.cost.name=Cost
meta.org.jkiss.dbeaver.ext.postgresql.model.plan.PostgrePlanNode.cost.description=
meta.org.jkiss.dbeaver.ext.postgresql.model.plan.PostgrePlanNode.entity.name=Entity
......
......@@ -59,7 +59,7 @@ public abstract class PostgreTableManagerBase extends SQLTableManager<PostgreTab
if (showComments && comment != null) {
actions.add(new SQLDatabasePersistAction(
"Comment table",
"COMMENT ON " + (table.isView() ? "VIEW": "TABLE") + " " + table.getFullyQualifiedName(DBPEvaluationContext.DDL) +
"COMMENT ON " + (table.isView() ? ((PostgreViewBase)table).getViewType() : "TABLE") + " " + table.getFullyQualifiedName(DBPEvaluationContext.DDL) +
" IS " + SQLUtils.quoteString(table, comment)));
}
DBRProgressMonitor monitor = new VoidProgressMonitor();
......
......@@ -113,7 +113,7 @@ public class PostgreViewManager extends PostgreTableManagerBase {
// Source may be empty if it wasn't yet read. Then it definitely wasn't changed
String sql = view.getSource().trim();
if (!sql.toLowerCase(Locale.ENGLISH).startsWith("create")) {
sql = "CREATE OR REPLACE VIEW " + DBUtils.getObjectFullName(view, DBPEvaluationContext.DDL) + " AS\n" + sql;
sql = "CREATE OR REPLACE " + view.getViewType() + " " + DBUtils.getObjectFullName(view, DBPEvaluationContext.DDL) + " AS\n" + sql;
}
actions.add(
new SQLDatabasePersistAction("Create view", sql));
......
......@@ -17,8 +17,14 @@
package org.jkiss.dbeaver.ext.postgresql.model;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ext.postgresql.PostgreUtils;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.meta.IPropertyValueListProvider;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.utils.CommonUtils;
import java.sql.ResultSet;
......@@ -30,6 +36,8 @@ import java.util.Map;
*/
public class PostgreMaterializedView extends PostgreViewBase
{
private long tablespaceId;
public PostgreMaterializedView(PostgreSchema catalog) {
super(catalog);
}
......@@ -39,6 +47,7 @@ public class PostgreMaterializedView extends PostgreViewBase
ResultSet dbResult)
{
super(catalog, dbResult);
this.tablespaceId = JDBCUtils.safeGetLong(dbResult, "reltablespace");
}
@Override
......@@ -65,4 +74,17 @@ public class PostgreMaterializedView extends PostgreViewBase
return "MATERIALIZED VIEW";
}
@Property(viewable = true, editable = true, updatable = true, order = 20, listProvider = PostgreTableBase.TablespaceListProvider.class)
public PostgreTablespace getTablespace(DBRProgressMonitor monitor) throws DBException {
if (tablespaceId == 0) {
return getDatabase().getDefaultTablespace(monitor);
}
return PostgreUtils.getObjectById(monitor, getDatabase().tablespaceCache, getDatabase(), tablespaceId);
}
public void setTablespace(PostgreTablespace tablespace) {
this.tablespaceId = tablespace.getObjectId();
}
}
......@@ -318,23 +318,4 @@ public abstract class PostgreTable extends PostgreTableReal implements DBDPseudo
return result;
}
public static class TablespaceListProvider implements IPropertyValueListProvider<PostgreTable> {
@Override
public boolean allowCustomValue()
{
return false;
}
@Override
public Object[] getPossibleValues(PostgreTable object)
{
try {
Collection<PostgreTablespace> tablespaces = object.getDatabase().getTablespaces(new VoidProgressMonitor());
return tablespaces.toArray(new Object[tablespaces.size()]);
} catch (DBException e) {
log.error(e);
return new Object[0];
}
}
}
}
......@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ext.postgresql.model;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ext.postgresql.PostgreUtils;
import org.jkiss.dbeaver.model.DBPEvaluationContext;
import org.jkiss.dbeaver.model.DBPNamedObject2;
......@@ -28,8 +29,10 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCStructCache;
import org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable;
import org.jkiss.dbeaver.model.meta.Association;
import org.jkiss.dbeaver.model.meta.IPropertyValueListProvider;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSEntity;
import org.jkiss.dbeaver.model.struct.DBSEntityAssociation;
import org.jkiss.dbeaver.model.struct.DBSObject;
......@@ -43,6 +46,8 @@ import java.util.*;
*/
public abstract class PostgreTableBase extends JDBCTable<PostgreDataSource, PostgreSchema> implements PostgreClass, PostgreScriptObject, PostgrePermissionsOwner, DBPNamedObject2
{
private static final Log log = Log.getLog(PostgreTableBase.class);
private long oid;
private long ownerId;
private String description;
......@@ -131,7 +136,6 @@ public abstract class PostgreTableBase extends JDBCTable<PostgreDataSource, Post
/**
* Table columns
* @param monitor progress monitor
* @throws DBException
*/
@Override
public List<PostgreTableColumn> getAttributes(@NotNull DBRProgressMonitor monitor)
......@@ -209,4 +213,23 @@ public abstract class PostgreTableBase extends JDBCTable<PostgreDataSource, Post
}
public static class TablespaceListProvider implements IPropertyValueListProvider<PostgreTableBase> {
@Override
public boolean allowCustomValue()
{
return false;
}
@Override
public Object[] getPossibleValues(PostgreTableBase object)
{
try {
Collection<PostgreTablespace> tablespaces = object.getDatabase().getTablespaces(new VoidProgressMonitor());
return tablespaces.toArray(new Object[tablespaces.size()]);
} catch (DBException e) {
log.error(e);
return new Object[0];
}
}
}
}
......@@ -109,7 +109,7 @@ public abstract class PostgreViewBase extends PostgreTableReal
if (CommonUtils.getOption(options, PostgreConstants.OPTION_DDL_SHOW_COLUMN_COMMENTS) && getDescription() != null) {
actions.add(
new SQLDatabasePersistAction("Comment",
"COMMENT ON VIEW " + getFullyQualifiedName(DBPEvaluationContext.DDL) + " IS " + SQLUtils.quoteString(this, getDescription())));
"COMMENT ON " + getViewType() + " " + getFullyQualifiedName(DBPEvaluationContext.DDL) + " IS " + SQLUtils.quoteString(this, getDescription())));
}
if (CommonUtils.getOption(options, PostgreConstants.OPTION_DDL_SHOW_PERMISSIONS)) {
PostgreUtils.getObjectGrantPermissionActions(monitor, this, actions, options);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册