mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-12-01 04:49:11 -06:00
Fix an issue in foreign tables node where it was displaying catalog tables in inherits options causing internal server error. Fixes RM#1520
This commit is contained in:
parent
99b4a0fe5b
commit
c336e8a743
@ -349,8 +349,6 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
|
||||
)
|
||||
|
||||
ver = self.manager.version
|
||||
server_type = self.manager.server_type
|
||||
|
||||
# Set template path for sql scripts depending
|
||||
# on the server version.
|
||||
|
||||
@ -495,15 +493,10 @@ shifted to the another schema.
|
||||
foid: Foreign Table Id
|
||||
"""
|
||||
|
||||
condition = """typisdefined AND typtype IN ('b', 'c', 'd', 'e', 'r')
|
||||
AND NOT EXISTS (SELECT 1 FROM pg_class WHERE relnamespace=typnamespace
|
||||
AND relname = typname AND relkind != 'c') AND
|
||||
(typname NOT LIKE '_%' OR NOT EXISTS (SELECT 1 FROM pg_class WHERE
|
||||
relnamespace=typnamespace AND relname = substring(typname FROM 2)::name
|
||||
AND relkind != 'c'))"""
|
||||
|
||||
if self.blueprint.show_system_objects:
|
||||
condition += " AND nsp.nspname != 'information_schema'"
|
||||
condition = render_template("/".join(
|
||||
[self.template_path, 'types_condition.sql']),
|
||||
server_type=self.manager.server_type,
|
||||
show_sys_objects=self.blueprint.show_system_objects)
|
||||
|
||||
# Get Types
|
||||
status, types = self.get_types(self.conn, condition)
|
||||
@ -562,8 +555,10 @@ AND relkind != 'c'))"""
|
||||
"""
|
||||
res = []
|
||||
try:
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'get_tables.sql']), foid=foid)
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path,'get_tables.sql']),
|
||||
foid=foid, server_type=self.manager.server_type,
|
||||
show_sys_objects=self.blueprint.show_system_objects)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
@ -0,0 +1,14 @@
|
||||
{% import 'foreign_tables/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||
typisdefined AND typtype IN ('b', 'c', 'd', 'e', 'r')
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM pg_class
|
||||
WHERE relnamespace=typnamespace
|
||||
AND relname = typname AND relkind != 'c')
|
||||
AND (typname NOT LIKE '_%' OR NOT EXISTS (
|
||||
SELECT 1 FROM pg_class
|
||||
WHERE relnamespace=typnamespace
|
||||
AND relname = substring(typname FROM 2)::name
|
||||
AND relkind != 'c'))
|
||||
{% if not show_system_objects %}
|
||||
{{ CATALOG.VALID_TYPE_CATALOGS(server_type) }}
|
||||
{% endif %}
|
@ -0,0 +1,14 @@
|
||||
{% import 'foreign_tables/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||
typisdefined AND typtype IN ('b', 'c', 'd', 'e', 'r')
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM pg_class
|
||||
WHERE relnamespace=typnamespace
|
||||
AND relname = typname AND relkind != 'c')
|
||||
AND (typname NOT LIKE '_%' OR NOT EXISTS (
|
||||
SELECT 1 FROM pg_class
|
||||
WHERE relnamespace=typnamespace
|
||||
AND relname = substring(typname FROM 2)::name
|
||||
AND relkind != 'c'))
|
||||
{% if not show_system_objects %}
|
||||
{{ CATALOG.VALID_TYPE_CATALOGS(server_type) }}
|
||||
{% endif %}
|
@ -1,3 +1,4 @@
|
||||
{% import 'foreign_tables/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||
{% if attrelid %}
|
||||
SELECT
|
||||
array_agg(quote_ident(n.nspname) || '.' || quote_ident(c.relname)) as inherits
|
||||
@ -14,6 +15,9 @@ FROM
|
||||
pg_class c, pg_namespace n
|
||||
WHERE
|
||||
c.relnamespace=n.oid AND c.relkind IN ('r', 'f')
|
||||
{% if not show_system_objects %}
|
||||
{{ CATALOG.VALID_CATALOGS(server_type) }}
|
||||
{% endif %}
|
||||
{% if foid %}
|
||||
AND c.oid <> {{foid}}::oid
|
||||
{% endif %}
|
||||
|
@ -0,0 +1,14 @@
|
||||
{% import 'foreign_tables/sql/macros/db_catalogs.macro' as CATALOG %}
|
||||
typisdefined AND typtype IN ('b', 'c', 'd', 'e', 'r')
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM pg_class
|
||||
WHERE relnamespace=typnamespace
|
||||
AND relname = typname AND relkind != 'c')
|
||||
AND (typname NOT LIKE '_%' OR NOT EXISTS (
|
||||
SELECT 1 FROM pg_class
|
||||
WHERE relnamespace=typnamespace
|
||||
AND relname = substring(typname FROM 2)::name
|
||||
AND relkind != 'c'))
|
||||
{% if not show_system_objects %}
|
||||
{{ CATALOG.VALID_TYPE_CATALOGS(server_type) }}
|
||||
{% endif %}
|
@ -0,0 +1,11 @@
|
||||
{% 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 %}
|
||||
{### Below macro is used in types fetching sql ###}
|
||||
{% macro VALID_TYPE_CATALOGS(server_type) -%}
|
||||
{% if server_type == 'ppas' %}
|
||||
AND nsp.nspname NOT IN ('information_schema', 'pgagent', 'dbo', 'sys') {% else %}
|
||||
AND nsp.nspname NOT IN ('information_schema') {% endif %}
|
||||
{%- endmacro %}
|
Loading…
Reference in New Issue
Block a user