Ensure objects depending on extensions are not displayed in Schema Diff. Fixes #7221

This commit is contained in:
Akshay Joshi 2022-03-24 15:59:02 +05:30
parent 7f2e87b27d
commit 473afd950c
89 changed files with 306 additions and 67 deletions

View File

@ -21,6 +21,7 @@ Bug fixes
| `Issue #7059 <https://redmine.postgresql.org/issues/7059>`_ - Fixed an issue where the error is shown on logout when the authentication source is oauth2.
| `Issue #7216 <https://redmine.postgresql.org/issues/7216>`_ - Ensure that the values of certain fields are prettified in the statistics tab for collection nodes.
| `Issue #7221 <https://redmine.postgresql.org/issues/7221>`_ - Ensure objects depending on extensions are not displayed in Schema Diff.
| `Issue #7238 <https://redmine.postgresql.org/issues/7238>`_ - Fixed an issue where foreign key is not removed even if the referred table is removed in ERD.
| `Issue #7257 <https://redmine.postgresql.org/issues/7257>`_ - Support running the container under OpenShift with alternate UIDs.
| `Issue #7261 <https://redmine.postgresql.org/issues/7261>`_ - Correct typo in the documentation.

View File

@ -774,9 +774,10 @@ class CastView(PGChildNodeView, SchemaDiffObjectCompare):
last_system_oid = (self.manager.db_info[did])['datlastsysoid']
sql = render_template(
"/".join([self.template_path, 'nodes.sql']),
"/".join([self.template_path, self._NODES_SQL]),
datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects
showsysobj=self.blueprint.show_system_objects,
schema_diff=True
)
status, rset = self.conn.execute_2darray(sql)
if not status:

View File

@ -21,4 +21,8 @@
{% endif %}
ca.oid > {{datlastsysoid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = ca.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY st.typname, tt.typname

View File

@ -853,14 +853,9 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
last_system_oid = 0
if self.manager.db_info is not None and did in self.manager.db_info:
last_system_oid = (self.manager.db_info[did])['datlastsysoid']
sql = render_template(
"/".join([self.template_path, 'nodes.sql']),
datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects
"/".join([self.template_path, self._NODES_SQL]),
schema_diff=True
)
status, rset = self.conn.execute_2darray(sql)
if not status:

View File

@ -3,4 +3,8 @@ FROM pg_catalog.pg_event_trigger e
{% if etid %}
WHERE e.oid={{etid}}::oid
{% endif %}
{% if schema_diff %}
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = e.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY e.evtname

View File

@ -561,7 +561,7 @@ class ExtensionView(PGChildNodeView, SchemaDiffObjectCompare):
res = dict()
sql = render_template("/".join([self.template_path,
'properties.sql']))
self._PROPERTIES_SQL]))
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=rset)

View File

@ -963,7 +963,8 @@ class ForeignDataWrapperView(PGChildNodeView, SchemaDiffObjectCompare):
res = dict()
sql = render_template("/".join([self.template_path,
'properties.sql']))
self._PROPERTIES_SQL]),
schema_diff=True)
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=rset)

View File

@ -924,7 +924,8 @@ class ForeignServerView(PGChildNodeView, SchemaDiffObjectCompare):
res = dict()
sql = render_template("/".join([self.template_path,
'properties.sql']))
self._PROPERTIES_SQL]),
schema_diff=True)
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=rset)

View File

@ -22,5 +22,9 @@ WHERE srvfdw={{fid}}::oid
{% if fsid %}
WHERE srv.oid={{fsid}}::oid
{% endif %}
{% if schema_diff %}
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = srv.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY srvname;
{% endif %}

View File

@ -548,7 +548,7 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare):
"""
try:
sql = render_template("/".join([self.template_path,
'properties.sql']),
self._PROPERTIES_SQL]),
umid=umid, conn=self.conn)
status, res = self.conn.execute_dict(sql)
if not status:
@ -905,7 +905,8 @@ class UserMappingView(PGChildNodeView, SchemaDiffObjectCompare):
res = dict()
sql = render_template("/".join([self.template_path,
'properties.sql']))
self._PROPERTIES_SQL]),
schema_diff=True)
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=rset)

View File

@ -14,5 +14,9 @@ ORDER BY 2;
SELECT u.umid AS oid, u.usename AS name, u.srvid AS fsid, pg_catalog.array_to_string(u.umoptions, ',') AS umoptions, fs.srvfdw AS fdwid
FROM pg_catalog.pg_user_mappings u
LEFT JOIN pg_catalog.pg_foreign_server fs ON fs.oid = u.srvid
{% if schema_diff %}
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = u.umid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY 2;
{% endif %}

View File

@ -23,4 +23,8 @@ WHERE fdw.oid={{fid}}::oid
{% if fname %}
WHERE fdw.fdwname={{ fname|qtLiteral }}::text
{% endif %}
{% if schema_diff %}
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = fdw.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY fdwname

View File

@ -829,7 +829,8 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
sql = render_template("/".join([self.template_path,
'properties.sql']))
self._PROPERTIES_SQL]),
schema_diff=True)
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=rset)

View File

@ -20,4 +20,8 @@ WHERE lanispl IS TRUE
{% if lanname %} AND
lanname={{ lanname|qtLiteral }}::text
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = lan.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY lanname

View File

@ -292,7 +292,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = []
sql = render_template("/".join([self.template_path,
'nodes.sql']))
self._NODES_SQL]))
status, result = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=result)
@ -900,14 +900,9 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.version < 100000:
return res
last_system_oid = 0
if self.manager.db_info is not None and did in self.manager.db_info:
last_system_oid = (self.manager.db_info[did])['datlastsysoid']
sql = render_template(
"/".join([self.template_path, 'nodes.sql']),
datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects
"/".join([self.template_path, self._NODES_SQL]),
schema_diff=True
)
status, rset = self.conn.execute_2darray(sql)
if not status:

View File

@ -1 +1,6 @@
SELECT oid , pubname AS name FROM pg_catalog.pg_publication;
SELECT oid , pubname AS name
FROM pg_catalog.pg_publication
{% if schema_diff %}
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}

View File

@ -799,7 +799,8 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -5,4 +5,8 @@ WHERE c.collnamespace = {{scid}}::oid
{% elif coid %}
WHERE c.oid = {{coid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY c.collname;

View File

@ -831,7 +831,7 @@ AND relkind != 'c'))"""
data['is_schema_diff'] = True
SQL = render_template(
"/".join([self.template_path, 'update.sql']),
"/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data)
return SQL, data
@ -935,7 +935,8 @@ AND relkind != 'c'))"""
"""
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODE_SQL]), scid=scid)
self._NODE_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=rset)

View File

@ -13,5 +13,9 @@ WHERE
{% elif doid %}
WHERE d.oid = {{doid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = d.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
d.typname;

View File

@ -1542,7 +1542,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
"""
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODE_SQL]), scid=scid)
self._NODE_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -15,4 +15,8 @@ WHERE
{% elif foid %}
c.oid = {{foid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY c.relname;

View File

@ -943,7 +943,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
data = {'schema': scid}
# Fetch schema name from schema oid
sql = render_template("/".join([self.template_path,
'schema.sql']),
self._SCHEMA_SQL]),
data=data,
conn=self.conn,
)
@ -1014,7 +1014,8 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, fts_cfg = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -9,5 +9,9 @@ WHERE
{% elif cfgid %}
cfg.oid = {{cfgid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = cfg.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY name

View File

@ -922,7 +922,8 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -10,5 +10,8 @@ WHERE
{% elif dcid %}
dict.oid = {{dcid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = dict.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY name

View File

@ -888,7 +888,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
data = {'schema': scid}
# Fetch schema name from schema oid
sql = render_template("/".join([self.template_path,
'schema.sql']),
self._SCHEMA_SQL]),
data=data,
conn=self.conn,
)
@ -959,7 +959,8 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -9,5 +9,8 @@ WHERE
{% elif pid %}
prs.oid = {{pid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = prs.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY name

View File

@ -765,7 +765,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
data = {'schema': scid}
# Fetch schema name from schema oid
sql = render_template("/".join([self.template_path,
'schema.sql']),
self._SCHEMA_SQL]),
data=data,
conn=self.conn,
)
@ -832,7 +832,8 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -8,5 +8,8 @@ WHERE
{% elif tid %}
tmpl.oid = {{tid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = tmpl.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY name

View File

@ -1960,7 +1960,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
if not oid:
sql = render_template("/".join([self.sql_template_path,
self._NODE_SQL]), scid=scid)
self._NODE_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=res)

View File

@ -16,6 +16,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname NOT IN ('trigger', 'event_trigger')
ORDER BY

View File

@ -16,6 +16,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname NOT IN ('trigger', 'event_trigger')
ORDER BY

View File

@ -17,6 +17,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname NOT IN ('trigger', 'event_trigger')
ORDER BY

View File

@ -17,6 +17,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname NOT IN ('trigger', 'event_trigger')
ORDER BY

View File

@ -23,6 +23,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname NOT IN ('trigger', 'event_trigger')
ORDER BY

View File

@ -23,6 +23,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname NOT IN ('trigger', 'event_trigger')
ORDER BY

View File

@ -24,6 +24,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname NOT IN ('trigger', 'event_trigger')
ORDER BY

View File

@ -16,6 +16,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname IN ('trigger', 'event_trigger')
AND lanname NOT IN ('edbspl', 'sql', 'internal')

View File

@ -17,6 +17,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND lanname NOT IN ('edbspl', 'sql', 'internal')
ORDER BY

View File

@ -16,6 +16,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname IN ('trigger', 'event_trigger')
AND lanname NOT IN ('edbspl', 'sql', 'internal')

View File

@ -16,6 +16,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname IN ('trigger', 'event_trigger') AND lanname != 'edbspl'
ORDER BY

View File

@ -16,6 +16,10 @@ WHERE
{% endif %}
{% if scid %}
AND pronamespace = {{scid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND typname IN ('trigger', 'event_trigger')
AND lanname NOT IN ('edbspl', 'sql', 'internal')

View File

@ -830,7 +830,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
return res
sql = render_template("/".join([self.template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=res)

View File

@ -6,6 +6,10 @@ WHERE nspparent = {{scid}}::oid
{% if pkgid %}
AND nsp.oid = {{pkgid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = nsp.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND nspobjecttype = 0
AND nspcompoundtrigger = false
ORDER BY nspname;

View File

@ -6,4 +6,8 @@ WHERE nspparent = {{scid}}::oid
{% if pkgid %}
AND nsp.oid = {{pkgid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = nsp.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY nspname;

View File

@ -6,5 +6,9 @@ WHERE nspparent = {{scid}}::oid
{% if pkgid %}
AND nsp.oid = {{pkgid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = nsp.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
AND nspobjecttype = 0
ORDER BY nspname;

View File

@ -937,7 +937,8 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = dict()
sql = render_template("/".join([self.template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=res)

View File

@ -11,4 +11,8 @@ WHERE
{% if seid %}
AND cl.oid = {{seid|qtLiteral}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = cl.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY relname

View File

@ -758,7 +758,8 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
return res
SQL = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]), scid=scid)
self._PROPERTIES_SQL]), scid=scid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -27,4 +27,8 @@ FROM pg_catalog.pg_synonym s JOIN pg_catalog.pg_namespace ns ON s.synnamespace
{% if syid %}
AND s.oid={{syid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = s.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY synname;

View File

@ -27,4 +27,8 @@ FROM pg_catalog.pg_synonym s JOIN pg_catalog.pg_namespace ns ON s.synnamespace
{% if syid %}
AND s.oid={{syid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = s.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY synname;

View File

@ -15,4 +15,8 @@ FROM pg_catalog.pg_synonym s JOIN pg_catalog.pg_namespace ns ON s.synnamespace
{% if syid %}
AND s.oid={{syid}}::oid
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = s.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY synname;

View File

@ -973,7 +973,8 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
res = data
else:
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), tid=tid)
self._NODES_SQL]), tid=tid,
schema_diff=True)
status, triggers = self.conn.execute_2darray(SQL)
if not status:
current_app.logger.error(triggers)

View File

@ -1028,7 +1028,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
if not oid:
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), tid=tid)
self._NODES_SQL]), tid=tid,
schema_diff=True)
status, indexes = self.conn.execute_2darray(SQL)
if not status:
current_app.logger.error(indexes)

View File

@ -420,7 +420,7 @@ class PartitionsView(BaseTableView, DataTypeReader, SchemaDiffObjectCompare):
else:
SQL = render_template(
"/".join([self.partition_template_path, self._NODES_SQL]),
scid=scid, tid=tid
scid=scid, tid=tid, schema_diff=True
)
status, partitions = self.conn.execute_2darray(SQL)
if not status:

View File

@ -660,7 +660,8 @@ class RowSecurityView(PGChildNodeView):
if not oid:
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), tid=tid)
self._NODES_SQL]), tid=tid,
schema_diff=True)
status, policies = self.conn.execute_2darray(SQL)
if not status:
current_app.logger.error(policies)

View File

@ -644,7 +644,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
else:
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]),
tid=tid)
tid=tid, schema_diff=True)
status, rules = self.conn.execute_2darray(SQL)
if not status:
current_app.logger.error(rules)

View File

@ -6,5 +6,9 @@ FROM pg_catalog.pg_trigger t
AND tgpackageoid != 0
{% if trid %}
AND t.oid = {{trid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY tgname;

View File

@ -12,5 +12,9 @@ WHERE indrelid = {{tid}}::OID
AND conname is NULL
{% if idx %}
AND cls.oid = {{ idx }}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = cls.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY cls.relname

View File

@ -41,4 +41,8 @@ FROM
LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid
WHERE rel.relispartition
{% if ptid %} AND rel.oid = {{ ptid }}::OID {% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = rel.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY rel.relname;

View File

@ -41,4 +41,8 @@ FROM
LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid
WHERE rel.relispartition
{% if ptid %} AND rel.oid = {{ ptid }}::OID {% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = rel.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY rel.relname;

View File

@ -9,5 +9,9 @@ WHERE
{% elif plid %}
pl.oid = {{ plid }}
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pl.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
pl.polname;

View File

@ -9,5 +9,9 @@ WHERE
{% elif plid %}
pl.oid = {{ plid }}
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = pl.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
pl.polname;

View File

@ -12,5 +12,9 @@ WHERE
{% elif rid %}
rw.oid = {{ rid }}
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = rw.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
rw.rulename

View File

@ -8,4 +8,8 @@ FROM pg_catalog.pg_class rel
WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid
AND NOT rel.relispartition
{% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = rel.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY rel.relname;

View File

@ -6,4 +6,8 @@ SELECT rel.oid, rel.relname AS name,
FROM pg_catalog.pg_class rel
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
{% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = rel.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY rel.relname;

View File

@ -4,5 +4,9 @@ FROM pg_catalog.pg_trigger t
AND tgrelid = {{tid}}::OID
{% if trid %}
AND t.oid = {{trid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY tgname;

View File

@ -4,5 +4,9 @@ FROM pg_catalog.pg_trigger t
AND tgrelid = {{tid}}::OID
{% if trid %}
AND t.oid = {{trid}}::OID
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY tgname;

View File

@ -1027,7 +1027,8 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
res = data
else:
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]), tid=tid)
self._NODES_SQL]), tid=tid,
schema_diff=True)
status, triggers = self.conn.execute_2darray(SQL)
if not status:
current_app.logger.error(triggers)

View File

@ -511,7 +511,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
else:
res = dict()
sql = render_template("/".join([self.table_template_path,
self._NODES_SQL]), scid=scid)
self._NODES_SQL]), scid=scid,
schema_diff=True)
status, tables = self.conn.execute_2darray(sql)
if not status:
return False, tables

View File

@ -1551,7 +1551,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
res = dict()
SQL = render_template("/".join([self.template_path,
self._NODES_SQL]),
scid=scid, datlastsysoid=self.datlastsysoid)
scid=scid, datlastsysoid=self.datlastsysoid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -10,4 +10,8 @@ WHERE t.typtype != 'd' AND t.typname NOT LIKE E'\\_%' AND t.typnamespace = {{sci
{% if not show_system_objects %}
AND ct.oid is NULL
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY t.typname;

View File

@ -10,4 +10,8 @@ WHERE t.typtype != 'd' AND t.typname NOT LIKE E'\\_%' AND t.typnamespace = {{sci
{% if not show_system_objects %}
AND ct.oid is NULL
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY t.typname;

View File

@ -1653,7 +1653,8 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not oid:
SQL = render_template("/".join(
[self.template_path, self._SQL_PREFIX + self._NODES_SQL]),
did=did, scid=scid, datlastsysoid=self.datlastsysoid)
did=did, scid=scid, datlastsysoid=self.datlastsysoid,
schema_diff=True)
status, views = self.conn.execute_2darray(SQL)
if not status:
current_app.logger.error(views)
@ -2286,7 +2287,8 @@ class MViewNode(ViewNode, VacuumSettings):
res = dict()
SQL = render_template("/".join(
[self.template_path, self._SQL_PREFIX + self._NODES_SQL]),
did=did, scid=scid, datlastsysoid=self.datlastsysoid)
did=did, scid=scid, datlastsysoid=self.datlastsysoid,
schema_diff=True)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -8,6 +8,10 @@ WHERE
AND c.oid = {{vid}}::oid
{% elif scid %}
AND c.relnamespace = {{scid}}::oid
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}
ORDER BY
c.relname
{% endif %}

View File

@ -280,7 +280,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
"""
res = []
sql = render_template("/".join([self.template_path,
'nodes.sql']), did=did)
self._NODES_SQL]), did=did)
status, result = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=result)
@ -883,15 +883,9 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
if self.manager.version < 100000:
return res
last_system_oid = 0
if self.manager.db_info is not None and did in self.manager.db_info:
last_system_oid = (self.manager.db_info[did])['datlastsysoid']
sql = render_template(
"/".join([self.template_path, 'nodes.sql']),
datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects,
did=did
"/".join([self.template_path, self._NODES_SQL]),
did=did, schema_diff=True
)
status, rset = self.conn.execute_2darray(sql)
if not status:

View File

@ -3,5 +3,9 @@ WHERE
{% if subid %}
sub.oid = {{ subid }};
{% else %}
sub.subdbid = {{ did }};
{% endif %};
sub.subdbid = {{ did }}
{% endif %}
{% if schema_diff %}
AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
WHERE objid = oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
{% endif %}

View File

@ -276,7 +276,7 @@ class ResourceGroupView(NodeView):
sid: Server ID
"""
sql = render_template("/".join([self.sql_path, 'nodes.sql']),
sql = render_template("/".join([self.sql_path, self._NODES_SQL]),
rgid=rg_id)
status, result = self.conn.execute_2darray(sql)
if not status:
@ -308,7 +308,7 @@ class ResourceGroupView(NodeView):
sid: Server ID
"""
res = []
sql = render_template("/".join([self.sql_path, 'nodes.sql']))
sql = render_template("/".join([self.sql_path, self._NODES_SQL]))
status, result = self.conn.execute_2darray(sql)
if not status:
return internal_server_error(errormsg=result)
@ -549,7 +549,7 @@ class ResourceGroupView(NodeView):
for rg_id in data['ids']:
# Get name for resource group from rg_id
sql = render_template(
"/".join([self.sql_path, 'delete.sql']),
"/".join([self.sql_path, self._DELETE_SQL]),
rgid=rg_id, conn=self.conn
)
status, rgname = self.conn.execute_scalar(sql)
@ -570,7 +570,7 @@ class ResourceGroupView(NodeView):
# drop resource group
sql = render_template(
"/".join([self.sql_path, 'delete.sql']),
"/".join([self.sql_path, self._DELETE_SQL]),
rgname=rgname, conn=self.conn
)
status, res = self.conn.execute_scalar(sql)