diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index d0beb8df..66052f5b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -74,6 +74,42 @@ class TableModule(SchemaChildModule):
"""
return database.DatabaseModule.NODE_TYPE
+ @property
+ def csssnippets(self):
+ """
+ Returns a snippet of css to include in the page
+ """
+ snippets = [
+ render_template(
+ "browser/css/collection.css",
+ node_type=self.node_type,
+ ),
+ render_template(
+ "browser/css/node.css",
+ node_type=self.node_type,
+ ),
+ render_template(
+ "browser/css/node.css",
+ node_type='table',
+ file_name='table-inherited',
+ ),
+ render_template(
+ "browser/css/node.css",
+ node_type='table',
+ file_name='table-inherits',
+ ),
+ render_template(
+ "browser/css/node.css",
+ node_type='table',
+ file_name='table-multi-inherit',
+ ),
+ ]
+
+ for submodule in self.submodules:
+ snippets.extend(submodule.csssnippets)
+
+ return snippets
+
def get_own_javascripts(self):
scripts = SchemaChildModule.get_own_javascripts(self)
@@ -271,6 +307,28 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
status=200
)
+ def get_icon_css_class(self, table_info, default_val='icon-table'):
+ if ('is_inherits' in table_info and
+ table_info['is_inherits'] == '1') or \
+ ('coll_inherits' in table_info and
+ len(table_info['coll_inherits']) > 0):
+
+ if ('is_inherited' in table_info and
+ table_info['is_inherited'] == '1')\
+ or ('inherited_tables_cnt' in table_info and
+ len(table_info['inherited_tables_cnt']) > 0):
+ default_val = 'icon-table-multi-inherit'
+ else:
+ default_val = 'icon-table-inherits'
+ elif ('is_inherited' in table_info and
+ table_info['is_inherited'] == '1')\
+ or ('inherited_tables_cnt' in table_info and
+ len(table_info['inherited_tables_cnt']) > 0):
+ default_val = 'icon-table-inherited'
+
+ return super(TableView, self).\
+ get_icon_css_class(table_info, default_val)
+
@BaseTableView.check_precondition
def node(self, gid, sid, did, scid, tid):
"""
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/base_partition_table.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/base_partition_table.py
index 7d413ef5..5885a8c8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/base_partition_table.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/base_partition_table.py
@@ -17,7 +17,7 @@ class BasePartitionTable:
return True
return False
- def get_icon_css_class(self, table_info):
+ def get_icon_css_class(self, table_info, default_val='icon-table'):
if self.is_table_partitioned(table_info):
return 'icon-partition'
- return 'icon-table'
+ return default_val
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-inherited.svg b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-inherited.svg
new file mode 100644
index 00000000..f0e0ff26
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-inherited.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-inherits.svg b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-inherits.svg
new file mode 100644
index 00000000..efa5cbd3
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-inherits.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-multi-inherit.svg b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-multi-inherit.svg
new file mode 100644
index 00000000..c87ddf22
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/img/table-multi-inherit.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/nodes.sql
index fbf9c42c..948d2d2c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/nodes.sql
@@ -1,7 +1,9 @@
SELECT rel.oid, rel.relname AS name,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers,
- (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned
+ (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned,
+ (SELECT count(1) FROM pg_inherits WHERE inhrelid=rel.oid LIMIT 1) as is_inherits,
+ (SELECT count(1) FROM pg_inherits WHERE inhparent=rel.oid LIMIT 1) as is_inherited
FROM pg_class rel
WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid
AND NOT rel.relispartition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/nodes.sql
index 409247cd..4e583b21 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/nodes.sql
@@ -1,6 +1,8 @@
SELECT rel.oid, rel.relname AS name,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
- (SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers
+ (SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers,
+ (SELECT count(1) FROM pg_inherits WHERE inhrelid=rel.oid LIMIT 1) as is_inherits,
+ (SELECT count(1) FROM pg_inherits WHERE inhparent=rel.oid LIMIT 1) as is_inherited
FROM pg_class rel
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
{% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql
index 01a88e0e..88606e1b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql
@@ -1,6 +1,8 @@
SELECT rel.oid, rel.relname AS name,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid) AS triggercount,
- (SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgenabled = 'O') AS has_enable_triggers
+ (SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgenabled = 'O') AS has_enable_triggers,
+ (SELECT count(1) FROM pg_inherits WHERE inhrelid=rel.oid LIMIT 1) as is_inherits,
+ (SELECT count(1) FROM pg_inherits WHERE inhparent=rel.oid LIMIT 1) as is_inherited
FROM pg_class rel
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
{% if tid %} AND rel.oid = {{tid}}::OID {% endif %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/nodes.sql
index 8c1e5878..b8961cc7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/nodes.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/gpdb_5.0_plus/nodes.sql
@@ -1,7 +1,9 @@
SELECT rel.oid, rel.relname AS name,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid) AS triggercount,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgenabled = 'O') AS has_enable_triggers,
- (CASE WHEN (SELECT count(*) from pg_partition where parrelid = rel.oid) > 0 THEN true ELSE false END) AS is_partitioned
+ (CASE WHEN (SELECT count(*) from pg_partition where parrelid = rel.oid) > 0 THEN true ELSE false END) AS is_partitioned,
+ (SELECT count(1) FROM pg_inherits WHERE inhrelid=rel.oid LIMIT 1) as is_inherits,
+ (SELECT count(1) FROM pg_inherits WHERE inhparent=rel.oid LIMIT 1) as is_inherited
FROM pg_class rel
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid
AND rel.relname NOT IN (SELECT partitiontablename FROM pg_partitions)
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependencies.sql
index 0b6f71f8..1490d683 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependencies.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependencies.sql
@@ -4,7 +4,8 @@ SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, pg_get_expr(a
WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN pr.oid IS NOT NULL AND prtyp.typname = 'trigger' THEN 't'::text
+ WHEN pr.oid IS NOT NULL THEN 'P'::text
WHEN la.oid IS NOT NULL THEN 'l'::text
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
@@ -14,10 +15,12 @@ SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, pg_get_expr(a
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || COALESCE('.' || att.attname, '')
ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname,
+ CASE WHEN inhits.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherits,
+ CASE WHEN inhed.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherited
FROM pg_depend dep
LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
@@ -38,6 +41,9 @@ LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
+LEFT JOIN pg_type prtyp ON prtyp.oid = pr.prorettype
+LEFT JOIN pg_inherits inhits ON (inhits.inhrelid=dep.refobjid)
+LEFT JOIN pg_inherits inhed ON (inhed.inhparent=dep.refobjid)
{{where_clause}} AND
refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependents.sql
index c5c87b7f..2640cd21 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/12_plus/dependents.sql
@@ -3,7 +3,8 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, pg_get_expr(ad.a
WHEN tg.oid IS NOT NULL THEN 'T'::text
WHEN ty.oid IS NOT NULL THEN 'y'::text
WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN pr.oid IS NOT NULL AND prtyp.typname = 'trigger' THEN 't'::text
+ WHEN pr.oid IS NOT NULL THEN 'P'::text
WHEN la.oid IS NOT NULL THEN 'l'::text
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
@@ -13,10 +14,12 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, pg_get_expr(ad.a
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || COALESCE('.' || att.attname, '')
ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname,
+ CASE WHEN inhits.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherits,
+ CASE WHEN inhed.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherited
FROM pg_depend dep
LEFT JOIN pg_class cl ON dep.objid=cl.oid
LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
@@ -37,6 +40,9 @@ LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
+LEFT JOIN pg_type prtyp ON prtyp.oid = pr.prorettype
+LEFT JOIN pg_inherits inhits ON (inhits.inhrelid=dep.objid)
+LEFT JOIN pg_inherits inhed ON (inhed.inhparent=dep.objid)
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
index e5bb8cb6..6600f2db 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependencies.sql
@@ -4,7 +4,8 @@ SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN pr.oid IS NOT NULL AND prtyp.typname = 'trigger' THEN 't'::text
+ WHEN pr.oid IS NOT NULL THEN 'P'::text
WHEN la.oid IS NOT NULL THEN 'l'::text
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
@@ -14,10 +15,12 @@ SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || COALESCE('.' || att.attname, '')
ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname,
+ CASE WHEN inhits.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherits,
+ CASE WHEN inhed.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherited
FROM pg_depend dep
LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
@@ -38,8 +41,11 @@ LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
LEFT JOIN pg_foreign_server fs ON fs.oid=dep.refobjid
LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.refobjid
+LEFT JOIN pg_type prtyp ON prtyp.oid = pr.prorettype
+LEFT JOIN pg_inherits inhits ON (inhits.inhrelid=dep.refobjid)
+LEFT JOIN pg_inherits inhed ON (inhed.inhparent=dep.refobjid)
{{where_clause}} AND
refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY refclassid, cl.relkind
\ No newline at end of file
+ORDER BY refclassid, cl.relkind
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
index 1281672f..a687c0ee 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/9.1_plus/dependents.sql
@@ -3,7 +3,8 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
WHEN tg.oid IS NOT NULL THEN 'T'::text
WHEN ty.oid IS NOT NULL THEN 'y'::text
WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN pr.oid IS NOT NULL AND prtyp.typname = 'trigger' THEN 't'::text
+ WHEN pr.oid IS NOT NULL THEN 'P'::text
WHEN la.oid IS NOT NULL THEN 'l'::text
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
@@ -13,10 +14,12 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || COALESCE('.' || att.attname, '')
ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname, fs.srvname, fdw.fdwname)
END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname,
+ CASE WHEN inhits.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherits,
+ CASE WHEN inhed.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherited
FROM pg_depend dep
LEFT JOIN pg_class cl ON dep.objid=cl.oid
LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
@@ -37,6 +40,9 @@ LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
LEFT JOIN pg_foreign_server fs ON fs.oid=dep.objid
LEFT JOIN pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
+LEFT JOIN pg_type prtyp ON prtyp.oid = pr.prorettype
+LEFT JOIN pg_inherits inhits ON (inhits.inhrelid=dep.objid)
+LEFT JOIN pg_inherits inhed ON (inhed.inhparent=dep.objid)
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
index aae5982e..8a816ca6 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependencies.sql
@@ -5,7 +5,8 @@ SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text
WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN pr.oid IS NOT NULL AND prtyp.typname = 'trigger' THEN 't'::text
+ WHEN pr.oid IS NOT NULL THEN 'P'::text
WHEN la.oid IS NOT NULL THEN 'l'::text
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
@@ -13,10 +14,12 @@ SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ CASE WHEN cl.relname IS NOT NULL OR att.attname IS NOT NULL THEN cl.relname || COALESCE('.' || att.attname, '')
ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname,
+ CASE WHEN inhits.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherits,
+ CASE WHEN inhed.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherited
FROM pg_depend dep
LEFT JOIN pg_class cl ON dep.refobjid=cl.oid
LEFT JOIN pg_attribute att ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
@@ -35,8 +38,11 @@ LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_language la ON dep.refobjid=la.oid
LEFT JOIN pg_namespace ns ON dep.refobjid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.adrelid=att.attrelid AND ad.adnum=att.attnum
+LEFT JOIN pg_type prtyp ON prtyp.oid = pr.prorettype
+LEFT JOIN pg_inherits inhits ON (inhits.inhrelid=dep.refobjid)
+LEFT JOIN pg_inherits inhed ON (inhed.inhparent=dep.refobjid)
{{where_clause}} AND
refclassid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper'))
-ORDER BY refclassid, cl.relkind
\ No newline at end of file
+ORDER BY refclassid, cl.relkind
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
index 2fe2ef3e..f8a1bee3 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
@@ -4,7 +4,8 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
WHEN tg.oid IS NOT NULL THEN 'T'::text
WHEN ty.oid IS NOT NULL THEN 'y'::text
WHEN ns.oid IS NOT NULL THEN 'n'::text
- WHEN pr.oid IS NOT NULL THEN 'p'::text
+ WHEN pr.oid IS NOT NULL AND prtyp.typname = 'trigger' THEN 't'::text
+ WHEN pr.oid IS NOT NULL THEN 'P'::text
WHEN la.oid IS NOT NULL THEN 'l'::text
WHEN rw.oid IS NOT NULL THEN 'R'::text
WHEN co.oid IS NOT NULL THEN 'C'::text || contype
@@ -12,10 +13,12 @@ SELECT DISTINCT dep.deptype, dep.classid, cl.relkind, ad.adbin, ad.adsrc,
ELSE ''
END AS type,
COALESCE(coc.relname, clrw.relname) AS ownertable,
- CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || '.' || att.attname
+ CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || COALESCE('.' || att.attname, '')
ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname)
END AS refname,
- COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname
+ COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname) AS nspname,
+ CASE WHEN inhits.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherits,
+ CASE WHEN inhed.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherited
FROM pg_depend dep
LEFT JOIN pg_class cl ON dep.objid=cl.oid
LEFT JOIN pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
@@ -34,6 +37,9 @@ LEFT JOIN pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_language la ON dep.objid=la.oid
LEFT JOIN pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_attrdef ad ON ad.oid=dep.objid
+LEFT JOIN pg_type prtyp ON prtyp.oid = pr.prorettype
+LEFT JOIN pg_inherits inhits ON (inhits.inhrelid=dep.objid)
+LEFT JOIN pg_inherits inhed ON (inhed.inhparent=dep.objid)
{{where_clause}} AND
classid IN ( SELECT oid FROM pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
diff --git a/web/pgadmin/browser/templates/browser/css/node.css b/web/pgadmin/browser/templates/browser/css/node.css
index 5c97d0a5..c75627b0 100644
--- a/web/pgadmin/browser/templates/browser/css/node.css
+++ b/web/pgadmin/browser/templates/browser/css/node.css
@@ -1,5 +1,8 @@
-.icon-{{node_type}} {
- background-image: url('{{ url_for('NODE-%s.static' % node_type, filename='img/%s.svg' % node_type )}}') !important;
+{% if file_name is not defined %}
+{% set file_name=node_type %}
+{% endif %}
+.icon-{{file_name}} {
+ background-image: url('{{ url_for('NODE-%s.static' % node_type, filename='img/%s.svg' % file_name )}}') !important;
background-repeat: no-repeat;
background-size: 20px !important;
align-content: center;
@@ -7,8 +10,8 @@
height: 15px;
}
-.pgadmin-node-select option[node="{{node_type}}"] {
- background-image: url('{{ url_for('NODE-%s.static' % node_type, filename='img/%s.svg' % node_type )}}') !important;
+.pgadmin-node-select option[node="{{file_name}}"] {
+ background-image: url('{{ url_for('NODE-%s.static' % node_type, filename='img/%s.svg' % file_name )}}') !important;
background-repeat: no-repeat;
background-size: 20px !important;
background-position: center left;
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index 3537b7c3..0462d7e3 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -461,10 +461,12 @@ class PGChildNodeView(NodeView):
'S': 'sequence',
'v': 'view',
'x': 'external_table',
- 'p': 'function',
+ 'p': 'partition',
+ 'P': 'function',
'n': 'schema',
'y': 'type',
'd': 'domain',
+ 't': 'trigger_function',
'T': 'trigger',
'l': 'language',
'f': 'foreign_data_wrapper',
@@ -500,6 +502,7 @@ class PGChildNodeView(NodeView):
ref_name = nsp_name + '.'
type_name = ''
+ icon = None
# Fetch the type name from the dictionary
# if type is not present in the types dictionary then
@@ -514,6 +517,25 @@ class PGChildNodeView(NodeView):
type_name = 'column'
else:
type_name = 'table'
+ if 'is_inherits' in row \
+ and row['is_inherits'] == '1':
+ if 'is_inherited' in row \
+ and row['is_inherited'] == '1':
+ icon = 'icon-table-multi-inherit'
+ # For tables under partitioned tables,
+ # is_inherits will be true and dependency
+ # will be auto as it inherits from parent
+ # partitioned table
+ elif ('is_inherited' in row and
+ row['is_inherited'] == '0')\
+ and dep_str == 'a':
+ type_name = 'partition'
+ else:
+ icon = 'icon-table-inherits'
+ elif 'is_inherited' in row \
+ and row['is_inherited'] == '1':
+ icon = 'icon-table-inherited'
+
elif type_str[0] == 'R':
type_name = 'rule'
ref_name = \
@@ -569,7 +591,8 @@ class PGChildNodeView(NodeView):
{
'type': type_name,
'name': ref_name,
- 'field': dep_type
+ 'field': dep_type,
+ 'icon': icon,
}
)
diff --git a/web/pgadmin/misc/dependencies/static/js/dependencies.js b/web/pgadmin/misc/dependencies/static/js/dependencies.js
index f5f717a1..59c3cbaf 100644
--- a/web/pgadmin/misc/dependencies/static/js/dependencies.js
+++ b/web/pgadmin/misc/dependencies/static/js/dependencies.js
@@ -46,10 +46,12 @@ define('misc.dependencies', [
// This function is used to fetch/set the icon for the type(Function, Role, Database, ....)
parse: function(res) {
var node = pgBrowser.Nodes[res.type];
- res.icon = node ? (_.isFunction(node['node_image']) ?
- (node['node_image']).apply(node, [null, null]) :
- (node['node_image'] || ('icon-' + res.type))) :
- ('icon-' + res.type);
+ if(res.icon == null || res.icon == '') {
+ res.icon = node ? (_.isFunction(node['node_image']) ?
+ (node['node_image']).apply(node, [null, null]) :
+ (node['node_image'] || ('icon-' + res.type))) :
+ ('icon-' + res.type);
+ }
res.type = S.titleize(res.type.replace(/_/g, ' '), true);
return res;
},
diff --git a/web/pgadmin/misc/dependents/static/js/dependents.js b/web/pgadmin/misc/dependents/static/js/dependents.js
index 633c4649..1b16305a 100644
--- a/web/pgadmin/misc/dependents/static/js/dependents.js
+++ b/web/pgadmin/misc/dependents/static/js/dependents.js
@@ -46,10 +46,12 @@ define('misc.dependents', [
// This function is used to fetch/set the icon for the type(Function, Role, Database, ....)
parse: function(res) {
var node = pgBrowser.Nodes[res.type];
- res.icon = node ? (_.isFunction(node['node_image']) ?
- (node['node_image']).apply(node, [null, null]) :
- (node['node_image'] || ('icon-' + res.type))) :
- ('icon-' + res.type);
+ if(res.icon == null || res.icon == '') {
+ res.icon = node ? (_.isFunction(node['node_image']) ?
+ (node['node_image']).apply(node, [null, null]) :
+ (node['node_image'] || ('icon-' + res.type))) :
+ ('icon-' + res.type);
+ }
res.type = S.titleize(res.type.replace(/_/g, ' '), true);
return res;
},