Fix filtering of system schemas so pg_* is hidden but pg* is not. Fixes #2709

This commit is contained in:
Murtuza Zabuawala
2017-09-15 13:50:06 +01:00
committed by Dave Page
parent 55e14e4d78
commit 9cfb2f3cbe
19 changed files with 25 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
{% macro VALID_CATALOGS(server_type) -%}
AND n.nspname NOT LIKE E'pg\_%' {% if server_type == 'ppas' %}
AND n.nspname NOT LIKE '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 %}

View File

@@ -5,7 +5,7 @@ FROM
(SELECT oid, relname, relnamespace FROM pg_catalog.pg_class
WHERE relkind in ('r', 'p') AND NOT relispartition) r
JOIN (SELECT oid AS nspoid, nspname FROM
pg_catalog.pg_namespace WHERE nspname NOT LIKE E'pg\_%') n
pg_catalog.pg_namespace WHERE nspname NOT LIKE 'pg\_%') n
ON (r.relnamespace = n.nspoid)
JOIN (SELECT attrelid, attname, atttypid FROM
pg_catalog.pg_attribute WHERE attnum > 0 ORDER BY attrelid, attnum) a
@@ -20,4 +20,4 @@ FROM
ORDER BY attrelid, attnum) attributes
GROUP BY attrelid) current_table ON current_table.attrelid != all_tables.oid
AND current_table.attnames = all_tables.attnames
AND current_table.atttypes = all_tables.atttypes
AND current_table.atttypes = all_tables.atttypes

View File

@@ -13,7 +13,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
WHERE tgrelid=rel.oid) AS isrepl,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%') THEN
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
ELSE quote_ident(c.relname) END AS inherited_tables
FROM pg_inherits i

View File

@@ -1,6 +1,6 @@
{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid, c.relname , nspname,
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
CASE WHEN nspname NOT LIKE 'pg\_%' THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
ELSE quote_ident(c.relname)
END AS inherits
@@ -14,4 +14,4 @@ WHERE relkind='r' AND NOT relispartition
{% if tid %}
AND c.oid != tid
{% endif %}
ORDER BY relnamespace, c.relname
ORDER BY relnamespace, c.relname

View File

@@ -13,7 +13,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
WHERE tgrelid=rel.oid) AS isrepl,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%') THEN
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
ELSE quote_ident(c.relname) END AS inherited_tables
FROM pg_inherits i

View File

@@ -12,7 +12,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
WHERE tgrelid=rel.oid) AS isrepl,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%') THEN
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
ELSE quote_ident(c.relname) END AS inherited_tables
FROM pg_inherits i

View File

@@ -1,6 +1,6 @@
{% import 'table/sql/macros/db_catalogs.macro' as CATALOG %}
SELECT c.oid, c.relname , nspname,
CASE WHEN nspname NOT LIKE E'pg\_%' THEN
CASE WHEN nspname NOT LIKE 'pg\_%' THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
ELSE quote_ident(c.relname)
END AS inherits
@@ -14,4 +14,4 @@ WHERE relkind='r'
{% if tid %}
AND c.oid != tid
{% endif %}
ORDER BY relnamespace, c.relname
ORDER BY relnamespace, c.relname

View File

@@ -3,6 +3,6 @@ FROM pg_namespace nsp, pg_class cl
WHERE relnamespace=nsp.oid AND relkind='r'
AND nsp.nspname NOT LIKE E'pg\_temp\_%'
{% if not show_sysobj %}
AND (nsp.nspname NOT LIKE E'pg\_%' AND nsp.nspname NOT in ('information_schema'))
AND (nsp.nspname NOT LIKE 'pg\_%' AND nsp.nspname NOT in ('information_schema'))
{% endif %}
ORDER BY nspname, relname
ORDER BY nspname, relname

View File

@@ -15,7 +15,7 @@ FROM (
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
WHERE tgrelid=rel.oid) AS isrepl,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid) AS triggercount,
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%') THEN
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
ELSE quote_ident(c.relname) END AS inherited_tables
FROM pg_inherits i
@@ -71,4 +71,4 @@ FROM (
WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}
{% if tid %} AND rel.oid = {{ tid }}::oid {% endif %}
) AS TableInformation
ORDER BY name
ORDER BY name

View File

@@ -15,7 +15,7 @@ FROM (
JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
WHERE tgrelid=rel.oid) AS isrepl,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid) AS triggercount,
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%') THEN
(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
quote_ident(nspname)||'.'||quote_ident(c.relname)
ELSE quote_ident(c.relname) END AS inherited_tables
FROM pg_inherits i

View File

@@ -1,5 +1,5 @@
{% macro VALID_CATALOGS(server_type) -%}
AND n.nspname NOT LIKE E'pg\_%' {% if server_type == 'ppas' %}
AND n.nspname NOT LIKE '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 %}
{%- endmacro %}

View File

@@ -6,7 +6,7 @@ FROM pg_proc p, pg_namespace n, pg_language l
AND l.lanname != 'edbspl' AND prorettype = 2279
-- If Show SystemObjects is not true
{% if not show_system_objects %}
AND (nspname NOT LIKE E'pg\_%' AND nspname NOT in ('information_schema'))
AND (nspname NOT LIKE 'pg\_%' AND nspname NOT in ('information_schema'))
{% endif %}
-- Find function for specific OID
{% if tgfoid %}

View File

@@ -11,7 +11,7 @@ WHERE
nsp.oid={{scid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND
nspname NOT LIKE 'pg\_%' AND
{% endif %}
{% endif %}
NOT (

View File

@@ -11,7 +11,7 @@ WHERE
nsp.oid={{scid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND
nspname NOT LIKE 'pg\_%' AND
{% endif %}
{% endif %}
NOT (

View File

@@ -11,7 +11,7 @@ WHERE
nsp.oid={{scid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND
nspname NOT LIKE 'pg\_%' AND
{% endif %}
{% endif %}
NOT (

View File

@@ -12,7 +12,7 @@ WHERE
nsp.oid={{scid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND
nspname NOT LIKE 'pg\_%' AND
{% endif %}
{% endif %}
NOT (

View File

@@ -12,7 +12,7 @@ WHERE
nsp.oid={{scid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND
nspname NOT LIKE 'pg\_%' AND
{% endif %}
{% endif %}
NOT (

View File

@@ -10,7 +10,7 @@ WHERE
nsp.oid={{nspid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND
nspname NOT LIKE 'pg\_%' AND
{% endif %}
{% endif %}
NOT (

View File

@@ -11,7 +11,7 @@ WHERE
nsp.oid={{nspid}}::oid AND
{% else %}
{% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND
nspname NOT LIKE 'pg\_%' AND
{% endif %}
{% endif %}
NOT (