Hi,
PFA patch to fix the issue where system level catalog are also displayed in
PPAS server under relation of create new table like option.
RM#1530
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
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 8bda490..0d29ab3 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
@@ -277,7 +277,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
self.qtIdent = driver.qtIdent
# We need datlastsysoid to check if current table is system table
self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
-
+ self.server_type = self.manager.server_type
# If DB not connected then return error to browser
if not self.conn.connected():
return precondition_required(
@@ -285,10 +285,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
"Connection to the server has been lost!"
)
)
-
- # We need datlastsysoid to check if current index is system index
- self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
-
# we will set template path for sql scripts
ver = self.manager.version
# Template for Column node
@@ -1196,7 +1192,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
res = [{'label': '', 'value': ''}]
try:
SQL = render_template("/".join([self.template_path,
- 'get_oftype.sql']), scid=scid)
+ 'get_oftype.sql']), scid=scid,
+ server_type=self.server_type,
+ show_sys_objects=self.blueprint.show_system_objects)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)
@@ -1225,7 +1223,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
res = []
SQL = render_template("/".join([self.template_path, 'get_inherits.sql']),
show_system_objects=self.blueprint.show_system_objects,
- tid=tid)
+ tid=tid,
+ server_type=self.server_type)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)
@@ -1253,7 +1252,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
res = [{'label': '', 'value': ''}]
try:
SQL = render_template("/".join([self.template_path, 'get_relations.sql']),
- show_sys_objects=self.blueprint.show_system_objects)
+ show_sys_objects=self.blueprint.show_system_objects,
+ server_type=self.server_type)
status, rset = self.conn.execute_2darray(SQL)
if not status:
return internal_server_error(errormsg=res)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_inherits.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_inherits.sql
index 6b2560d..20e6c34 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_inherits.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_inherits.sql
@@ -1,3 +1,4 @@
+{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid, c.relname , nspname,
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
@@ -8,7 +9,7 @@ JOIN pg_namespace n
ON n.oid=c.relnamespace
WHERE relkind='r'
{% if not show_system_objects %}
-AND (n.nspname NOT LIKE E'pg\_%' AND n.nspname NOT in ('information_schema'))
+{{ CATALOG.VALID_CATALOGS(server_type) }}
{% endif %}
{% if tid %}
AND c.oid != tid
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql
index c5cedeb..5734935 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_oftype.sql
@@ -1,6 +1,9 @@
+{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid,
quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS typname
FROM pg_namespace n, pg_class c
WHERE c.relkind = 'c' AND c.relnamespace=n.oid
- AND NOT (n.nspname like 'pg_%' OR n.nspname='information_schema')
+{% if not show_system_objects %}
+{{ CATALOG.VALID_CATALOGS(server_type) }}
+{% endif %}
ORDER BY typname;
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql
index a9c11ae..20687fa 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/get_relations.sql
@@ -1,9 +1,9 @@
+{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid, quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS like_relation
FROM pg_class c, pg_namespace n
WHERE c.relnamespace=n.oid
AND c.relkind IN ('r', 'v', 'f')
{% if not show_sys_objects %}
- AND n.nspname NOT LIKE E'pg\\_%'
- AND n.nspname NOT in ('information_schema', 'sys')
+{{ CATALOG.VALID_CATALOGS(server_type) }}
{% endif %}
ORDER BY 1;
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_inherits.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_inherits.sql
index 6b2560d..20e6c34 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_inherits.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_inherits.sql
@@ -1,3 +1,4 @@
+{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid, c.relname , nspname,
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
@@ -8,7 +9,7 @@ JOIN pg_namespace n
ON n.oid=c.relnamespace
WHERE relkind='r'
{% if not show_system_objects %}
-AND (n.nspname NOT LIKE E'pg\_%' AND n.nspname NOT in ('information_schema'))
+{{ CATALOG.VALID_CATALOGS(server_type) }}
{% endif %}
{% if tid %}
AND c.oid != tid
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql
index c5cedeb..5734935 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_oftype.sql
@@ -1,6 +1,9 @@
+{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid,
quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS typname
FROM pg_namespace n, pg_class c
WHERE c.relkind = 'c' AND c.relnamespace=n.oid
- AND NOT (n.nspname like 'pg_%' OR n.nspname='information_schema')
+{% if not show_system_objects %}
+{{ CATALOG.VALID_CATALOGS(server_type) }}
+{% endif %}
ORDER BY typname;
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_relations.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_relations.sql
index a9c11ae..20687fa 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_relations.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/get_relations.sql
@@ -1,9 +1,9 @@
+{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid, quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS like_relation
FROM pg_class c, pg_namespace n
WHERE c.relnamespace=n.oid
AND c.relkind IN ('r', 'v', 'f')
{% if not show_sys_objects %}
- AND n.nspname NOT LIKE E'pg\\_%'
- AND n.nspname NOT in ('information_schema', 'sys')
+{{ CATALOG.VALID_CATALOGS(server_type) }}
{% endif %}
ORDER BY 1;
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/macros/db_catalogs.macro b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/macros/db_catalogs.macro
new file mode 100644
index 0000000..a97d37d
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/macros/db_catalogs.macro
@@ -0,0 +1,5 @@
+{% macro VALID_CATALOGS(server_type) -%}
+AND n.nspname NOT LIKE E'pg\_%' {% if server_type == 'ppas' %}
+AND n.nspname NOT IN ('information_schema', 'pgagent', 'dbo', 'sys') {% else %}
+AND n.nspname NOT IN ('information_schema') {% endif %}
+{%- endmacro %}
\ No newline at end of file
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers