1) Fixed column "none" does not exist issue, while comparing schema objects. Fixes #7591

2) Fixed an issue where schema diff did not pick up the change in RLS policy. Fixes #7596
3) Ensure that schema diff maintains view ownership when view definitions are modified. Fixes #7611
This commit is contained in:
Akshay Joshi 2022-08-18 13:40:28 +05:30
parent 306b184e11
commit e455114441
11 changed files with 46 additions and 11 deletions

View File

@ -38,5 +38,8 @@ Bug fixes
| `Issue #7575 <https://redmine.postgresql.org/issues/7575>`_ - Fixed an issue where Alt-Shift-Q didn't work after creating a new query.
| `Issue #7586 <https://redmine.postgresql.org/issues/7586>`_ - Fixed an issue with rendering geometry when selecting a complete column.
| `Issue #7587 <https://redmine.postgresql.org/issues/7587>`_ - Ensure that the children of information_schema and pg_catalog node should be displayed.
| `Issue #7591 <https://redmine.postgresql.org/issues/7591>`_ - Fixed column "none" does not exist issue, while comparing schema objects.
| `Issue #7596 <https://redmine.postgresql.org/issues/7596>`_ - Fixed an issue where schema diff did not pick up the change in RLS policy.
| `Issue #7608 <https://redmine.postgresql.org/issues/7608>`_ - Fixed an issue where the cloud deployment wizard creates the cluster with the High Availability even if that option is not selected.
| `Issue #7611 <https://redmine.postgresql.org/issues/7611>`_ - Ensure that schema diff maintains view ownership when view definitions are modified.
| `Issue #7614 <https://redmine.postgresql.org/issues/7614>`_ - Fixed crypt key is missing issue when logout from the pgAdmin.

View File

@ -616,7 +616,7 @@ class RowSecurityView(PGChildNodeView):
data['schema'] = self.schema
data['table'] = self.table
sql, name = row_security_policies_utils.get_sql(
self.conn, data=data, scid=scid, plid=oid,
self.conn, data=data, scid=scid, plid=oid, policy_table_id=tid,
schema=self.schema, table=self.table)
sql = sql.strip('\n').strip(' ')

View File

@ -49,6 +49,11 @@ WITH(
{% elif o_data.with_data is defined %}
WITH {{ 'DATA' if o_data.with_data else 'NO DATA' }};
{% endif %}
{% if o_data.owner and not data.owner %}
ALTER TABLE IF EXISTS {{ conn|qtIdent(view_schema, view_name) }}
OWNER TO {{ conn|qtIdent(o_data.owner) }};
{% endif %}
{% if o_data.comment and not data.comment %}
COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}

View File

@ -49,6 +49,11 @@ WITH(
{% elif o_data.with_data is defined %}
WITH {{ 'DATA' if o_data.with_data else 'NO DATA' }};
{% endif %}
{% if o_data.owner and not data.owner %}
ALTER TABLE IF EXISTS {{ conn|qtIdent(view_schema, view_name) }}
OWNER TO {{ conn|qtIdent(o_data.owner) }};
{% endif %}
{% if o_data.comment and not data.comment %}
COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}

View File

@ -6,16 +6,17 @@
{% 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 {{ conn|qtIdent(o_data.schema, 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 {{ conn|qtIdent(o_data.schema, view_name ) }}
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 data.security_barrier) %}
@ -23,20 +24,25 @@ CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }}
{% 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 {{ conn|qtIdent(view_schema, view_name) }}
ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }}
SET (security_barrier={{ data.security_barrier|lower }});
{% endif %}
{% if (data.check_option and data.check_option != o_data.check_option and data.check_option != 'no') %}
ALTER VIEW {{ conn|qtIdent(view_schema, view_name) }}
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 {{ conn|qtIdent(view_schema, view_name) }} RESET (check_option);
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 {{ conn|qtIdent(view_schema, view_name) }}
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) %}

View File

@ -16,6 +16,7 @@ ALTER VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, view_name ) }}
{% 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 data.security_barrier) %}
@ -23,6 +24,11 @@ CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }}
{% 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) }}

View File

@ -4,5 +4,8 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS public."testmview_$%{}[]()&*^!/@`#"
SELECT 12 AS col1
WITH NO DATA;
ALTER TABLE IF EXISTS public."testmview_$%{}[]()&*^!/@`#"
OWNER TO postgres;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';

View File

@ -1,5 +1,5 @@
ALTER VIEW public."testview_$%{}[]()&*^!@""'`\/#"
ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#"
SET (security_barrier=true);
ALTER VIEW public."testview_$%{}[]()&*^!@""'`\/#"
ALTER VIEW IF EXISTS public."testview_$%{}[]()&*^!@""'`\/#"
SET (check_option=cascaded);
GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC;

View File

@ -1,7 +1,11 @@
DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#";
CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#"
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

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

View File

@ -4,5 +4,8 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS public."testmview_$%{}[]()&*^!/@`#"
SELECT 12 AS col1
WITH NO DATA;
ALTER TABLE IF EXISTS public."testmview_$%{}[]()&*^!/@`#"
OWNER TO enterprisedb;
COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"
IS 'comment1';