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

#3681 PG: refresh materialized view

上级 2442af77
......@@ -584,3 +584,5 @@ tools.vacuum.name=Vacuum
tools.vacuum.description=Vacuum table(s)
tools.truncate.name=Truncate
tools.truncate.description=Truncate table(s)
tools.refesh.mview.name=Refresh Materialized View
tools.refesh.mview.description=Refresh materialized view(s)
......@@ -493,6 +493,15 @@
singleton="false">
<objectType name="org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase"/>
</tool>
<tool
class="org.jkiss.dbeaver.ext.postgresql.tools.maintenance.PostgreToolRefreshMView"
description="%tools.refesh.mview.description"
id="org.jkiss.dbeaver.ext.postgresql.tools.maintenance.PostgreToolRefreshMView"
group="org.jkiss.dbeaver.ext.postgresql.tools.maintenance"
label="%tools.refesh.mview.name"
singleton="false">
<objectType name="org.jkiss.dbeaver.ext.postgresql.model.PostgreMaterializedView"/>
</tool>
</tools>
</extension>
......
......@@ -76,6 +76,9 @@ public class PostgreMessages extends NLS {
public static String tool_analyze_title_table;
public static String tool_analyze_title_database;
/* tool refresh mat view */
public static String tool_refresh_mview_title_table;
/* tool vacuum */
public static String tool_vacuum_analyze_check_tooltip;
public static String tool_vacuum_dps_check_tooltip;
......@@ -95,6 +98,11 @@ public class PostgreMessages extends NLS {
public static String tool_truncate_group_option;
public static String tool_truncate_title_table;
/* tool refresh mat view */
public static String tool_refresh_mview_group_option;
public static String tool_refresh_mview_with_data;
public static String tool_refresh_mview_with_data_tooltip;
/* dialog create db */
public static String dialog_create_db_group_definition;
public static String dialog_create_db_group_general;
......
......@@ -57,6 +57,9 @@ tool_script_title_import=Import configuration
tool_analyze_title_database=Analyze database
tool_analyze_title_table=Analyze table(s)
# tool refresh mat view
tool_refresh_mview_title_table = Refresh materialized view
# tool vacuum #
tool_vacuum_analyze_check_tooltip=Updates statistics used by the planner to determine the most efficient way to execute a query.
tool_vacuum_dps_check_tooltip=Normally, VACUUM will skip pages based on the visibility map.\nPages where all tuples are known to be frozen can always be skipped, and those where all tuples are known to be visible to all transactions may be skipped except when performing an aggressive vacuum.\nFurthermore, except when performing an aggressive vacuum, some pages may be skipped in order to avoid waiting for other sessions to finish using them.\nThis option disables all page-skipping behavior, and is intended to be used only the contents of the visibility map are thought to be suspect, which should happen only if there is a hardware or software issue causing database corruption.
......@@ -76,6 +79,11 @@ tool_truncate_checkbox_restart_tooltip=Automatically restart sequences owned by
tool_truncate_group_option=Options
tool_truncate_title_table=Truncate table(s)
# tool refresh mat view
tool_refresh_mview_group_option = Options
tool_refresh_mview_with_data = With data
tool_refresh_mview_with_data_tooltip = If WITH DATA is specified (or defaults) the backing query is executed to provide the new data, and the materialized view is left in a scannable state.\nIf WITH NO DATA is specified no new data is generated and the materialized view is left in an unscannable state.
# dialog create db #
dialog_create_db_group_definition=Definition
dialog_create_db_group_general=General
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.postgresql.tools.maintenance;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.postgresql.PostgreMessages;
import org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase;
import org.jkiss.dbeaver.ext.postgresql.model.PostgreMaterializedView;
import org.jkiss.dbeaver.ext.postgresql.model.PostgreObject;
import org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase;
import org.jkiss.dbeaver.model.DBPEvaluationContext;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.tools.IExternalTool;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.CommonUtils;
import java.util.Collection;
import java.util.List;
/**
* Table analyze
*/
public class PostgreToolRefreshMView implements IExternalTool
{
@Override
public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException
{
List<PostgreMaterializedView> tables = CommonUtils.filterCollection(objects, PostgreMaterializedView.class);
if (!tables.isEmpty()) {
SQLDialog dialog = new SQLDialog(activePart.getSite(), tables);
dialog.open();
}
}
static class SQLDialog extends TableToolDialog {
private Button withDataCheck;
public SQLDialog(IWorkbenchPartSite partSite, List<PostgreMaterializedView> selectedTables)
{
super(partSite, PostgreMessages.tool_refresh_mview_title_table, selectedTables);
}
@Override
protected void generateObjectCommand(List<String> lines, PostgreObject object) {
String sql = "REFRESH MATERIALIZED VIEW " + ((PostgreMaterializedView) object).getFullyQualifiedName(DBPEvaluationContext.DDL) + " ";
if (withDataCheck.getSelection()) {
sql += "WITH DATA";
} else {
sql += "WITH NO DATA";
}
lines.add(sql);
}
@Override
protected void createControls(Composite parent) {
Group optionsGroup = UIUtils.createControlGroup(parent, PostgreMessages.tool_refresh_mview_group_option, 1, 0, 0);
optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
withDataCheck = UIUtils.createCheckbox(optionsGroup, PostgreMessages.tool_refresh_mview_with_data, PostgreMessages.tool_refresh_mview_with_data_tooltip, true, 0);
withDataCheck.addSelectionListener(SQL_CHANGE_LISTENER);
createObjectsSelector(parent);
}
}
}
......@@ -47,7 +47,7 @@ import java.util.List;
public abstract class TableToolDialog extends GenerateMultiSQLDialog<PostgreObject>
{
public TableToolDialog(IWorkbenchPartSite partSite, String title, Collection<PostgreTableBase> tables) {
public TableToolDialog(IWorkbenchPartSite partSite, String title, Collection<? extends PostgreTableBase> tables) {
super(partSite, title, toObjects(tables), true);
}
......@@ -55,7 +55,7 @@ public abstract class TableToolDialog extends GenerateMultiSQLDialog<PostgreObje
super(partSite, title, Collections.<PostgreObject>singletonList(database), true);
}
private static Collection<PostgreObject> toObjects(Collection<PostgreTableBase> tables) {
private static Collection<PostgreObject> toObjects(Collection<? extends PostgreTableBase> tables) {
List<PostgreObject> objectList = new ArrayList<>();
objectList.addAll(tables);
return objectList;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册