mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure that indexes created by constraints are visible in the object explorer when "Show system objects" is enabled. #6717
This commit is contained in:
parent
f2876cabe8
commit
2b2ff0d260
@ -30,6 +30,7 @@ Housekeeping
|
|||||||
Bug fixes
|
Bug fixes
|
||||||
*********
|
*********
|
||||||
|
|
||||||
|
| `Issue #6717 <https://github.com/pgadmin-org/pgadmin4/issues/6717>`_ - Ensure that automatically created indexes should be shown in the treeview.
|
||||||
| `Issue #6803 <https://github.com/pgadmin-org/pgadmin4/issues/6803>`_ - Fixed an issue where reading process logs throws an error when DATA_DIR is moved to a networked drive.
|
| `Issue #6803 <https://github.com/pgadmin-org/pgadmin4/issues/6803>`_ - Fixed an issue where reading process logs throws an error when DATA_DIR is moved to a networked drive.
|
||||||
| `Issue #6887 <https://github.com/pgadmin-org/pgadmin4/issues/6887>`_ - Fixed an issue where syntax error was not highlighting in query tool.
|
| `Issue #6887 <https://github.com/pgadmin-org/pgadmin4/issues/6887>`_ - Fixed an issue where syntax error was not highlighting in query tool.
|
||||||
| `Issue #6921 <https://github.com/pgadmin-org/pgadmin4/issues/6921>`_ - Fixed an issue where on entering full screen, the option label is not changed to 'Exit Full Screen' in desktop mode.
|
| `Issue #6921 <https://github.com/pgadmin-org/pgadmin4/issues/6921>`_ - Fixed an issue where on entering full screen, the option label is not changed to 'Exit Full Screen' in desktop mode.
|
||||||
|
@ -384,7 +384,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]), tid=tid
|
"/".join([self.template_path, self._NODES_SQL]), tid=tid,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
status, res = self.conn.execute_dict(SQL)
|
status, res = self.conn.execute_dict(SQL)
|
||||||
|
|
||||||
@ -414,7 +415,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
"""
|
"""
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]),
|
"/".join([self.template_path, self._NODES_SQL]),
|
||||||
tid=tid, idx=idx
|
tid=tid, idx=idx,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
status, rset = self.conn.execute_2darray(SQL)
|
status, rset = self.conn.execute_2darray(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
@ -453,7 +455,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
"""
|
"""
|
||||||
res = []
|
res = []
|
||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._NODES_SQL]), tid=tid
|
"/".join([self.template_path, self._NODES_SQL]), tid=tid,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
status, rset = self.conn.execute_2darray(SQL)
|
status, rset = self.conn.execute_2darray(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
@ -511,7 +514,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||||
did=did, tid=tid, idx=idx,
|
did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID
|
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
|
|
||||||
status, res = self.conn.execute_dict(SQL)
|
status, res = self.conn.execute_dict(SQL)
|
||||||
@ -717,7 +721,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||||
did=did, tid=tid, idx=idx,
|
did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID
|
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
|
|
||||||
status, res = self.conn.execute_dict(SQL)
|
status, res = self.conn.execute_dict(SQL)
|
||||||
@ -774,7 +779,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
SQL, name = index_utils.get_sql(
|
SQL, name = index_utils.get_sql(
|
||||||
self.conn, data=data, did=did, tid=tid, idx=idx,
|
self.conn, data=data, did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID)
|
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects)
|
||||||
if not isinstance(SQL, str):
|
if not isinstance(SQL, str):
|
||||||
return SQL
|
return SQL
|
||||||
SQL = SQL.strip('\n').strip(' ')
|
SQL = SQL.strip('\n').strip(' ')
|
||||||
@ -839,7 +845,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
try:
|
try:
|
||||||
sql, name = index_utils.get_sql(
|
sql, name = index_utils.get_sql(
|
||||||
self.conn, data=data, did=did, tid=tid, idx=idx,
|
self.conn, data=data, did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID, mode='create')
|
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID, mode='create',
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects)
|
||||||
if not isinstance(sql, str):
|
if not isinstance(sql, str):
|
||||||
return sql
|
return sql
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
@ -869,7 +876,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
SQL = index_utils.get_reverse_engineered_sql(
|
SQL = index_utils.get_reverse_engineered_sql(
|
||||||
self.conn, schema=self.schema, table=self.table, did=did,
|
self.conn, schema=self.schema, table=self.table, did=did,
|
||||||
tid=tid, idx=idx, datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
tid=tid, idx=idx, datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
||||||
add_not_exists_clause=True
|
add_not_exists_clause=True,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
|
|
||||||
return ajax_response(response=SQL)
|
return ajax_response(response=SQL)
|
||||||
@ -899,7 +907,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
|
|
||||||
sql, name = index_utils.get_sql(
|
sql, name = index_utils.get_sql(
|
||||||
self.conn, data=data, did=did, tid=tid, idx=idx,
|
self.conn, data=data, did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID, mode='create')
|
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID, mode='create',
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects)
|
||||||
|
|
||||||
sql = sql.strip('\n').strip(' ')
|
sql = sql.strip('\n').strip(' ')
|
||||||
|
|
||||||
@ -909,7 +918,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
table=self.table, did=did, tid=tid, idx=idx,
|
table=self.table, did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
||||||
template_path=None, with_header=False,
|
template_path=None, with_header=False,
|
||||||
add_not_exists_clause=True
|
add_not_exists_clause=True,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
|
|
||||||
drop_sql = ''
|
drop_sql = ''
|
||||||
@ -1004,7 +1014,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
|||||||
SQL = render_template(
|
SQL = render_template(
|
||||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||||
did=did, tid=tid, idx=idx,
|
did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID
|
datlastsysoid=self._DATABASE_LAST_SYSTEM_OID,
|
||||||
|
show_sys_objects=self.blueprint.show_system_objects
|
||||||
)
|
)
|
||||||
status, res = self.conn.execute_dict(SQL)
|
status, res = self.conn.execute_dict(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
|
@ -15,6 +15,12 @@ from pgadmin.utils.ajax import internal_server_error
|
|||||||
from pgadmin.utils.exception import ObjectGone, ExecuteError
|
from pgadmin.utils.exception import ObjectGone, ExecuteError
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
AUTO_CREATE_INDEX_MSG = "-- This primary key index is automatically " \
|
||||||
|
"generated from a constraint with an identical name.\n-- " \
|
||||||
|
"For more details, refer to the Constraints node. Note that this type " \
|
||||||
|
"of index is only visible \n-- when the 'Show system objects?' is set " \
|
||||||
|
"to True in the Preferences.\n\n"
|
||||||
|
|
||||||
|
|
||||||
def get_template_path(f):
|
def get_template_path(f):
|
||||||
"""
|
"""
|
||||||
@ -233,12 +239,14 @@ def get_sql(conn, **kwargs):
|
|||||||
mode = kwargs.get('mode', None)
|
mode = kwargs.get('mode', None)
|
||||||
template_path = kwargs.get('template_path', None)
|
template_path = kwargs.get('template_path', None)
|
||||||
if_exists_flag = kwargs.get('if_exists_flag', False)
|
if_exists_flag = kwargs.get('if_exists_flag', False)
|
||||||
|
show_sys_obj = kwargs.get('show_sys_objects', False)
|
||||||
|
|
||||||
name = data['name'] if 'name' in data else None
|
name = data['name'] if 'name' in data else None
|
||||||
if idx is not None:
|
if idx is not None:
|
||||||
sql = render_template("/".join([template_path, 'properties.sql']),
|
sql = render_template("/".join([template_path, 'properties.sql']),
|
||||||
did=did, tid=tid, idx=idx,
|
did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=datlastsysoid)
|
datlastsysoid=datlastsysoid,
|
||||||
|
show_sys_objects=show_sys_obj)
|
||||||
|
|
||||||
status, res = conn.execute_dict(sql)
|
status, res = conn.execute_dict(sql)
|
||||||
if not status:
|
if not status:
|
||||||
@ -300,10 +308,12 @@ def get_reverse_engineered_sql(conn, **kwargs):
|
|||||||
template_path = kwargs.get('template_path', None)
|
template_path = kwargs.get('template_path', None)
|
||||||
with_header = kwargs.get('with_header', True)
|
with_header = kwargs.get('with_header', True)
|
||||||
if_exists_flag = kwargs.get('add_not_exists_clause', False)
|
if_exists_flag = kwargs.get('add_not_exists_clause', False)
|
||||||
|
show_sys_obj = kwargs.get('show_sys_objects', False)
|
||||||
|
|
||||||
SQL = render_template("/".join([template_path, 'properties.sql']),
|
SQL = render_template("/".join([template_path, 'properties.sql']),
|
||||||
did=did, tid=tid, idx=idx,
|
did=did, tid=tid, idx=idx,
|
||||||
datlastsysoid=datlastsysoid)
|
datlastsysoid=datlastsysoid,
|
||||||
|
show_sys_objects=show_sys_obj)
|
||||||
|
|
||||||
status, res = conn.execute_dict(SQL)
|
status, res = conn.execute_dict(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
@ -336,7 +346,12 @@ def get_reverse_engineered_sql(conn, **kwargs):
|
|||||||
if_exists_flag=if_exists_flag)
|
if_exists_flag=if_exists_flag)
|
||||||
|
|
||||||
if with_header:
|
if with_header:
|
||||||
sql_header = "-- Index: {0}\n\n-- ".format(data['name'])
|
sql_header = ''
|
||||||
|
# Add a Note if index is automatically created.
|
||||||
|
if 'conname' in data and data['conname'] is not None:
|
||||||
|
sql_header += AUTO_CREATE_INDEX_MSG
|
||||||
|
|
||||||
|
sql_header += "-- Index: {0}\n\n-- ".format(data['name'])
|
||||||
|
|
||||||
sql_header += render_template("/".join([template_path, 'delete.sql']),
|
sql_header += render_template("/".join([template_path, 'delete.sql']),
|
||||||
data=data, conn=conn)
|
data=data, conn=conn)
|
||||||
|
@ -4,7 +4,7 @@ SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name, indrelid, indkey,
|
|||||||
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
||||||
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
||||||
WHERE dtb.oid = {{ did }}::oid)
|
WHERE dtb.oid = {{ did }}::oid)
|
||||||
END as spcname,
|
END as spcname, conname,
|
||||||
tab.relname as tabname, indclass, con.oid AS conoid,
|
tab.relname as tabname, indclass, con.oid AS conoid,
|
||||||
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
||||||
ELSE des.description END AS description,
|
ELSE des.description END AS description,
|
||||||
@ -29,6 +29,8 @@ FROM pg_catalog.pg_index idx
|
|||||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
||||||
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
||||||
WHERE indrelid = {{tid}}::OID
|
WHERE indrelid = {{tid}}::OID
|
||||||
|
{% if not show_sys_objects %}
|
||||||
AND conname is NULL
|
AND conname is NULL
|
||||||
|
{% endif %}
|
||||||
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
||||||
ORDER BY cls.relname
|
ORDER BY cls.relname
|
||||||
|
@ -4,7 +4,7 @@ SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name, indrelid, indkey,
|
|||||||
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
||||||
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
||||||
WHERE dtb.oid = {{ did }}::oid)
|
WHERE dtb.oid = {{ did }}::oid)
|
||||||
END as spcname,
|
END as spcname, conname,
|
||||||
tab.relname as tabname, indclass, con.oid AS conoid,
|
tab.relname as tabname, indclass, con.oid AS conoid,
|
||||||
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
||||||
ELSE des.description END AS description,
|
ELSE des.description END AS description,
|
||||||
@ -30,6 +30,8 @@ FROM pg_catalog.pg_index idx
|
|||||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
||||||
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
||||||
WHERE indrelid = {{tid}}::OID
|
WHERE indrelid = {{tid}}::OID
|
||||||
|
{% if not show_sys_objects %}
|
||||||
AND conname is NULL
|
AND conname is NULL
|
||||||
|
{% endif %}
|
||||||
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
||||||
ORDER BY cls.relname
|
ORDER BY cls.relname
|
||||||
|
@ -4,7 +4,7 @@ SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name, indrelid, indkey,
|
|||||||
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
||||||
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
||||||
WHERE dtb.oid = {{ did }}::oid)
|
WHERE dtb.oid = {{ did }}::oid)
|
||||||
END as spcname,
|
END as spcname, conname,
|
||||||
tab.relname as tabname, indclass, con.oid AS conoid,
|
tab.relname as tabname, indclass, con.oid AS conoid,
|
||||||
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
||||||
ELSE des.description END AS description,
|
ELSE des.description END AS description,
|
||||||
@ -30,6 +30,8 @@ FROM pg_catalog.pg_index idx
|
|||||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
||||||
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
||||||
WHERE indrelid = {{tid}}::OID
|
WHERE indrelid = {{tid}}::OID
|
||||||
|
{% if not show_sys_objects %}
|
||||||
AND conname is NULL
|
AND conname is NULL
|
||||||
|
{% endif %}
|
||||||
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
||||||
ORDER BY cls.relname
|
ORDER BY cls.relname
|
||||||
|
@ -4,4 +4,7 @@ FROM pg_catalog.pg_index idx
|
|||||||
LEFT JOIN pg_catalog.pg_depend dep ON (dep.classid = cls.tableoid AND dep.objid = cls.oid AND dep.refobjsubid = '0' AND dep.refclassid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='pg_constraint') AND dep.deptype='i')
|
LEFT JOIN pg_catalog.pg_depend dep ON (dep.classid = cls.tableoid AND dep.objid = cls.oid AND dep.refobjsubid = '0' AND dep.refclassid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='pg_constraint') AND dep.deptype='i')
|
||||||
LEFT OUTER JOIN pg_catalog.pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)
|
LEFT OUTER JOIN pg_catalog.pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)
|
||||||
WHERE indrelid = {{tid}}::OID
|
WHERE indrelid = {{tid}}::OID
|
||||||
|
{### To show system objects ###}
|
||||||
|
{% if not showsysobj %}
|
||||||
AND conname is NULL
|
AND conname is NULL
|
||||||
|
{% endif %}
|
||||||
|
@ -12,7 +12,9 @@ FROM pg_catalog.pg_index idx
|
|||||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
||||||
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
||||||
WHERE indrelid = {{tid}}::OID
|
WHERE indrelid = {{tid}}::OID
|
||||||
|
{% if not show_sys_objects %}
|
||||||
AND conname is NULL
|
AND conname is NULL
|
||||||
|
{% endif %}
|
||||||
{% if idx %}
|
{% if idx %}
|
||||||
AND cls.oid = {{ idx }}::OID
|
AND cls.oid = {{ idx }}::OID
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -4,7 +4,7 @@ SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name, indrelid, indkey,
|
|||||||
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
(SELECT sp.spcname FROM pg_catalog.pg_database dtb
|
||||||
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
|
||||||
WHERE dtb.oid = {{ did }}::oid)
|
WHERE dtb.oid = {{ did }}::oid)
|
||||||
END as spcname,
|
END as spcname, conname,
|
||||||
tab.relname as tabname, indclass, con.oid AS conoid,
|
tab.relname as tabname, indclass, con.oid AS conoid,
|
||||||
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
CASE WHEN contype IN ('p', 'u', 'x') THEN desp.description
|
||||||
ELSE des.description END AS description,
|
ELSE des.description END AS description,
|
||||||
@ -23,6 +23,8 @@ FROM pg_catalog.pg_index idx
|
|||||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
|
||||||
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
|
||||||
WHERE indrelid = {{tid}}::OID
|
WHERE indrelid = {{tid}}::OID
|
||||||
|
{% if not show_sys_objects %}
|
||||||
AND conname is NULL
|
AND conname is NULL
|
||||||
|
{% endif %}
|
||||||
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
{% if idx %}AND cls.oid = {{idx}}::OID {% endif %}
|
||||||
ORDER BY cls.relname
|
ORDER BY cls.relname
|
||||||
|
Loading…
Reference in New Issue
Block a user