public inbox for [email protected]
help / color / mirror / Atom feedFrom: Aditya Toshniwal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM3174] Distinguish simple tables from tables that are inherited and from which other tables are inherited
Date: Mon, 17 Jun 2019 12:01:30 +0530
Message-ID: <CAM9w-_=7VjHC0zw_cNuXTH3BAp0CgmJ3kP-J9gF0psb=SfjeRA@mail.gmail.com> (raw)
Hi Hackers,
Attached is the patch to change icons for table inheritance (icons by
Chethana Kumar)
Along with this, I have also fixed few other issues/icons found on the way:
1) Dependencies tab for inherited tables/foreign keys shows partial text
(#3994).
2) Dependencies tab for child partition table shows parent partition table
as Function.
3) Dependencies tab for triggers shows trigger functions as plain functions.
4) Dependents tab for partitioned table shows the child partition tables as
normal table instead for partitioned tables.
Kindly review.
--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
Attachments:
[application/octet-stream] RM3174.patch (34.9K, 3-RM3174.patch)
download | inline diff:
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 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#f2f2f2;}.cls-2{fill:#c1cbd5;}.cls-3{fill:#2195e7;}.cls-4{fill:#34495e;}</style></defs><title>inherited</title><g id="_10" data-name="10"><rect class="cls-1" x="2.5" y="3" width="11" height="10" rx="1"/><polygon class="cls-2" points="13 9.13 8.38 9.13 8.38 6 7.63 6 7.63 9.13 3 9.13 3 9.88 7.63 9.88 7.63 13 8.38 13 8.38 9.88 13 9.88 13 9.13"/><path class="cls-3" d="M12.5,3h-9a1,1,0,0,0-1,1v8a1,1,0,0,0,1,1h9a1,1,0,0,0,1-1V4A1,1,0,0,0,12.5,3Zm0,.75a.25.25,0,0,1,.25.25V6.12H8.38V3.75Zm-9,0H7.62V6.12H3.25V4A.25.25,0,0,1,3.5,3.75Zm9,8.5h-9A.25.25,0,0,1,3.25,12V6.88h9.5V12A.25.25,0,0,1,12.5,12.25Z"/><path class="cls-1" d="M12,8a3.93,3.93,0,1,1,3.93-3.93A3.94,3.94,0,0,1,12,8Z"/><path class="cls-4" d="M12,.25a3.8,3.8,0,1,1-3.8,3.8A3.8,3.8,0,0,1,12,.25M12,0A4.05,4.05,0,1,0,16,4.05,4,4,0,0,0,12,0Z"/><path class="cls-4" d="M11.77,1.93a.54.54,0,0,0,0,.76l.82.82H10a.54.54,0,0,0,0,1.08h2.58l-.82.82a.54.54,0,1,0,.76.76l1.74-1.74a.53.53,0,0,0,0-.76L12.53,1.93A.54.54,0,0,0,11.77,1.93Z"/></g></svg>
\ 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 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#f2f2f2;}.cls-2{fill:#c1cbd5;}.cls-3{fill:#2195e7;}.cls-4{fill:#34495e;}</style></defs><title>inherits</title><g id="_10" data-name="10"><rect class="cls-1" x="2.5" y="3" width="11" height="10" rx="1"/><polygon class="cls-2" points="13 9.13 8.38 9.13 8.38 6 7.63 6 7.63 9.13 3 9.13 3 9.88 7.63 9.88 7.63 13 8.38 13 8.38 9.88 13 9.88 13 9.13"/><path class="cls-3" d="M12.5,3h-9a1,1,0,0,0-1,1v8a1,1,0,0,0,1,1h9a1,1,0,0,0,1-1V4A1,1,0,0,0,12.5,3Zm0,.75a.25.25,0,0,1,.25.25V6.12H8.38V3.75Zm-9,0H7.62V6.12H3.25V4A.25.25,0,0,1,3.5,3.75Zm9,8.5h-9A.25.25,0,0,1,3.25,12V6.88h9.5V12A.25.25,0,0,1,12.5,12.25Z"/><path class="cls-1" d="M12,8a3.93,3.93,0,1,1,3.93-3.93A3.94,3.94,0,0,1,12,8Z"/><path class="cls-4" d="M12,.25a3.8,3.8,0,1,1-3.8,3.8A3.8,3.8,0,0,1,12,.25M12,0A4.05,4.05,0,1,0,16,4.05,4,4,0,0,0,12,0Z"/><path class="cls-4" d="M12.13,1.93a.54.54,0,0,1,0,.76l-.82.82h2.58a.54.54,0,0,1,0,1.08H11.31l.82.82a.54.54,0,1,1-.76.76L9.63,4.43a.53.53,0,0,1,0-.76l1.74-1.74A.54.54,0,0,1,12.13,1.93Z"/></g></svg>
\ 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 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#f2f2f2;}.cls-2{fill:#c1cbd5;}.cls-3{fill:#2195e7;}.cls-4{fill:#34495e;}</style></defs><title>multiple</title><g id="_10" data-name="10"><rect class="cls-1" x="2.5" y="3" width="11" height="10" rx="1"/><polygon class="cls-2" points="13 9.13 8.38 9.13 8.38 6 7.63 6 7.63 9.13 3 9.13 3 9.88 7.63 9.88 7.63 13 8.38 13 8.38 9.88 13 9.88 13 9.13"/><path class="cls-3" d="M12.5,3h-9a1,1,0,0,0-1,1v8a1,1,0,0,0,1,1h9a1,1,0,0,0,1-1V4A1,1,0,0,0,12.5,3Zm0,.75a.25.25,0,0,1,.25.25V6.12H8.38V3.75Zm-9,0H7.62V6.12H3.25V4A.25.25,0,0,1,3.5,3.75Zm9,8.5h-9A.25.25,0,0,1,3.25,12V6.88h9.5V12A.25.25,0,0,1,12.5,12.25Z"/><path class="cls-1" d="M12,8a3.93,3.93,0,1,1,3.93-3.93A3.94,3.94,0,0,1,12,8Z"/><path class="cls-4" d="M12,.25a3.8,3.8,0,1,1-3.8,3.8A3.8,3.8,0,0,1,12,.25M12,0A4.05,4.05,0,1,0,16,4.05,4,4,0,0,0,12,0Z"/><path class="cls-4" d="M14.94,3.71,13.38,2.14a.49.49,0,0,0-.69.69l.73.73H10.48l.73-.73a.49.49,0,0,0-.69-.69L9,3.71a.48.48,0,0,0,0,.68L10.52,6a.49.49,0,1,0,.69-.69l-.73-.73h2.94l-.73.73a.49.49,0,1,0,.69.69l1.56-1.57a.48.48,0,0,0,0-.68Z"/></g></svg>
\ 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;
},
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin][RM3174] Distinguish simple tables from tables that are inherited and from which other tables are inherited
In-Reply-To: <CAM9w-_=7VjHC0zw_cNuXTH3BAp0CgmJ3kP-J9gF0psb=SfjeRA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox