Added security_invoker option while creating a view. #6371

This commit is contained in:
Anil Sahoo 2023-06-22 11:14:03 +05:30 committed by GitHub
parent 1184752540
commit 78db1e3c36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
67 changed files with 1653 additions and 90 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -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*:

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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);

View File

@ -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);
FOR TABLES IN SCHEMA test_schema_publication, test_schema_publication_2
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication, public.test_table_publication_2
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_id)
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
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);

View File

@ -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);
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);

View File

@ -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);
FOR TABLES IN SCHEMA test_schema_publication_2
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);

View File

@ -1,2 +0,0 @@
ALTER PUBLICATION test_publication_create
RENAME TO alterd_publication;

View File

@ -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);
FOR TABLE public.test_table_publication, public.test_table_publication_2 (dept_name)
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
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);

View File

@ -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);
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);

View File

@ -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);

View File

@ -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);
FOR TABLES IN SCHEMA test_schema_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLES IN SCHEMA test_schema_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication (emp_id, name)
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication (emp_id, name)
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
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);

View File

@ -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);
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);

View File

@ -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);
FOR TABLE public.test_table_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE ONLY public.test_table_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication, TABLES IN SCHEMA test_schema_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
FOR TABLE public.test_table_publication, TABLES IN SCHEMA test_schema_publication
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
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);

View File

@ -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);
FOR TABLE public.test_table_publication WHERE (emp_id=2 and name='test')
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);

View File

@ -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);
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);

View File

@ -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);
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);

View File

@ -1,3 +0,0 @@
CREATE PUBLICATION test_publication_create
FOR ALL TABLES
WITH (publish = 'insert, update', publish_via_partition_root = false);

View File

@ -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'),

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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 %}

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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';

View File

@ -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';

View File

@ -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;

View File

@ -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"
}
]
}

View File

@ -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"
}
}
]
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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';

View File

@ -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';

View File

@ -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;

View File

@ -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"
}
]
}

View File

@ -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"
}
}
]
}

View File

@ -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": {},