mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -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
|
ver = self.manager.version
|
||||||
server_type = self.manager.server_type
|
|
||||||
|
|
||||||
# Set template path for sql scripts depending
|
# Set template path for sql scripts depending
|
||||||
# on the server version.
|
# on the server version.
|
||||||
|
|
||||||
@ -495,15 +493,10 @@ shifted to the another schema.
|
|||||||
foid: Foreign Table Id
|
foid: Foreign Table Id
|
||||||
"""
|
"""
|
||||||
|
|
||||||
condition = """typisdefined AND typtype IN ('b', 'c', 'd', 'e', 'r')
|
condition = render_template("/".join(
|
||||||
AND NOT EXISTS (SELECT 1 FROM pg_class WHERE relnamespace=typnamespace
|
[self.template_path, 'types_condition.sql']),
|
||||||
AND relname = typname AND relkind != 'c') AND
|
server_type=self.manager.server_type,
|
||||||
(typname NOT LIKE '_%' OR NOT EXISTS (SELECT 1 FROM pg_class WHERE
|
show_sys_objects=self.blueprint.show_system_objects)
|
||||||
relnamespace=typnamespace AND relname = substring(typname FROM 2)::name
|
|
||||||
AND relkind != 'c'))"""
|
|
||||||
|
|
||||||
if self.blueprint.show_system_objects:
|
|
||||||
condition += " AND nsp.nspname != 'information_schema'"
|
|
||||||
|
|
||||||
# Get Types
|
# Get Types
|
||||||
status, types = self.get_types(self.conn, condition)
|
status, types = self.get_types(self.conn, condition)
|
||||||
@ -562,8 +555,10 @@ AND relkind != 'c'))"""
|
|||||||
"""
|
"""
|
||||||
res = []
|
res = []
|
||||||
try:
|
try:
|
||||||
SQL = render_template("/".join([self.template_path,
|
SQL = render_template("/".join(
|
||||||
'get_tables.sql']), foid=foid)
|
[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)
|
status, rset = self.conn.execute_dict(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=res)
|
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 %}
|
{% if attrelid %}
|
||||||
SELECT
|
SELECT
|
||||||
array_agg(quote_ident(n.nspname) || '.' || quote_ident(c.relname)) as inherits
|
array_agg(quote_ident(n.nspname) || '.' || quote_ident(c.relname)) as inherits
|
||||||
@ -14,6 +15,9 @@ FROM
|
|||||||
pg_class c, pg_namespace n
|
pg_class c, pg_namespace n
|
||||||
WHERE
|
WHERE
|
||||||
c.relnamespace=n.oid AND c.relkind IN ('r', 'f')
|
c.relnamespace=n.oid AND c.relkind IN ('r', 'f')
|
||||||
|
{% if not show_system_objects %}
|
||||||
|
{{ CATALOG.VALID_CATALOGS(server_type) }}
|
||||||
|
{% endif %}
|
||||||
{% if foid %}
|
{% if foid %}
|
||||||
AND c.oid <> {{foid}}::oid
|
AND c.oid <> {{foid}}::oid
|
||||||
{% endif %}
|
{% 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