diff --git a/docs/en_US/images/view_definition.png b/docs/en_US/images/view_definition.png index fe1a63372..40abb27de 100644 Binary files a/docs/en_US/images/view_definition.png and b/docs/en_US/images/view_definition.png differ diff --git a/docs/en_US/images/view_sql.png b/docs/en_US/images/view_sql.png index 188563130..43ebf411e 100644 Binary files a/docs/en_US/images/view_sql.png and b/docs/en_US/images/view_sql.png differ diff --git a/docs/en_US/view_dialog.rst b/docs/en_US/view_dialog.rst index 1b810736f..5b5c82c2c 100644 --- a/docs/en_US/view_dialog.rst +++ b/docs/en_US/view_dialog.rst @@ -39,7 +39,10 @@ Use the fields in the *Definition* tab to define properties of the view: * Set the *Security Barrier* switch to *Yes* to indicate that the view is to act as a security barrier. For more information about defining and using a - security barrier rule, see Section 38.5 of the PostgreSQL documentation. + security barrier rule, see Rules and Privileges of the PostgreSQL documentation. +* Set the *Security Invoker* switch to *Yes* to indicate that the underlying base + relations are to be checked against the privileges of the user of the view rather + than the view owner. This option is available from PostgreSQL 15 onwards. * Use the drop-down listbox next to *Check options* to select from *No*, *Local* or *Cascaded*: diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/pg/15_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/pg/15_plus/sql/create.sql index a85e735ee..2fb14ac02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/pg/15_plus/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/pg/15_plus/sql/create.sql @@ -13,14 +13,14 @@ {### Create PUBLICATION ###} CREATE PUBLICATION {{ conn|qtIdent(data.name) }} {% if data.all_table %} - FOR ALL TABLES + FOR ALL TABLES {% elif data.pubtable or data.pubschema %} - FOR {% if data.pubtable %}TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{pub_table['table_name']}}{% if pub_table['columns'] %} ({% for column in pub_table['columns'] %}{% if loop.index != 1 %}, {% endif %}{{column}}{% endfor %}){% endif %}{% if pub_table['where'] %} WHERE ({{pub_table['where']}}){% endif %}{% endfor %}{% endif %}{% if data.pubtable and data.pubschema %},{% endif %} + FOR {% if data.pubtable %}TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{pub_table['table_name']}}{% if pub_table['columns'] %} ({% for column in pub_table['columns'] %}{% if loop.index != 1 %}, {% endif %}{{column}}{% endfor %}){% endif %}{% if pub_table['where'] %} WHERE ({{pub_table['where']}}){% endif %}{% endfor %}{% endif %}{% if data.pubtable and data.pubschema %},{% endif %} {% if data.pubschema %} TABLES IN SCHEMA {% for pub_schema in data.pubschema %}{% if loop.index != 1 %}, {% endif %}{{ pub_schema }}{% endfor %} {% endif %} {% endif %} {% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %} - WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }}); + WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }}); {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/ppas/15_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/ppas/15_plus/sql/create.sql index a85e735ee..2fb14ac02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/ppas/15_plus/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/templates/publications/ppas/15_plus/sql/create.sql @@ -13,14 +13,14 @@ {### Create PUBLICATION ###} CREATE PUBLICATION {{ conn|qtIdent(data.name) }} {% if data.all_table %} - FOR ALL TABLES + FOR ALL TABLES {% elif data.pubtable or data.pubschema %} - FOR {% if data.pubtable %}TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{pub_table['table_name']}}{% if pub_table['columns'] %} ({% for column in pub_table['columns'] %}{% if loop.index != 1 %}, {% endif %}{{column}}{% endfor %}){% endif %}{% if pub_table['where'] %} WHERE ({{pub_table['where']}}){% endif %}{% endfor %}{% endif %}{% if data.pubtable and data.pubschema %},{% endif %} + FOR {% if data.pubtable %}TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{pub_table['table_name']}}{% if pub_table['columns'] %} ({% for column in pub_table['columns'] %}{% if loop.index != 1 %}, {% endif %}{{column}}{% endfor %}){% endif %}{% if pub_table['where'] %} WHERE ({{pub_table['where']}}){% endif %}{% endfor %}{% endif %}{% if data.pubtable and data.pubschema %},{% endif %} {% if data.pubschema %} TABLES IN SCHEMA {% for pub_schema in data.pubschema %}{% if loop.index != 1 %}, {% endif %}{{ pub_schema }}{% endfor %} {% endif %} {% endif %} {% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %} - WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }}); + WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }}); {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication.sql deleted file mode 100644 index 69e4e112b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Publication: alterd_publication - --- DROP PUBLICATION IF EXISTS alterd_publication; - -CREATE PUBLICATION alterd_publication - FOR ALL TABLES - WITH (publish = 'insert, update', publish_via_partition_root = false); diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_schemas.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_schemas.sql index 4f44598d9..49d016ec7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_schemas.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_schemas.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLES IN SCHEMA test_schema_publication, test_schema_publication_2 - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLES IN SCHEMA test_schema_publication, test_schema_publication_2 + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables.sql index 31ab428ab..6a568e378 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, public.test_table_publication_2 - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, public.test_table_publication_2 + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns.sql index 21252b513..11a8fdbea 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_id) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_id) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns_where.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns_where.sql index 1dde4fa25..91012b43e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns_where.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_columns_where.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_id) WHERE ((dept_id = 2)) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_id) WHERE ((dept_id = 2)) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_where.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_where.sql index dd3d72488..0a7a4eb22 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_where.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_add_tables_where.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, public.test_table_publication_2 WHERE ((dept_id = 2)) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, public.test_table_publication_2 WHERE ((dept_id = 2)) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_schemas.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_schemas.sql index 8444eafb6..743301c03 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_schemas.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_schemas.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLES IN SCHEMA test_schema_publication_2 - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLES IN SCHEMA test_schema_publication_2 + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_tables.sql index 7c806b089..f1713b9b1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_tables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_drop_tables.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_event.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_event.sql index 7eb05bdac..10c31c05f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_event.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_event.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS alterd_publication; CREATE PUBLICATION alterd_publication - FOR ALL TABLES - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); + FOR ALL TABLES + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_msql.sql deleted file mode 100644 index f799b60df..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER PUBLICATION test_publication_create - RENAME TO alterd_publication; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns.sql index c42c6bb88..fdffbe593 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_name) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_name) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns_where.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns_where.sql index cbe382337..c5b177869 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns_where.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_columns_where.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_name) WHERE ((dept_name = 'test'::text)) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_name) WHERE ((dept_name = 'test'::text)) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_where.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_where.sql index de0918090..02ef1ac54 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_where.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/alter_publication_set_tables_where.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, public.test_table_publication_2 WHERE ((dept_name = 'test'::text)) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, public.test_table_publication_2 WHERE ((dept_name = 'test'::text)) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication.sql deleted file mode 100644 index 266553d7b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Publication: test_publication_create - --- DROP PUBLICATION IF EXISTS test_publication_create; - -CREATE PUBLICATION test_publication_create - FOR ALL TABLES - WITH (publish = 'insert, update', publish_via_partition_root = false); diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas.sql index be8498ce8..e2d2ad552 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLES IN SCHEMA test_schema_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLES IN SCHEMA test_schema_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas_msql.sql index caa4333c0..1427cffbe 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_schemas_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLES IN SCHEMA test_schema_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLES IN SCHEMA test_schema_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables.sql index 7c806b089..f1713b9b1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns.sql index 9594b98a3..1f3d2af2a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication (emp_id, name) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication (emp_id, name) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_msql.sql index cc095ec98..4515210e3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication (emp_id, name) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication (emp_id, name) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where.sql index 8f1a98111..6a5575633 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication (emp_id, name) WHERE (((emp_id = 2) AND (name = 'test'::text))) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication (emp_id, name) WHERE (((emp_id = 2) AND (name = 'test'::text))) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where_msql.sql index a8f72b4ff..885d6b023 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_columns_where_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication (emp_id, name) WHERE (emp_id=2 and name='test') - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication (emp_id, name) WHERE (emp_id=2 and name='test') + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_msql.sql index 878660992..63e7e8b51 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only.sql index 7c806b089..f1713b9b1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only_msql.sql index 0cff3b522..f42e7c1b5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_only_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLE ONLY public.test_table_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE ONLY public.test_table_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas.sql index f34aeb82b..1329bb993 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, TABLES IN SCHEMA test_schema_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, TABLES IN SCHEMA test_schema_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas_msql.sql index ecc7399e1..45ddb0c07 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_schemas_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication, TABLES IN SCHEMA test_schema_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication, TABLES IN SCHEMA test_schema_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where.sql index 85c23bae6..6a7260743 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication WHERE (((emp_id = 2) AND (name = 'test'::text))) - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication WHERE (((emp_id = 2) AND (name = 'test'::text))) + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_msql.sql index 980fdd686..876fdf866 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication WHERE (emp_id=2 and name='test') - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication WHERE (emp_id=2 and name='test') + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas.sql index c376b165d..2827941ee 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas.sql @@ -3,5 +3,5 @@ -- DROP PUBLICATION IF EXISTS test_publication_create; CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication WHERE (((emp_id = 2) AND (name = 'test'::text))), TABLES IN SCHEMA test_schema_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication WHERE (((emp_id = 2) AND (name = 'test'::text))), TABLES IN SCHEMA test_schema_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas_msql.sql index d3d91a615..d6294271a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_few_tables_where_schemas_msql.sql @@ -1,3 +1,3 @@ CREATE PUBLICATION test_publication_create - FOR TABLE public.test_table_publication WHERE (emp_id=2 and name='test'), TABLES IN SCHEMA test_schema_publication - WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file + FOR TABLE public.test_table_publication WHERE (emp_id=2 and name='test'), TABLES IN SCHEMA test_schema_publication + WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_msql.sql deleted file mode 100644 index 27a371d68..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/15_plus/create_publication_msql.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE PUBLICATION test_publication_create - FOR ALL TABLES - WITH (publish = 'insert, update', publish_via_partition_root = false); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js index e44542bcf..5dd126039 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui.js @@ -74,6 +74,10 @@ export default class ViewSchema extends BaseUISchema { id: 'security_barrier', label: gettext('Security barrier?'), type: 'switch', min_version: '90200', group: gettext('Definition'), disabled: obj.notInSchema, + },{ + id: 'security_invoker', label: gettext('Security invoker?'), + type: 'switch', min_version: '150000', group: gettext('Definition'), + disabled: obj.notInSchema, },{ id: 'check_option', label: gettext('Check options'), type: 'select', group: gettext('Definition'), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/create.sql new file mode 100644 index 000000000..7a363073e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/create.sql @@ -0,0 +1,32 @@ +{#============================Create new view=========================#} +{% if display_comments %} +-- View: {{ data.schema }}.{{ data.name }} + +-- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; + +{% endif %} +{% if data.name and data.schema and data.definition %} +CREATE{% if add_replace_clause %} OR REPLACE{% endif %} VIEW {{ conn|qtIdent(data.schema, data.name) }} +{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier or data.security_invoker) %} +WITH ( +{% if data.check_option and data.check_option.lower() != 'no' %} + check_option={{ data.check_option }}{% if data.security_barrier or data.security_invoker %}, +{% endif %}{% endif %} +{% if data.security_barrier %} + security_barrier={{ data.security_barrier|lower }}{% if data.security_invoker %}, +{% endif %}{% endif %} +{% if data.security_invoker %} + security_invoker={{ data.security_invoker|lower }}{% endif %} + +){% endif %} AS +{{ data.definition.rstrip(';') }}; +{% if data.owner and data.m_view is undefined %} + +ALTER TABLE {{ conn|qtIdent(data.schema, data.name) }} + OWNER TO {{ conn|qtIdent(data.owner) }}; +{% endif %} +{% if data.comment %} +COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} + IS {{ data.comment|qtLiteral(conn) }}; +{% endif %} +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/properties.sql new file mode 100644 index 000000000..1664db2fe --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/properties.sql @@ -0,0 +1,73 @@ +{# ========================== Fetch View Properties ========================= #} +{% if (vid and datlastsysoid) or scid %} +SELECT + c.oid, + c.xmin, + c.relkind, + description AS comment, + (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, + c.relname AS name, + c.reltablespace AS spcoid, + nsp.nspname AS schema, + c.relispopulated AS ispopulated, + pg_catalog.pg_get_userbyid(c.relowner) AS owner, + pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, + pg_catalog.pg_get_viewdef(c.oid, true) AS definition, + {# ===== Checks if it is system view ===== #} + {% if vid and datlastsysoid %} + CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, + {% endif %} + (SELECT + pg_catalog.array_agg(provider || '=' || label) + FROM + pg_catalog.pg_seclabels sl1 + WHERE + sl1.objoid=c.oid AND sl1.objsubid=0 + ) AS seclabels, + substring(pg_catalog.array_to_string(c.reloptions, ',') + FROM 'check_option=([a-z]*)') AS check_option, + (substring(pg_catalog.array_to_string(c.reloptions, ',') + FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier, + (substring(pg_catalog.array_to_string(c.reloptions, ',') + FROM 'security_invoker=([a-z|0-9]*)'))::boolean AS security_invoker +FROM pg_catalog.pg_class c +LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace +LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace +LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) + WHERE ((c.relhasrules AND (EXISTS ( + SELECT + r.rulename + FROM + pg_catalog.pg_rewrite r + WHERE + ((r.ev_class = c.oid) + AND (bpchar(r.ev_type) = '1'::bpchar)) ))) + AND (c.relkind = 'v'::char) + ) +{% if (vid and datlastsysoid) %} + AND c.oid = {{vid}}::oid +{% elif scid %} + AND c.relnamespace = {{scid}}::oid +ORDER BY + c.relname +{% endif %} + +{% elif type == 'roles' %} +SELECT + pr.rolname +FROM + pg_catalog.pg_roles pr +WHERE + pr.rolcanlogin +ORDER BY + pr.rolname + +{% elif type == 'schemas' %} +SELECT + nsp.nspname +FROM + pg_catalog.pg_namespace nsp +WHERE + (nsp.nspname NOT LIKE E'pg\\_%' + AND nsp.nspname != 'information_schema') +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/update.sql new file mode 100644 index 000000000..252516605 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/15_plus/sql/update.sql @@ -0,0 +1,106 @@ +{# ============================ Update View ========================= #} +{% import 'macros/schemas/security.macros' as SECLABEL %} +{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} +{% if data %} +{% set view_name = data.name if data.name else o_data.name %} +{% set view_schema = data.schema if data.schema else o_data.schema %} +{% set def = data.definition.rstrip(';') if data.definition %} +{% if data.name and data.name != o_data.name %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, o_data.name) }} + RENAME TO {{ conn|qtIdent(data.name) }}; +{% endif %} +{% if data.schema and data.schema != o_data.schema %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, view_name ) }} + SET SCHEMA {{ conn|qtIdent(data.schema) }}; +{% endif %} +{% if def and def != o_data.definition.rstrip(';') %} +{% if data.del_sql %} +DROP VIEW {{ conn|qtIdent(view_schema, view_name) }}; + +{% endif %} +CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} +{% if ((data.check_option and data.check_option.lower() != 'no') or (o_data.check_option and o_data.check_option.lower() != 'no') or data.security_barrier or o_data.security_barrier or data.security_invoker or o_data.security_invoker) %} + WITH ({% if (data.check_option or o_data.check_option) %}check_option={{ data.check_option if data.check_option else o_data.check_option }}{{', ' }}{% endif %}security_barrier={{ data.security_barrier|lower if data.security_barrier is defined else o_data.security_barrier|default('false', 'true')|lower }}{{', ' }}security_invoker={{ data.security_invoker|lower if data.security_invoker is defined else o_data.security_invoker|default('false', 'true')|lower }}) +{% endif %} + AS + {{ def }}; +{% if data.del_sql and data.owner is not defined %} + +ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }} + OWNER TO {{ conn|qtIdent(o_data.owner) }}; +{% endif %} +{% else %} +{% if (data.security_barrier is defined and data.security_barrier|lower != o_data.security_barrier|lower) %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + SET (security_barrier={{ data.security_barrier|lower }}); +{% endif %} +{% if (data.security_invoker is defined and data.security_invoker|lower != o_data.security_invoker|lower) %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + SET (security_invoker={{ data.security_invoker|lower }}); +{% endif %} +{% if (data.check_option and data.check_option != o_data.check_option and data.check_option != 'no') %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + SET (check_option={{ data.check_option }}); +{% elif (data.check_option and data.check_option != o_data.check_option and data.check_option == 'no') %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} RESET (check_option); +{% endif %} +{% endif %} +{% if data.owner and data.owner != o_data.owner %} +ALTER TABLE IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + OWNER TO {{ conn|qtIdent(data.owner) }}; +{% endif %} +{% set old_comment = o_data.comment|default('', true) %} +{% if (data.comment is defined and (data.comment != old_comment)) %} + +COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} + IS {{ data.comment|qtLiteral(conn) }}; +{% elif data.del_sql == True and old_comment != '' %} +COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} + IS {{ old_comment|qtLiteral(conn) }}; +{% endif %} +{# The SQL generated below will change privileges #} +{% if o_data.acl_sql and o_data.acl_sql != '' %} +{{o_data['acl_sql']}} +{% endif %} +{% if data.datacl %} +{% if 'deleted' in data.datacl %} +{% for priv in data.datacl.deleted %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endfor %} +{% endif %} +{% if 'changed' in data.datacl %} +{% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} +{% endfor %} +{% endif %} +{% if 'added' in data.datacl %} +{% for priv in data.datacl.added %} +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} +{% endfor %} +{% endif %} +{% endif %} +{# The SQL generated below will change Security Label #} +{% if data.seclabels is not none and data.seclabels|length > 0 %} +{% set seclabels = data.seclabels %} +{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} +{% for r in seclabels.deleted %} +{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} +{% endfor %} +{% endif %} +{% if 'added' in seclabels and seclabels.added|length > 0 %} +{% for r in seclabels.added %} +{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} +{% endfor %} +{% endif %} +{% if 'changed' in seclabels and seclabels.changed|length > 0 %} +{% for r in seclabels.changed %} +{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} +{% endfor %} +{% endif %} +{% endif %} +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/create.sql index 99b8f83c9..e78c04626 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/create.sql @@ -10,7 +10,7 @@ CREATE{% if add_replace_clause %} OR REPLACE{% endif %} VIEW {{ conn|qtIdent(dat {% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %} WITH ({% if data.check_option and data.check_option.lower() != 'no' %} - check_option={{ data.check_option }}{% endif %}{{ ',' if data.check_option and data.check_option.lower() != 'no' and data.security_barrier }} + check_option={{ data.check_option }}{% endif %}{{ ',' if data.security_barrier }} {% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/update.sql index a25ddff8b..4da58482f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/update.sql @@ -19,7 +19,7 @@ DROP VIEW {{ conn|qtIdent(view_schema, view_name) }}; {% endif %} CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} -{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %} +{% if ((data.check_option and data.check_option.lower() != 'no') or (o_data.check_option and o_data.check_option.lower() != 'no') or data.security_barrier or o_data.security_barrier) %} WITH ({% if (data.check_option or o_data.check_option) %}check_option={{ data.check_option if data.check_option else o_data.check_option }}{{', ' }}{% endif %}security_barrier={{ data.security_barrier|lower if data.security_barrier is defined else o_data.security_barrier|default('false', 'true')|lower }}) {% endif %} AS diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/create.sql new file mode 100644 index 000000000..6c53b8c4a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/create.sql @@ -0,0 +1,32 @@ +{#============================Create new view=========================#} +{% if display_comments %} +-- View: {{ data.schema }}.{{ data.name }} + +-- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; + +{% endif %} +{% if data.name and data.schema and data.definition %} +CREATE{% if add_replace_clause %} OR REPLACE{% endif %} VIEW {{ conn|qtIdent(data.schema, data.name) }} +{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier or data.security_invoker) %} +WITH ( +{% if data.check_option and data.check_option.lower() != 'no' %} + check_option={{ data.check_option }}{% if data.security_barrier or data.security_invoker %}, +{% endif %}{% endif %} +{% if data.security_barrier %} + security_barrier={{ data.security_barrier|lower }}{% if data.security_invoker %}, +{% endif %}{% endif %} +{% if data.security_invoker %} + security_invoker={{ data.security_invoker|lower }}{% endif %} + +){% endif %} AS +{{ data.definition.rstrip(';') }}; +{% if data.owner and data.m_view is undefined %} + +ALTER TABLE IF EXISTS {{ conn|qtIdent(data.schema, data.name) }} + OWNER TO {{ conn|qtIdent(data.owner) }}; +{% endif %} +{% if data.comment %} +COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} + IS {{ data.comment|qtLiteral(conn) }}; +{% endif %} +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/properties.sql new file mode 100644 index 000000000..ccbf99dee --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/properties.sql @@ -0,0 +1,73 @@ +{# ========================== Fetch View Properties ========================= #} +{% if (vid and datlastsysoid) or scid %} +SELECT + c.oid, + c.xmin, + c.relkind, + description AS comment, + (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, + c.relname AS name, + c.reltablespace AS spcoid, + nsp.nspname AS schema, + c.relispopulated AS ispopulated, + pg_catalog.pg_get_userbyid(c.relowner) AS owner, + pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, + pg_catalog.pg_get_viewdef(c.oid) AS definition, + {# ===== Checks if it is system view ===== #} + {% if vid and datlastsysoid %} + CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, + {% endif %} + (SELECT + pg_catalog.array_agg(provider || '=' || label) + FROM + pg_catalog.pg_seclabels sl1 + WHERE + sl1.objoid=c.oid AND sl1.objsubid=0 + ) AS seclabels, + substring(pg_catalog.array_to_string(c.reloptions, ',') + FROM 'check_option=([a-z]*)') AS check_option, + (substring(pg_catalog.array_to_string(c.reloptions, ',') + FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier, + (substring(pg_catalog.array_to_string(c.reloptions, ',') + FROM 'security_invoker=([a-z|0-9]*)'))::boolean AS security_invoker +FROM pg_catalog.pg_class c +LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace +LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace +LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) + WHERE ((c.relhasrules AND (EXISTS ( + SELECT + r.rulename + FROM + pg_catalog.pg_rewrite r + WHERE + ((r.ev_class = c.oid) + AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar)) ))) + AND (c.relkind = 'v'::char) + ) +{% if (vid and datlastsysoid) %} + AND c.oid = {{vid}}::oid +{% elif scid %} + AND c.relnamespace = {{scid}}::oid +ORDER BY + c.relname +{% endif %} + +{% elif type == 'roles' %} +SELECT + pr.rolname +FROM + pg_catalog.pg_roles pr +WHERE + pr.rolcanlogin +ORDER BY + pr.rolname + +{% elif type == 'schemas' %} +SELECT + nsp.nspname +FROM + pg_catalog.pg_namespace nsp +WHERE + (nsp.nspname NOT LIKE E'pg\\_%' + AND nsp.nspname != 'information_schema') +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/update.sql new file mode 100644 index 000000000..252516605 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/15_plus/sql/update.sql @@ -0,0 +1,106 @@ +{# ============================ Update View ========================= #} +{% import 'macros/schemas/security.macros' as SECLABEL %} +{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} +{% if data %} +{% set view_name = data.name if data.name else o_data.name %} +{% set view_schema = data.schema if data.schema else o_data.schema %} +{% set def = data.definition.rstrip(';') if data.definition %} +{% if data.name and data.name != o_data.name %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, o_data.name) }} + RENAME TO {{ conn|qtIdent(data.name) }}; +{% endif %} +{% if data.schema and data.schema != o_data.schema %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, view_name ) }} + SET SCHEMA {{ conn|qtIdent(data.schema) }}; +{% endif %} +{% if def and def != o_data.definition.rstrip(';') %} +{% if data.del_sql %} +DROP VIEW {{ conn|qtIdent(view_schema, view_name) }}; + +{% endif %} +CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} +{% if ((data.check_option and data.check_option.lower() != 'no') or (o_data.check_option and o_data.check_option.lower() != 'no') or data.security_barrier or o_data.security_barrier or data.security_invoker or o_data.security_invoker) %} + WITH ({% if (data.check_option or o_data.check_option) %}check_option={{ data.check_option if data.check_option else o_data.check_option }}{{', ' }}{% endif %}security_barrier={{ data.security_barrier|lower if data.security_barrier is defined else o_data.security_barrier|default('false', 'true')|lower }}{{', ' }}security_invoker={{ data.security_invoker|lower if data.security_invoker is defined else o_data.security_invoker|default('false', 'true')|lower }}) +{% endif %} + AS + {{ def }}; +{% if data.del_sql and data.owner is not defined %} + +ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }} + OWNER TO {{ conn|qtIdent(o_data.owner) }}; +{% endif %} +{% else %} +{% if (data.security_barrier is defined and data.security_barrier|lower != o_data.security_barrier|lower) %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + SET (security_barrier={{ data.security_barrier|lower }}); +{% endif %} +{% if (data.security_invoker is defined and data.security_invoker|lower != o_data.security_invoker|lower) %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + SET (security_invoker={{ data.security_invoker|lower }}); +{% endif %} +{% if (data.check_option and data.check_option != o_data.check_option and data.check_option != 'no') %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + SET (check_option={{ data.check_option }}); +{% elif (data.check_option and data.check_option != o_data.check_option and data.check_option == 'no') %} +ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} RESET (check_option); +{% endif %} +{% endif %} +{% if data.owner and data.owner != o_data.owner %} +ALTER TABLE IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} + OWNER TO {{ conn|qtIdent(data.owner) }}; +{% endif %} +{% set old_comment = o_data.comment|default('', true) %} +{% if (data.comment is defined and (data.comment != old_comment)) %} + +COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} + IS {{ data.comment|qtLiteral(conn) }}; +{% elif data.del_sql == True and old_comment != '' %} +COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} + IS {{ old_comment|qtLiteral(conn) }}; +{% endif %} +{# The SQL generated below will change privileges #} +{% if o_data.acl_sql and o_data.acl_sql != '' %} +{{o_data['acl_sql']}} +{% endif %} +{% if data.datacl %} +{% if 'deleted' in data.datacl %} +{% for priv in data.datacl.deleted %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endfor %} +{% endif %} +{% if 'changed' in data.datacl %} +{% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} +{% endfor %} +{% endif %} +{% if 'added' in data.datacl %} +{% for priv in data.datacl.added %} +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} +{% endfor %} +{% endif %} +{% endif %} +{# The SQL generated below will change Security Label #} +{% if data.seclabels is not none and data.seclabels|length > 0 %} +{% set seclabels = data.seclabels %} +{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} +{% for r in seclabels.deleted %} +{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} +{% endfor %} +{% endif %} +{% if 'added' in seclabels and seclabels.added|length > 0 %} +{% for r in seclabels.added %} +{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} +{% endfor %} +{% endif %} +{% if 'changed' in seclabels and seclabels.changed|length > 0 %} +{% for r in seclabels.changed %} +{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} +{% endfor %} +{% endif %} +{% endif %} +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/create.sql index f12e4ecc3..f6a23af6d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/create.sql @@ -10,7 +10,7 @@ CREATE{% if add_replace_clause %} OR REPLACE{% endif %} VIEW {{ conn|qtIdent(dat {% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %} WITH ({% if data.check_option and data.check_option.lower() != 'no' %} - check_option={{ data.check_option }}{% endif %}{{ ',' if data.check_option and data.check_option.lower() != 'no' and data.security_barrier }} + check_option={{ data.check_option }}{% endif %}{{ ',' if data.security_barrier }} {% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/update.sql index a25ddff8b..4da58482f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/update.sql @@ -19,7 +19,7 @@ DROP VIEW {{ conn|qtIdent(view_schema, view_name) }}; {% endif %} CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} -{% if ((data.check_option and data.check_option.lower() != 'no') or data.security_barrier) %} +{% if ((data.check_option and data.check_option.lower() != 'no') or (o_data.check_option and o_data.check_option.lower() != 'no') or data.security_barrier or o_data.security_barrier) %} WITH ({% if (data.check_option or o_data.check_option) %}check_option={{ data.check_option if data.check_option else o_data.check_option }}{{', ' }}{% endif %}security_barrier={{ data.security_barrier|lower if data.security_barrier is defined else o_data.security_barrier|default('false', 'true')|lower }}) {% endif %} AS diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view.sql new file mode 100644 index 000000000..38dd7f916 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_add_some_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_add_some_priv.sql new file mode 100644 index 000000000..17c23f10d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_add_some_priv.sql @@ -0,0 +1,20 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_definition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_definition.sql new file mode 100644 index 000000000..38dd7f916 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_definition.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_definition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_definition_msql.sql new file mode 100644 index 000000000..26a21ddd7 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_definition_msql.sql @@ -0,0 +1,12 @@ +DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" + WITH (check_option=cascaded, security_barrier=true, security_invoker=true) + AS + SELECT * FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; +GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_delete_priv.sql new file mode 100644 index 000000000..e203e8ad3 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_delete_priv.sql @@ -0,0 +1,18 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_msql.sql new file mode 100644 index 000000000..d84f10549 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_msql.sql @@ -0,0 +1,9 @@ +ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + SET (security_barrier=true); +ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + SET (security_invoker=true); +ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + SET (check_option=cascaded); + +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..8fac5ce35 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/alter_view_update_priv.sql @@ -0,0 +1,20 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/test_mview.json new file mode 100644 index 000000000..1feb2d1a5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/test_mview.json @@ -0,0 +1,259 @@ +{ + "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", + "schema": "public", + "owner": "postgres", + "datacl": [], + "seclabels": [], + "name": "testmview_$%{}[]()&*^!/@`#", + "comment": "comment1", + "definition": "SELECT 1 AS col1" + }, + "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": "postgres", + "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": "postgres", + "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 grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "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_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_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 AS col1;" + }, + "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": true + }, + "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": "t", + "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": "x", + "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" + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/tests.json new file mode 100644 index 000000000..aae4702db --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/15_plus/tests.json @@ -0,0 +1,225 @@ +{ + "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": "postgres", + "schema": "public", + "check_option": "local", + "security_barrier": false, + "security_invoker": false, + "comment":"Testcomment", + "datacl":[{"grantee":"postgres", "old_grantee": "postgres", "grantor":"postgres", "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": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "security_invoker": true, + "comment":"Testcomment-updated", + "datacl":[{"grantee":"postgres", "grantor":"postgres", "old_grantee": "postgres", "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": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl":{ + "added":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[ + { + "privilege_type":"r", + "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 (PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (postgres to PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "old_grantee": "postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_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": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[ + { + "privilege_type":"r", + "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": "postgres", + "schema": "public" + } + }, + { + "type": "delete", + "name": "Drop Table for view", + "endpoint": "NODE-table.obj_id", + "data": { + "name": "test_view_table", + "owner": "postgres", + "schema": "public" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv_msql.sql index 4e7a843f8..285bb2268 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv_msql.sql @@ -1,5 +1 @@ -ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" - SET (security_barrier=true); -ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" - SET (check_option=cascaded); GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition.sql index b28f8a418..b3b83cd0d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition.sql @@ -3,7 +3,10 @@ -- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" - AS +WITH ( + check_option=cascaded, + security_barrier=true +) AS SELECT test_view_table.col1 FROM test_view_table; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition_msql.sql index a6d42aefc..a0d45d9a7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition_msql.sql @@ -1,6 +1,7 @@ DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" + WITH (check_option=cascaded, security_barrier=true) AS SELECT * FROM test_view_table; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view.sql new file mode 100644 index 000000000..54d6ec84d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_add_some_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_add_some_priv.sql new file mode 100644 index 000000000..8368ea8e9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_add_some_priv.sql @@ -0,0 +1,20 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_delete_priv.sql new file mode 100644 index 000000000..72b31a7e3 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_delete_priv.sql @@ -0,0 +1,17 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_msql.sql new file mode 100644 index 000000000..d84f10549 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_msql.sql @@ -0,0 +1,9 @@ +ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + SET (security_barrier=true); +ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + SET (security_invoker=true); +ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + SET (check_option=cascaded); + +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..4f1b227d2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/alter_view_update_priv.sql @@ -0,0 +1,20 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true, + security_invoker=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/test_mview.json new file mode 100644 index 000000000..aacf62106 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/test_mview.json @@ -0,0 +1,259 @@ +{ + "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", + "schema": "public", + "owner": "enterprisedb", + "datacl": [], + "seclabels": [], + "name": "testmview_$%{}[]()&*^!/@`#", + "comment": "comment1", + "definition": "SELECT 1 AS col1" + }, + "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 grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "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_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_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 AS col1;" + }, + "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": true + }, + "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": "t", + "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": "x", + "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" + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/tests.json new file mode 100644 index 000000000..c8111f9f5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/15_plus/tests.json @@ -0,0 +1,207 @@ +{ + "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, + "security_invoker": 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, + "security_invoker": 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 (adding privileges)", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "datacl":{ + "added":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "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 (PUBLIC))", + "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 + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (enterprisedb to PUBLIC))", + "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": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "old_grantee": "enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_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 + } + ] + } + ] + } + }, + "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" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json index d693ad174..a42a66bdb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json @@ -11,7 +11,8 @@ "datacl": [], "seclabels": [], "name": "test_view_add_", - "definition": "SELECT 'Hello World';" + "definition": "SELECT 'Hello World';", + "security_invoker": true }, "mocking_required": false, "mock_data": {},