Fix an issue where system level catalog are also displayed in PPAS server under relation of create new table like option. Fixes #1530
parent
c336e8a743
commit
9ec05d6bb1
|
@ -277,7 +277,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||||
self.qtIdent = driver.qtIdent
|
self.qtIdent = driver.qtIdent
|
||||||
# We need datlastsysoid to check if current table is system table
|
# We need datlastsysoid to check if current table is system table
|
||||||
self.datlastsysoid = self.manager.db_info[kwargs['did']]['datlastsysoid']
|
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 DB not connected then return error to browser
|
||||||
if not self.conn.connected():
|
if not self.conn.connected():
|
||||||
return precondition_required(
|
return precondition_required(
|
||||||
|
@ -285,10 +285,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||||
"Connection to the server has been lost!"
|
"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
|
# we will set template path for sql scripts
|
||||||
ver = self.manager.version
|
ver = self.manager.version
|
||||||
# Template for Column node
|
# Template for Column node
|
||||||
|
@ -1196,7 +1192,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||||
res = [{'label': '', 'value': ''}]
|
res = [{'label': '', 'value': ''}]
|
||||||
try:
|
try:
|
||||||
SQL = render_template("/".join([self.template_path,
|
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)
|
status, rset = self.conn.execute_2darray(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
@ -1225,7 +1223,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||||
res = []
|
res = []
|
||||||
SQL = render_template("/".join([self.template_path, 'get_inherits.sql']),
|
SQL = render_template("/".join([self.template_path, 'get_inherits.sql']),
|
||||||
show_system_objects=self.blueprint.show_system_objects,
|
show_system_objects=self.blueprint.show_system_objects,
|
||||||
tid=tid)
|
tid=tid,
|
||||||
|
server_type=self.server_type)
|
||||||
status, rset = self.conn.execute_2darray(SQL)
|
status, rset = self.conn.execute_2darray(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
@ -1253,7 +1252,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||||
res = [{'label': '', 'value': ''}]
|
res = [{'label': '', 'value': ''}]
|
||||||
try:
|
try:
|
||||||
SQL = render_template("/".join([self.template_path, 'get_relations.sql']),
|
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)
|
status, rset = self.conn.execute_2darray(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||||
SELECT c.oid, c.relname , nspname,
|
SELECT c.oid, c.relname , nspname,
|
||||||
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
|
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
|
||||||
quote_ident(nspname)||'.'||quote_ident(c.relname)
|
quote_ident(nspname)||'.'||quote_ident(c.relname)
|
||||||
|
@ -8,7 +9,7 @@ JOIN pg_namespace n
|
||||||
ON n.oid=c.relnamespace
|
ON n.oid=c.relnamespace
|
||||||
WHERE relkind='r'
|
WHERE relkind='r'
|
||||||
{% if not show_system_objects %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% if tid %}
|
{% if tid %}
|
||||||
AND c.oid != tid
|
AND c.oid != tid
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||||
SELECT c.oid,
|
SELECT c.oid,
|
||||||
quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS typname
|
quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS typname
|
||||||
FROM pg_namespace n, pg_class c
|
FROM pg_namespace n, pg_class c
|
||||||
WHERE c.relkind = 'c' AND c.relnamespace=n.oid
|
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;
|
ORDER BY typname;
|
|
@ -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
|
SELECT c.oid, quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS like_relation
|
||||||
FROM pg_class c, pg_namespace n
|
FROM pg_class c, pg_namespace n
|
||||||
WHERE c.relnamespace=n.oid
|
WHERE c.relnamespace=n.oid
|
||||||
AND c.relkind IN ('r', 'v', 'f')
|
AND c.relkind IN ('r', 'v', 'f')
|
||||||
{% if not show_sys_objects %}
|
{% if not show_sys_objects %}
|
||||||
AND n.nspname NOT LIKE E'pg\\_%'
|
{{ CATALOG.VALID_CATALOGS(server_type) }}
|
||||||
AND n.nspname NOT in ('information_schema', 'sys')
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
|
@ -1,3 +1,4 @@
|
||||||
|
{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||||
SELECT c.oid, c.relname , nspname,
|
SELECT c.oid, c.relname , nspname,
|
||||||
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
|
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
|
||||||
quote_ident(nspname)||'.'||quote_ident(c.relname)
|
quote_ident(nspname)||'.'||quote_ident(c.relname)
|
||||||
|
@ -8,7 +9,7 @@ JOIN pg_namespace n
|
||||||
ON n.oid=c.relnamespace
|
ON n.oid=c.relnamespace
|
||||||
WHERE relkind='r'
|
WHERE relkind='r'
|
||||||
{% if not show_system_objects %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% if tid %}
|
{% if tid %}
|
||||||
AND c.oid != tid
|
AND c.oid != tid
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||||
SELECT c.oid,
|
SELECT c.oid,
|
||||||
quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS typname
|
quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS typname
|
||||||
FROM pg_namespace n, pg_class c
|
FROM pg_namespace n, pg_class c
|
||||||
WHERE c.relkind = 'c' AND c.relnamespace=n.oid
|
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;
|
ORDER BY typname;
|
|
@ -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
|
SELECT c.oid, quote_ident(n.nspname)||'.'||quote_ident(c.relname) AS like_relation
|
||||||
FROM pg_class c, pg_namespace n
|
FROM pg_class c, pg_namespace n
|
||||||
WHERE c.relnamespace=n.oid
|
WHERE c.relnamespace=n.oid
|
||||||
AND c.relkind IN ('r', 'v', 'f')
|
AND c.relkind IN ('r', 'v', 'f')
|
||||||
{% if not show_sys_objects %}
|
{% if not show_sys_objects %}
|
||||||
AND n.nspname NOT LIKE E'pg\\_%'
|
{{ CATALOG.VALID_CATALOGS(server_type) }}
|
||||||
AND n.nspname NOT in ('information_schema', 'sys')
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
|
@ -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 %}
|
Loading…
Reference in New Issue