Warn the user on changing the definition of Materialized View about the loss of data and its dependent objects. Fixes #4396

pull/27/head
Rahul Shirsat 2019-12-02 11:25:51 +05:30 committed by Akshay Joshi
parent 623ff4f91f
commit d98e86d3df
52 changed files with 150 additions and 777 deletions

View File

@ -35,7 +35,9 @@ Click the *Definition* tab to continue.
:align: center
Use the text editor field in the *Definition* tab to provide the query that will
populate the materialized view.
populate the materialized view. Please note that updating the definition of existing
materialized view would result in loss of Parameter(Table, Toast), Security(Privileges & Security labels),
Indexes and other dependent objects.
Click the *Storage* tab to continue.

View File

@ -9,6 +9,7 @@ This release contains a number of bug fixes and new features since the release o
New features
************
| `Issue #4396 <https://redmine.postgresql.org/issues/4396>`_ - Warn the user on changing the definition of Materialized View about the loss of data and its dependent objects.
| `Issue #4435 <https://redmine.postgresql.org/issues/4435>`_ - Allow drag and drop functionality for all the nodes under the database node, excluding collection nodes.
Housekeeping
@ -21,19 +22,19 @@ Housekeeping
Bug fixes
*********
| `Issue #3538 <https://redmine.postgresql.org/issues/3538>`_ - Fix issue where the Reset button does not get enabled till all the mandatory fields are provided in the dialog.
| `Issue #4659 <https://redmine.postgresql.org/issues/4659>`_ - Updated documentation for default privileges to clarify more on the grantor.
| `Issue #4724 <https://redmine.postgresql.org/issues/4724>`_ - Fix network disconnect issue while establishing the connection via SSH Tunnel and it impossible to expand the Servers node.
| `Issue #4761 <https://redmine.postgresql.org/issues/4761>`_ - Fix an issue where the wrong type is displayed when changing the datatype from timestamp with time zone to timestamp without time zone.
| `Issue #4792 <https://redmine.postgresql.org/issues/4792>`_ - Ensure that the superuser should be able to create database, as the superuser overrides all the access restrictions.
| `Issue #4818 <https://redmine.postgresql.org/issues/4818>`_ - Fix server connection drops out issue in query tool.
| `Issue #4836 <https://redmine.postgresql.org/issues/4836>`_ - Updated the json file name from 'servers.json' to 'pgadmin4/servers.json' in the container deployment section of the documentation.
| `Issue #4878 <https://redmine.postgresql.org/issues/4878>`_ - Ensure that the superuser should be able to create role, as the superuser overrides all the access restrictions.
| `Issue #4925 <https://redmine.postgresql.org/issues/4925>`_ - Shown some text on process watcher till the initial logs are loaded.
| `Issue #4926 <https://redmine.postgresql.org/issues/4926>`_ - Fix VPN network disconnect issue where pgAdmin4 hangs on expanding the Servers node.
| `Issue #4930 <https://redmine.postgresql.org/issues/4930>`_ - Fix main window tab navigation accessibility issue.
| `Issue #4933 <https://redmine.postgresql.org/issues/4933>`_ - Ensure that the Servers collection node should expand independently of server connections.
| `Issue #4934 <https://redmine.postgresql.org/issues/4934>`_ - Fix the help button link on the User Management dialog.
| `Issue #4935 <https://redmine.postgresql.org/issues/4935>`_ - Fix accessibility issues.
| `Issue #4964 <https://redmine.postgresql.org/issues/4964>`_ - Fix an issue where length and precision are not removed from table/column dialog.
| `Issue #4965 <https://redmine.postgresql.org/issues/4965>`_ - Fix an issue where the Interval data type is not displayed in the properties dialog of table/column.
| `Issue #3538 <https://redmine.postgresql.org/issues/3538>`_ - Fix issue where the Reset button does not get enabled till all the mandatory fields are provided in the dialog.
| `Issue #4659 <https://redmine.postgresql.org/issues/4659>`_ - Updated documentation for default privileges to clarify more on the grantor.
| `Issue #4724 <https://redmine.postgresql.org/issues/4724>`_ - Fix network disconnect issue while establishing the connection via SSH Tunnel and it impossible to expand the Servers node.
| `Issue #4761 <https://redmine.postgresql.org/issues/4761>`_ - Fix an issue where the wrong type is displayed when changing the datatype from timestamp with time zone to timestamp without time zone.
| `Issue #4792 <https://redmine.postgresql.org/issues/4792>`_ - Ensure that the superuser should be able to create database, as the superuser overrides all the access restrictions.
| `Issue #4818 <https://redmine.postgresql.org/issues/4818>`_ - Fix server connection drops out issue in query tool.
| `Issue #4836 <https://redmine.postgresql.org/issues/4836>`_ - Updated the json file name from 'servers.json' to 'pgadmin4/servers.json' in the container deployment section of the documentation.
| `Issue #4878 <https://redmine.postgresql.org/issues/4878>`_ - Ensure that the superuser should be able to create role, as the superuser overrides all the access restrictions.
| `Issue #4925 <https://redmine.postgresql.org/issues/4925>`_ - Shown some text on process watcher till the initial logs are loaded.
| `Issue #4926 <https://redmine.postgresql.org/issues/4926>`_ - Fix VPN network disconnect issue where pgAdmin4 hangs on expanding the Servers node.
| `Issue #4930 <https://redmine.postgresql.org/issues/4930>`_ - Fix main window tab navigation accessibility issue.
| `Issue #4933 <https://redmine.postgresql.org/issues/4933>`_ - Ensure that the Servers collection node should expand independently of server connections.
| `Issue #4934 <https://redmine.postgresql.org/issues/4934>`_ - Fix the help button link on the User Management dialog.
| `Issue #4935 <https://redmine.postgresql.org/issues/4935>`_ - Fix accessibility issues.
| `Issue #4964 <https://redmine.postgresql.org/issues/4964>`_ - Fix an issue where length and precision are not removed from table/column dialog.
| `Issue #4965 <https://redmine.postgresql.org/issues/4965>`_ - Fix an issue where the Interval data type is not displayed in the properties dialog of table/column.

View File

@ -142,6 +142,7 @@ define('pgadmin.node.mview', [
spcname: undefined,
toast_autovacuum_enabled: false,
autovacuum_enabled: false,
warn_text: undefined,
},
schema: [{
id: 'name', label: gettext('Name'), cell: 'string',
@ -171,7 +172,22 @@ define('pgadmin.node.mview', [
id: 'definition', label: gettext('Definition'), cell: 'string',
type: 'text', mode: ['create', 'edit'], group: gettext('Definition'),
tabPanelCodeClass: 'sql-code-control',
control: Backform.SqlCodeControl,
control: Backform.SqlCodeControl.extend({
onChange: function() {
Backform.SqlCodeControl.prototype.onChange.apply(this, arguments);
if(this.model && this.model.changed) {
if(this.model.origSessAttrs && (this.model.changed.definition != this.model.origSessAttrs.definition)) {
this.model.warn_text = gettext('Updating the definition will drop and re-create the materialized view. It may result in loss of information about its dependent objects. Do you want to continue?');
}
else {
this.model.warn_text = undefined;
}
}
else {
this.model.warn_text = undefined;
}
},
}),
},{
id: 'with_data', label: gettext('With data?'),
group: gettext('Storage'), mode: ['edit', 'create'],

View File

@ -27,9 +27,14 @@ ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }}
{% if def and def != o_data.definition.rstrip(';') %}
DROP MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }};
CREATE MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}
{% if data.fillfactor or (data['vacuum_data']['changed']|length > 0 ) %}
{% if data.fillfactor or o_data.fillfactor %}
WITH(
{% if data.fillfactor %} FILLFACTOR = {{ data.fillfactor }}{% if data['vacuum_data']['changed']|length > 0 %},{% endif %}{{ '\n' }} {% endif %}
{% if data.fillfactor %}
FILLFACTOR = {{ data.fillfactor }}{% if (data['vacuum_data'] is defined and data['vacuum_data']['changed']|length > 0) or (o_data['vacuum_data'] is defined and o_data['vacuum_data']['changed']|length > 0) %},{% endif %}
{% elif o_data.fillfactor %}
FILLFACTOR = {{ o_data.fillfactor }}{% if (data['vacuum_data'] is defined and data['vacuum_data']['changed']|length > 0) or (o_data['vacuum_data'] is defined and o_data['vacuum_data']['changed']|length > 0) %},{% endif %}
{% endif %}
{% if data['vacuum_data']['changed']|length > 0 %}
{% for field in data['vacuum_data']['changed'] %} {{ field.name }} = {{ field.value|lower }}{% if not loop.last %},{{ '\n' }}{% endif %}
{% endfor %}
@ -40,11 +45,14 @@ WITH(
{{ def }}
{% if data.with_data is defined %}
WITH {{ 'DATA' if data.with_data else 'NO DATA' }};
{% elif o_data.with_data %}
{% elif o_data.with_data is defined %}
WITH {{ 'DATA' if o_data.with_data else 'NO DATA' }};
{% endif %}
{% if o_data.comment and not data.comment %}
COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}
IS {{ o_data.comment|qtLiteral }};
{% endif %}
{% else %}
{# ======= Alter Tablespace ========= #}
{%- if data.spcoid and o_data.spcoid != data.spcoid -%}

View File

@ -27,10 +27,12 @@ ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }}
{% if def and def != o_data.definition.rstrip(';') %}
DROP MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }};
CREATE MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}
{% if data.fillfactor or (data['vacuum_data']['changed']|length > 0 ) %}
{% if data.fillfactor or o_data.fillfactor %}
WITH(
{% if data.fillfactor %}
FILLFACTOR = {{ data.fillfactor }}{% if data['vacuum_data']['changed']|length > 0 %},{% endif %}{{ '\n' }}
FILLFACTOR = {{ data.fillfactor }}{% if (data['vacuum_data'] is defined and data['vacuum_data']['changed']|length > 0) or (o_data['vacuum_data'] is defined and o_data['vacuum_data']['changed']|length > 0) %},{% endif %}
{% elif o_data.fillfactor %}
FILLFACTOR = {{ o_data.fillfactor }}{% if (data['vacuum_data'] is defined and data['vacuum_data']['changed']|length > 0) or (o_data['vacuum_data'] is defined and o_data['vacuum_data']['changed']|length > 0) %},{% endif %}
{% endif %}
{% if data['vacuum_data']['changed']|length > 0 %}
{% for field in data['vacuum_data']['changed'] %} {{ field.name }} = {{ field.value|lower }}{% if not loop.last %},{% endif %}{{ '\n' }}
@ -43,10 +45,14 @@ WITH(
{% if data.with_data is defined %}
WITH {{ 'DATA' if data.with_data else 'NO DATA' }};
{% elif o_data.with_data %}
{% elif o_data.with_data is defined %}
WITH {{ 'DATA' if o_data.with_data else 'NO DATA' }};
{% endif %}
{% if o_data.comment and not data.comment %}
COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}
IS {{ o_data.comment|qtLiteral }};
{% endif %}
{% else %}
{# ======= Alter Tablespace ========= #}
{%- if data.spcoid and o_data.spcoid != data.spcoid -%}

View File

@ -10,7 +10,10 @@ WITH (
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
WITH DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO postgres;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -3,4 +3,4 @@ SET(
FILLFACTOR = 18
);
REFRESH MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" WITH NO DATA;
REFRESH MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" WITH DATA;

View File

@ -11,7 +11,10 @@ WITH (
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
WITH DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO postgres;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -6,7 +6,10 @@ CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
TABLESPACE pg_default
AS
SELECT 12
WITH DATA;
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO postgres;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -2,3 +2,7 @@ DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
AS
SELECT 12
WITH NO DATA;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -10,7 +10,10 @@ WITH (
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
WITH DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO postgres;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -16,4 +16,4 @@ COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment-updated';
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres;
GRANT SELECT, UPDATE, DELETE ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -1 +1 @@
GRANT SELECT, UPDATE, DELETE ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -205,7 +205,7 @@
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"fillfactor": "18",
"with_data": false
"with_data": true
},
"expected_sql_file": "alter_mview_add_fillfactor.sql",
"expected_msql_file": "alter_mview_add_fillfactor_msql.sql"

View File

@ -88,18 +88,8 @@
"grantee":"PUBLIC",
"grantor":"postgres",
"privileges":[
{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"d",
"privilege_type":"r",
"privilege":true,
"with_grant":false
}
@ -135,16 +125,6 @@
"privilege_type":"r",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"d",
"privilege":true,
"with_grant":false
}
]
}

View File

@ -1,18 +0,0 @@
-- View: public."testmview_$%{}[]()&*^!/@`#"
-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
TABLESPACE pg_default
AS
SELECT 1
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';
GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC;
GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO enterprisedb;

View File

@ -1,16 +0,0 @@
-- View: public."testmview_$%{}[]()&*^!/@`#"
-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
WITH (
FILLFACTOR = 18,
autovacuum_enabled = false
)
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;

View File

@ -1,6 +0,0 @@
ALTER MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
SET(
FILLFACTOR = 18
);
REFRESH MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" WITH NO DATA;

View File

@ -1,17 +0,0 @@
-- View: public."testmview_$%{}[]()&*^!/@`#"
-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
WITH (
FILLFACTOR = 18,
autovacuum_analyze_scale_factor = 0.2,
autovacuum_enabled = true
)
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;

View File

@ -1,4 +0,0 @@
ALTER MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" SET(
autovacuum_analyze_scale_factor = 0.2,
autovacuum_enabled = true
);

View File

@ -1,12 +0,0 @@
-- View: public."testmview_$%{}[]()&*^!/@`#"
-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
TABLESPACE pg_default
AS
SELECT 12
WITH DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;

View File

@ -1,4 +0,0 @@
DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
AS
SELECT 12

View File

@ -1,17 +0,0 @@
-- View: public."testmview_$%{}[]()&*^!/@`#"
-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
TABLESPACE pg_default
AS
SELECT 1
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';
GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO enterprisedb;

View File

@ -1 +0,0 @@
REVOKE ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" FROM PUBLIC;

View File

@ -1 +0,0 @@
GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC;

View File

@ -1,16 +0,0 @@
-- View: public."testmview_$%{}[]()&*^!/@`#"
-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
WITH (
FILLFACTOR = 18,
autovacuum_enabled = false
)
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;

View File

@ -1,6 +0,0 @@
ALTER MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" SET(
autovacuum_enabled = false
);
ALTER MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" RESET(
autovacuum_analyze_scale_factor
);

View File

@ -1,18 +0,0 @@
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
WITH (
check_option=cascaded,
security_barrier=true
) AS
SELECT test_view_table.col1
FROM test_view_table;
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment-updated';
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -1,19 +0,0 @@
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
WITH (
check_option=cascaded,
security_barrier=true
) AS
SELECT test_view_table.col1
FROM test_view_table;
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment-updated';
GRANT DELETE, UPDATE, SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -1 +0,0 @@
GRANT SELECT, UPDATE, DELETE ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -1,18 +0,0 @@
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
WITH (
check_option=cascaded,
security_barrier=true
) AS
SELECT test_view_table.col1
FROM test_view_table;
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment-updated';
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -1,4 +0,0 @@
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
WITH (check_option=cascaded, security_barrier=true)
AS
SELECT * FROM test_view_table;

View File

@ -1,18 +0,0 @@
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
WITH (
check_option=cascaded,
security_barrier=true
) AS
SELECT test_view_table.col1
FROM test_view_table;
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment-updated';
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -1 +0,0 @@
REVOKE ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" FROM PUBLIC;

View File

@ -1,7 +0,0 @@
ALTER VIEW public."testview_$%{}[]()&*^!@""'`\/#"
SET (security_barrier=true);
ALTER VIEW public."testview_$%{}[]()&*^!@""'`\/#"
SET (check_option=cascaded);
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment-updated';

View File

@ -1,15 +0,0 @@
-- View: public."testmview_$%{}[]()&*^!/@`#"
-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
TABLESPACE pg_default
AS
SELECT 1
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -1,11 +0,0 @@
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
TABLESPACE pg_default
AS
SELECT 1
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -1,17 +0,0 @@
-- View: public."testview_$%{}[]()&*^!@""'`\/#"
-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
WITH (
check_option=local
) AS
SELECT test_view_table.col1
FROM test_view_table;
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment';
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -1,12 +0,0 @@
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
WITH (
check_option=local
) AS
select col1 from test_view_table;
ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
OWNER TO enterprisedb;
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment';
GRANT INSERT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -1,256 +0,0 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Materialised Views",
"endpoint": "NODE-mview.obj",
"sql_endpoint": "NODE-mview.sql_id",
"msql_endpoint": "NODE-mview.msql",
"data": {
"spcname": "pg_default",
"toast_autovacuum_enabled": false,
"autovacuum_enabled": false,
"schema": "public",
"owner": "enterprisedb",
"vacuum_table": [
{
"name": "autovacuum_analyze_scale_factor"
},
{
"name": "autovacuum_analyze_threshold"
},
{
"name": "autovacuum_freeze_max_age"
},
{
"name": "autovacuum_vacuum_cost_delay"
},
{
"name": "autovacuum_vacuum_cost_limit"
},
{
"name": "autovacuum_vacuum_scale_factor"
},
{
"name": "autovacuum_vacuum_threshold"
},
{
"name": "autovacuum_freeze_min_age"
},
{
"name": "autovacuum_freeze_table_age"
}
],
"vacuum_toast": [
{
"name": "autovacuum_freeze_max_age"
},
{
"name": "autovacuum_vacuum_cost_delay"
},
{
"name": "autovacuum_vacuum_cost_limit"
},
{
"name": "autovacuum_vacuum_scale_factor"
},
{
"name": "autovacuum_vacuum_threshold"
},
{
"name": "autovacuum_freeze_min_age"
},
{
"name": "autovacuum_freeze_table_age"
}
],
"datacl": [],
"seclabels": [],
"name": "testmview_$%{}[]()&*^!/@`#",
"comment": "comment1",
"definition": "SELECT 1"
},
"expected_sql_file": "create_mview.sql",
"expected_msql_file": "create_mview_msql.sql"
},
{
"type": "alter",
"name": "Alter Materialised Views (Adding privileges)",
"endpoint": "NODE-mview.obj_id",
"sql_endpoint": "NODE-mview.sql_id",
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"datacl": {
"added": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "d",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "D",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "t",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_mview.sql",
"expected_msql_file": "alter_mview_msql.sql"
},
{
"type": "alter",
"name": "Alter Materialised Views (Remove all privileges)",
"endpoint": "NODE-mview.obj_id",
"sql_endpoint": "NODE-mview.sql_id",
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"datacl": {
"deleted": [
{
"grantee": "PUBLIC",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "d",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "D",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "x",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "t",
"privilege": true,
"with_grant": false
}
]
}
]
}
},
"expected_sql_file": "alter_mview_drop_all_priv.sql",
"expected_msql_file": "alter_mview_drop_all_priv_msql.sql"
},
{
"type": "alter",
"name": "Alter Materialised Views (change definition)",
"endpoint": "NODE-mview.obj_id",
"sql_endpoint": "NODE-mview.sql_id",
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"definition": "SELECT 12;"
},
"expected_sql_file": "alter_mview_definition.sql",
"expected_msql_file": "alter_mview_definition_msql.sql"
},
{
"type": "alter",
"name": "Alter Materialised Views (Fillfactor)",
"endpoint": "NODE-mview.obj_id",
"sql_endpoint": "NODE-mview.sql_id",
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"fillfactor": "18",
"with_data": false
},
"expected_sql_file": "alter_mview_add_fillfactor.sql",
"expected_msql_file": "alter_mview_add_fillfactor_msql.sql"
},
{
"type": "alter",
"name": "Alter Materialised Views (add table parameters)",
"endpoint": "NODE-mview.obj_id",
"sql_endpoint": "NODE-mview.sql_id",
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"autovacuum_custom": true,
"autovacuum_enabled": true,
"vacuum_table": {
"changed": [
{
"name": "autovacuum_analyze_scale_factor",
"value": 0.2
}
]
}
},
"expected_sql_file": "alter_mview_add_table_parameter.sql",
"expected_msql_file": "alter_mview_add_table_parameter_msql.sql"
},
{
"type": "alter",
"name": "Alter Materialised Views (remove table parameters)",
"endpoint": "NODE-mview.obj_id",
"sql_endpoint": "NODE-mview.sql_id",
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"autovacuum_custom": true,
"autovacuum_enabled": false,
"vacuum_table": {
"changed": [
{
"name": "autovacuum_analyze_scale_factor",
"value": null
}
]
}
},
"expected_sql_file": "alter_mview_remove_table_parameter.sql",
"expected_msql_file": "alter_mview_remove_table_parameter_msql.sql"
}
]
}

View File

@ -1,178 +0,0 @@
{
"scenarios": [
{
"type": "create",
"name": "Create Table for Views",
"endpoint": "NODE-table.obj",
"sql_endpoint": "NODE-table.sql_id",
"data": {
"name": "test_view_table",
"check_constraint": [],
"coll_inherits": "[]",
"columns": [
{
"name": "col1",
"cltype": "integer"
}
],
"schema": "public"
}
},
{
"type": "create",
"name": "Create View",
"endpoint": "NODE-view.obj",
"sql_endpoint": "NODE-view.sql_id",
"msql_endpoint": "NODE-view.msql",
"data": {
"definition": "select col1 from test_view_table;",
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
"owner": "enterprisedb",
"schema": "public",
"check_option": "local",
"security_barrier": false,
"comment":"Testcomment",
"datacl":[{"grantee":"enterprisedb", "grantor":"enterprisedb", "privileges":[{"privilege_type": "a", "privilege": true,
"with_grant":false}]}]
},
"expected_sql_file": "create_view.sql",
"expected_msql_file": "create_view_msql.sql"
},
{
"type": "alter",
"name": "Alter View",
"endpoint": "NODE-view.obj_id",
"sql_endpoint": "NODE-view.sql_id",
"msql_endpoint": "NODE-view.msql_id",
"data": {
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
"owner": "enterprisedb",
"schema": "public",
"check_option": "cascaded",
"security_barrier": true,
"comment":"Testcomment-updated",
"datacl":[{"grantee":"enterprisedb", "grantor":"enterprisedb", "privileges":[{"privilege_type": "a", "privilege": true,
"with_grant":false}]}]
},
"expected_sql_file": "alter_view.sql",
"expected_msql_file": "alter_view_msql.sql"
},
{
"type": "alter",
"name": "Alter View (changing code)",
"endpoint": "NODE-view.obj_id",
"sql_endpoint": "NODE-view.sql_id",
"msql_endpoint": "NODE-view.msql_id",
"data": {
"definition": "SELECT * FROM test_view_table;"
},
"expected_sql_file": "alter_view_definition.sql",
"expected_msql_file": "alter_view_definition_msql.sql"
},
{
"type": "alter",
"name": "Alter View (adding privileges)",
"endpoint": "NODE-view.obj_id",
"sql_endpoint": "NODE-view.sql_id",
"msql_endpoint": "NODE-view.msql_id",
"data": {
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
"owner": "enterprisedb",
"schema": "public",
"check_option": "cascaded",
"security_barrier": true,
"comment":"Testcomment-updated",
"datacl":{
"added":[
{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[
{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"d",
"privilege":true,
"with_grant":false
}
]
}
]
}
},
"expected_sql_file": "alter_view_add_some_priv.sql",
"expected_msql_file": "alter_view_add_some_priv_msql.sql"
},
{
"type": "alter",
"name": "Alter View (deleting privileges)",
"endpoint": "NODE-view.obj_id",
"sql_endpoint": "NODE-view.sql_id",
"msql_endpoint": "NODE-view.msql_id",
"data": {
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
"owner": "enterprisedb",
"schema": "public",
"check_option": "cascaded",
"security_barrier": true,
"comment":"Testcomment-updated",
"datacl":
{
"deleted":[
{
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[
{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"d",
"privilege":true,
"with_grant":false
}
]
}
]
}
},
"expected_sql_file": "alter_view_delete_priv.sql",
"expected_msql_file": "alter_view_delete_priv_msql.sql"
},
{
"type": "delete",
"name": "Drop View",
"endpoint": "NODE-view.obj_id",
"data": {
"name": "testview_$%{}[]()&*^!@\"'`\\/#",
"owner": "enterprisedb",
"schema": "public"
}
},
{
"type": "delete",
"name": "Drop Table for view",
"endpoint": "NODE-table.obj_id",
"data": {
"name": "test_view_table",
"owner": "enterprisedb",
"schema": "public"
}
}
]
}

View File

@ -10,7 +10,10 @@ WITH (
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
WITH DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -3,4 +3,4 @@ SET(
FILLFACTOR = 18
);
REFRESH MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" WITH NO DATA;
REFRESH MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" WITH DATA;

View File

@ -11,7 +11,10 @@ WITH (
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
WITH DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -6,7 +6,10 @@ CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
TABLESPACE pg_default
AS
SELECT 12
WITH DATA;
WITH NO DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -2,3 +2,7 @@ DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#";
CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
AS
SELECT 12
WITH NO DATA;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -10,7 +10,10 @@ WITH (
TABLESPACE pg_default
AS
SELECT 12
WITH NO DATA;
WITH DATA;
ALTER TABLE public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -15,5 +15,5 @@ ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#"
COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#"
IS 'Testcomment-updated';
GRANT SELECT, UPDATE, DELETE ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb;

View File

@ -1 +1 @@
GRANT SELECT, UPDATE, DELETE ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;
GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -205,7 +205,7 @@
"msql_endpoint": "NODE-mview.msql_id",
"data": {
"fillfactor": "18",
"with_data": false
"with_data": true
},
"expected_sql_file": "alter_mview_add_fillfactor.sql",
"expected_msql_file": "alter_mview_add_fillfactor_msql.sql"

View File

@ -88,20 +88,10 @@
"grantee":"PUBLIC",
"grantor":"enterprisedb",
"privileges":[
{
{
"privilege_type":"r",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"d",
"privilege":true,
"with_grant":false
}
]
}
@ -135,16 +125,6 @@
"privilege_type":"r",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"w",
"privilege":true,
"with_grant":false
},
{
"privilege_type":"d",
"privilege":true,
"with_grant":false
}
]
}

View File

@ -1305,6 +1305,40 @@ define('pgadmin.browser.node', [
}
}.bind(panel),
warnBeforeAttributeChange = function(yes_callback) {
var j = this.$container.find('.obj_properties').first(),
view = j && j.data('obj-view'),
self = this;
if (view && view.model && !_.isUndefined(view.model.warn_text) && !_.isNull(view.model.warn_text)) {
let warn_text;
warn_text = gettext(view.model.warn_text);
if(view.model.sessChanged()){
Alertify.confirm(
gettext('Warning'),
warn_text,
function() {
setTimeout(function(){
yes_callback();
}.bind(self), 50);
return true;
},
function() {
return true;
}
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
}).show();
} else {
return true;
}
} else {
yes_callback();
return true;
}
}.bind(panel),
onSave = function(view, saveBtn) {
var m = view.model,
d = m.toJSON(true),
@ -1498,7 +1532,14 @@ define('pgadmin.browser.node', [
register: function(btn) {
// Save the changes
btn.on('click',() => {
onSave.call(this, view, btn);
warnBeforeAttributeChange.call(
panel,
function() {
setTimeout(function() {
onSave.call(this, view, btn);
}, 0);
}
);
});
},
}], 'footer', 'pg-prop-btn-group-below');