Use schema qualification while accessing the catalog objects. Fixes #3976

This commit is contained in:
Rahul Shirsat 2021-03-09 13:18:45 +05:30 committed by Akshay Joshi
parent 8cf7c41ad9
commit a2be30d257
738 changed files with 5027 additions and 5022 deletions

View File

@ -15,6 +15,7 @@ New features
Housekeeping
************
| `Issue #3976 <https://redmine.postgresql.org/issues/3976>`_ - Use schema qualification while accessing the catalog objects.
Bug fixes
*********

View File

@ -1,14 +1,14 @@
{# FETCH CAST SOURCE TYPE AND TARGET TYPE Statement #}
{% if cid %}
SELECT
format_type(ca.castsource, null) as castsource,
format_type(ca.casttarget, null) as casttarget
pg_catalog.format_type(ca.castsource, null) as castsource,
pg_catalog.format_type(ca.casttarget, null) as casttarget
FROM
pg_cast ca
pg_catalog.pg_cast ca
WHERE
ca.oid = {{cid}}::OID;
{% endif %}
{# DROP CAST Statement #}
{% if castsource and casttarget %}
DROP CAST ({{castsource}} AS {{casttarget}}) {% if cascade %}CASCADE{%endif%};
{% endif %}
{% endif %}

View File

@ -4,14 +4,14 @@ SELECT
nspname,
proargtypes
FROM
pg_proc p JOIN pg_namespace n ON n.oid=p.pronamespace
pg_catalog.pg_proc p JOIN pg_namespace n ON n.oid=p.pronamespace
WHERE
proargtypes[0] = (SELECT t.oid FROM pg_type t WHERE format_type(t.oid, NULL) = {{srctyp|qtLiteral}})
AND prorettype = (SELECT t.oid FROM pg_type t WHERE format_type(t.oid, NULL) = {{trgtyp|qtLiteral}})
proargtypes[0] = (SELECT t.oid FROM pg_catalog.pg_type t WHERE pg_catalog.format_type(t.oid, NULL) = {{srctyp|qtLiteral}})
AND prorettype = (SELECT t.oid FROM pg_catalog.pg_type t WHERE pg_catalog.format_type(t.oid, NULL) = {{trgtyp|qtLiteral}})
AND CASE
WHEN array_length(proargtypes,1) = 2 THEN
WHEN pg_catalog.array_length(proargtypes,1) = 2 THEN
proargtypes[1] = 23
WHEN array_length(proargtypes,1) >= 3 THEN
WHEN pg_catalog.array_length(proargtypes,1) >= 3 THEN
proargtypes[1] = 23 AND proargtypes[2] = 16
ELSE TRUE
END

View File

@ -1,8 +1,8 @@
SELECT
*
FROM (
SELECT
format_type(t.oid,NULL) AS typname,
SELECT
pg_catalog.format_type(t.oid,NULL) AS typname,
CASE
WHEN typelem > 0 THEN typelem
ELSE t.oid
@ -11,10 +11,10 @@ FROM (
typtype,
t.oid,
nspname,
(SELECT COUNT(1) FROM pg_type t2 WHERE t2.typname = t.typname) > 1 AS isdup
(SELECT COUNT(1) FROM pg_catalog.pg_type t2 WHERE t2.typname = t.typname) > 1 AS isdup
FROM
pg_type t
JOIN pg_namespace nsp ON typnamespace=nsp.oid
pg_catalog.pg_type t
JOIN pg_catalog.pg_namespace nsp ON typnamespace=nsp.oid
WHERE
(NOT (typname = 'unknown'
AND nspname = 'pg_catalog'))
@ -24,7 +24,7 @@ FROM (
SELECT
1
FROM
pg_class
pg_catalog.pg_class
WHERE
relnamespace = typnamespace
AND relname = typname
@ -34,7 +34,7 @@ FROM (
SELECT
1
FROM
pg_class
pg_catalog.pg_class
WHERE
relnamespace = typnamespace
AND relname = SUBSTRING(typname FROM 2)::name

View File

@ -1,14 +1,14 @@
SELECT
ca.oid,
concat(format_type(st.oid,NULL),'->',format_type(tt.oid,tt.typtypmod)) as name
FROM pg_cast ca
JOIN pg_type st ON st.oid=castsource
JOIN pg_namespace ns ON ns.oid=st.typnamespace
JOIN pg_type tt ON tt.oid=casttarget
JOIN pg_namespace nt ON nt.oid=tt.typnamespace
LEFT JOIN pg_proc pr ON pr.oid=castfunc
LEFT JOIN pg_namespace np ON np.oid=pr.pronamespace
LEFT OUTER JOIN pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass)
pg_catalog.concat(pg_catalog.format_type(st.oid,NULL),'->',pg_catalog.format_type(tt.oid,tt.typtypmod)) as name
FROM pg_catalog.pg_cast ca
JOIN pg_catalog.pg_type st ON st.oid=castsource
JOIN pg_catalog.pg_namespace ns ON ns.oid=st.typnamespace
JOIN pg_catalog.pg_type tt ON tt.oid=casttarget
JOIN pg_catalog.pg_namespace nt ON nt.oid=tt.typnamespace
LEFT JOIN pg_catalog.pg_proc pr ON pr.oid=castfunc
LEFT JOIN pg_catalog.pg_namespace np ON np.oid=pr.pronamespace
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass)
{% if cid %}
WHERE ca.oid={{cid}}::oid
{% endif %}
@ -21,4 +21,4 @@
{% endif %}
ca.oid > {{datlastsysoid}}::OID
{% endif %}
ORDER BY st.typname, tt.typname
ORDER BY st.typname, tt.typname

View File

@ -2,7 +2,7 @@
{% if srctyp and trgtyp %}
SELECT
ca.oid
FROM pg_cast ca
FROM pg_catalog.pg_cast ca
WHERE ca.castsource = (SELECT t.oid FROM pg_type t WHERE format_type(t.oid, NULL) = {{srctyp|qtLiteral}})
AND ca.casttarget = (SELECT t.oid FROM pg_type t WHERE format_type(t.oid, NULL) = {{trgtyp|qtLiteral}})
{% if datlastsysoid %}
@ -27,21 +27,21 @@
ELSE proname || '(' || pg_catalog.pg_get_function_identity_arguments(pr.oid) || ')'
END AS proname,
ca.castfunc,
format_type(st.oid,NULL) AS srctyp,
format_type(tt.oid,tt.typtypmod) AS trgtyp,
pg_catalog.format_type(st.oid,NULL) AS srctyp,
pg_catalog.format_type(tt.oid,tt.typtypmod) AS trgtyp,
ns.nspname AS srcnspname,
nt.nspname AS trgnspname,
np.nspname AS pronspname,
description,
concat(format_type(st.oid,NULL),'->',format_type(tt.oid,tt.typtypmod)) as name
FROM pg_cast ca
JOIN pg_type st ON st.oid=castsource
JOIN pg_namespace ns ON ns.oid=st.typnamespace
JOIN pg_type tt ON tt.oid=casttarget
JOIN pg_namespace nt ON nt.oid=tt.typnamespace
LEFT JOIN pg_proc pr ON pr.oid=castfunc
LEFT JOIN pg_namespace np ON np.oid=pr.pronamespace
LEFT OUTER JOIN pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass)
pg_catalog.concat(pg_catalog.format_type(st.oid,NULL),'->',pg_catalog.format_type(tt.oid,tt.typtypmod)) as name
FROM pg_catalog.pg_cast ca
JOIN pg_catalog.pg_type st ON st.oid=castsource
JOIN pg_catalog.pg_namespace ns ON ns.oid=st.typnamespace
JOIN pg_catalog.pg_type tt ON tt.oid=casttarget
JOIN pg_catalog.pg_namespace nt ON nt.oid=tt.typnamespace
LEFT JOIN pg_catalog.pg_proc pr ON pr.oid=castfunc
LEFT JOIN pg_catalog.pg_namespace np ON np.oid=pr.pronamespace
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass)
{% if cid %}
WHERE ca.oid={{cid}}::oid

View File

@ -1,14 +1,14 @@
SELECT
array_to_string(array_agg(sql), E'\n\n') as sql
pg_catalog.array_to_string(array_agg(sql), E'\n\n') as sql
FROM
(SELECT
E'-- Cast: ' ||
format_type(st.oid, null)|| E' -> ' ||
format_type(tt.oid, tt.typtypmod) ||
E'\n\n-- DROP CAST (' || format_type(st.oid, null) ||
E' AS ' || format_type(tt.oid,tt.typtypmod) ||
E');\n\nCREATE CAST (' || format_type(st.oid, null) ||
E' AS ' || format_type(tt.oid,tt.typtypmod) || E')\n' ||
pg_catalog.format_type(st.oid, null)|| E' -> ' ||
pg_catalog.format_type(tt.oid, tt.typtypmod) ||
E'\n\n-- DROP CAST (' || pg_catalog.format_type(st.oid, null) ||
E' AS ' || pg_catalog.format_type(tt.oid,tt.typtypmod) ||
E');\n\nCREATE CAST (' || pg_catalog.format_type(st.oid, null) ||
E' AS ' || pg_catalog.format_type(tt.oid,tt.typtypmod) || E')\n' ||
CASE WHEN ca.castfunc != 0 THEN
E'\tWITH FUNCTION ' ||
pr.proname || '(' || COALESCE(pg_catalog.pg_get_function_identity_arguments(pr.oid), '') || E')'
@ -19,23 +19,23 @@ FROM
WHEN ca.castcontext = 'i' THEN E'\n\tAS IMPLICIT;'
ELSE E';' END ||
CASE WHEN a.description IS NOT NULL THEN
E'\n\nCOMMENT ON CAST (' || (format_type(st.oid,NULL)) ||
E' AS ' || (format_type(tt.oid,tt.typtypmod)) ||
E'\n\nCOMMENT ON CAST (' || (pg_catalog.format_type(st.oid,NULL)) ||
E' AS ' || (pg_catalog.format_type(tt.oid,tt.typtypmod)) ||
E') IS ' || pg_catalog.quote_literal(description) || E';'
ELSE '' END as sql
FROM
pg_cast ca
JOIN pg_type st ON st.oid=ca.castsource
JOIN pg_namespace ns ON ns.oid=st.typnamespace
JOIN pg_type tt ON tt.oid=ca.casttarget
JOIN pg_namespace nt ON nt.oid=tt.typnamespace
LEFT JOIN pg_proc pr ON pr.oid=ca.castfunc
pg_catalog.pg_cast ca
JOIN pg_catalog.pg_type st ON st.oid=ca.castsource
JOIN pg_catalog.pg_namespace ns ON ns.oid=st.typnamespace
JOIN pg_catalog.pg_type tt ON tt.oid=ca.casttarget
JOIN pg_catalog.pg_namespace nt ON nt.oid=tt.typnamespace
LEFT JOIN pg_catalog.pg_proc pr ON pr.oid=ca.castfunc
LEFT JOIN (
SELECT
des.description as description,
des.objoid as descoid
FROM
pg_description des
pg_catalog.pg_description des
WHERE
des.objoid={{cid}}::OID AND des.objsubid=0 AND des.classoid='pg_cast'::regclass
) a ON (a.descoid = ca.oid)

View File

@ -1,7 +1,7 @@
{% if etid %}
SELECT e.evtname AS name FROM pg_event_trigger e
SELECT e.evtname AS name FROM pg_catalog.pg_event_trigger e
WHERE e.oid={{etid}}::oid;
{% endif %}
{% if name %}
DROP EVENT TRIGGER IF EXISTS {{ conn|qtIdent(name) }}{% if cascade%} CASCADE{% endif %};
{% endif %}
{% endif %}

View File

@ -1,4 +1,4 @@
SELECT quote_ident(nspname) || '.' || quote_ident(proname) AS tfname
FROM pg_proc p, pg_namespace n, pg_language l
SELECT pg_catalog.quote_ident(nspname) || '.' || pg_catalog.quote_ident(proname) AS tfname
FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n, pg_catalog.pg_language l
WHERE p.pronamespace = n.oid AND p.prolang = l.oid AND p.pronargs = 0 AND l.lanname != 'sql' AND prorettype::regtype::text = 'event_trigger'
ORDER BY nspname ASC, proname ASC
ORDER BY nspname ASC, proname ASC

View File

@ -1 +1 @@
SELECT db.datname as name FROM pg_database as db WHERE db.oid = {{did}}
SELECT db.datname as name FROM pg_catalog.pg_database as db WHERE db.oid = {{did}}

View File

@ -1,5 +1,5 @@
{# The Sql below will provide oid for newly created event_trigger #}
{% if data %}
SELECT e.oid from pg_event_trigger e
SELECT e.oid from pg_catalog.pg_event_trigger e
WHERE e.evtname = {{ data.name|qtLiteral }}
{% endif %}
{% endif %}

View File

@ -1,5 +1,5 @@
SELECT e.oid, e.evtname AS name
FROM pg_event_trigger e
FROM pg_catalog.pg_event_trigger e
{% if etid %}
WHERE e.oid={{etid}}::oid
{% endif %}

View File

@ -4,17 +4,17 @@ e.evtenabled AS enabled,
e.evtfoid AS eventfuncoid,
CASE
WHEN n.nspname = 'public'
THEN quote_ident(n.nspname) || '.' || cast(e.evtfoid::regproc as text)
THEN pg_catalog.quote_ident(n.nspname) || '.' || cast(e.evtfoid::regproc as text)
ELSE cast(e.evtfoid::regproc as text)
END AS eventfunname,
array_to_string(array(select quote_literal(x) from unnest(evttags) as t(x)), ', ') AS when,
pg_catalog.array_to_string(array(select pg_catalog.quote_literal(x) from pg_catalog.unnest(evttags) as t(x)), ', ') AS when,
pg_catalog.obj_description(e.oid, 'pg_event_trigger') AS comment,
(SELECT array_agg(provider || '=' || label) FROM pg_seclabel sl1 WHERE sl1.objoid=e.oid) AS seclabels,
(SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabel sl1 WHERE sl1.objoid=e.oid) AS seclabels,
p.prosrc AS source, p.pronamespace AS schemaoid, l.lanname AS language
FROM pg_event_trigger e
LEFT OUTER JOIN pg_proc p ON p.oid=e.evtfoid
LEFT OUTER JOIN pg_language l ON l.oid=p.prolang,
pg_namespace n
FROM pg_catalog.pg_event_trigger e
LEFT OUTER JOIN pg_catalog.pg_proc p ON p.oid=e.evtfoid
LEFT OUTER JOIN pg_catalog.pg_language l ON l.oid=p.prolang,
pg_catalog.pg_namespace n
WHERE p.pronamespace = n.oid
{% if etid %}
AND e.oid={{etid}}::oid

View File

@ -1,6 +1,6 @@
{#============================Drop/Cascade Extension by name=========================#}
{% if eid %}
SELECT x.extname from pg_extension x
SELECT x.extname from pg_catalog.pg_extension x
WHERE x.oid = {{ eid }}::oid
{% endif %}
{% if name %}

View File

@ -1,12 +1,12 @@
{# ======================Fetch extensions names=====================#}
SELECT
a.name, a.installed_version,
array_agg(av.version) as version,
array_agg(av.schema) as schema,
array_agg(av.superuser) as superuser,
array_agg(av.relocatable) as relocatable
pg_catalog.array_agg(av.version) as version,
pg_catalog.array_agg(av.schema) as schema,
pg_catalog.array_agg(av.superuser) as superuser,
pg_catalog.array_agg(av.relocatable) as relocatable
FROM
pg_available_extensions a
LEFT JOIN pg_available_extension_versions av ON (a.name = av.name)
pg_catalog.pg_available_extensions a
LEFT JOIN pg_catalog.pg_available_extension_versions av ON (a.name = av.name)
GROUP BY a.name, a.installed_version
ORDER BY a.name

View File

@ -1,13 +1,13 @@
{#===================Fetch properties of each extension by name or oid===================#}
SELECT
x.oid, pg_get_userbyid(extowner) AS owner,
x.oid, pg_catalog.pg_get_userbyid(extowner) AS owner,
x.extname AS name, n.nspname AS schema,
x.extrelocatable AS relocatable, x.extversion AS version,
e.comment
FROM
pg_extension x
LEFT JOIN pg_namespace n ON x.extnamespace=n.oid
JOIN pg_available_extensions() e(name, default_version, comment) ON x.extname=e.name
pg_catalog.pg_extension x
LEFT JOIN pg_catalog.pg_namespace n ON x.extnamespace=n.oid
JOIN pg_catalog.pg_available_extensions() e(name, default_version, comment) ON x.extname=e.name
{%- if eid %}
WHERE x.oid = {{eid}}::oid
{% elif ename %}

View File

@ -1,4 +1,4 @@
SELECT 'fsrvacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
SELECT 'fsrvacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
@ -7,14 +7,14 @@ FROM
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT srvacl FROM pg_foreign_server fsrv
LEFT OUTER JOIN pg_shdescription descr ON (
(SELECT srvacl FROM pg_catalog.pg_foreign_server fsrv
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
fsrv.oid=descr.objoid AND descr.classoid='pg_foreign_server'::regclass)
{% if fsid %}
WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID
{% endif %}
) acl,
aclexplode(srvacl) d
pg_catalog.aclexplode(srvacl) d
) d
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)

View File

@ -1,16 +1,16 @@
{# ============= Give all the properties of foreign server ============= #}
{% if fdwid %}
SELECT fdw.oid as fdwoid, fdwname as name
FROM pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
FROM pg_catalog.pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
WHERE fdw.oid={{fdwid}}::oid
{% else %}
SELECT srv.oid, srvname as name, srvfdw as fdwid, srvtype as fsrvtype, srvversion as fsrvversion,
fdw.fdwname as fdwname, description, array_to_string(srvoptions, ',') AS fsrvoptions,
pg_get_userbyid(srvowner) as fsrvowner, array_to_string(srvacl::text[], ', ') as acl
FROM pg_foreign_server srv
LEFT OUTER JOIN pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
LEFT OUTER JOIN pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
fdw.fdwname as fdwname, description, pg_catalog.array_to_string(srvoptions, ',') AS fsrvoptions,
pg_catalog.pg_get_userbyid(srvowner) as fsrvowner, pg_catalog.array_to_string(srvacl::text[], ', ') as acl
FROM pg_catalog.pg_foreign_server srv
LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
{% if data and fdwdata %}
WHERE fdw.fdwname = {{ fdwdata.name|qtLiteral }}::text and srvname = {{ data.name|qtLiteral }}::text
{% elif fdwdata %}

View File

@ -1,4 +1,4 @@
SELECT 'fsrvacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
SELECT 'fsrvacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
@ -7,8 +7,8 @@ FROM
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT srvacl FROM pg_foreign_server fsrv
LEFT OUTER JOIN pg_shdescription descr ON (
(SELECT srvacl FROM pg_catalog.pg_foreign_server fsrv
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
fsrv.oid=descr.objoid AND descr.classoid='pg_foreign_server'::regclass)
{% if fsid %}
WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID
@ -16,7 +16,7 @@ FROM
) acl,
(SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable,
(d).privilege_type AS privilege_type
FROM (SELECT aclexplode(srvacl) as d FROM pg_foreign_server fsrv1
FROM (SELECT pg_catalog.aclexplode(srvacl) as d FROM pg_catalog.pg_foreign_server fsrv1
{% if fsid %}
WHERE fsrv1.oid = {{ fsid|qtLiteral }}::OID ) a
{% endif %}

View File

@ -1,9 +1,9 @@
{# ============= Give foreign server name from foreign server id ============= #}
{% if fsid %}
SELECT srvname as name FROM pg_foreign_server srv LEFT OUTER JOIN pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
SELECT srvname as name FROM pg_foreign_server srv LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
WHERE srv.oid={{fsid}}::oid;
{% endif %}
{# ============= Delete/Drop cascade foreign server ============= #}
{% if name %}
DROP SERVER {{ conn|qtIdent(name) }} {% if cascade %} CASCADE {% endif %};
{% endif %}
{% endif %}

View File

@ -1,6 +1,6 @@
{# ============= Get dependents of foreign server ============= #}
{% if fsid %}
SELECT um.umid as um_oid, um.usename as name, dep.deptype FROM pg_user_mappings um
LEFT JOIN pg_depend dep ON dep.objid=um.umid
SELECT um.umid as um_oid, um.usename as name, dep.deptype FROM pg_catalog.pg_user_mappings um
LEFT JOIN pg_catalog.pg_depend dep ON dep.objid=um.umid
WHERE um.srvid = {{ fsid }}::OID
{% endif %}

View File

@ -2,16 +2,16 @@
{% if fdwid %}
SELECT fdw.oid as fdwoid,
fdwname as name
FROM pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
FROM pg_catalog.pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
WHERE fdw.oid={{fdwid}}::oid
{% else %}
SELECT srv.oid, srvname as name, srvtype as fsrvtype, srvversion as fsrvversion, fdw.fdwname as fdwname, description,
array_to_string(srvoptions, ',') AS fsrvoptions,
pg_get_userbyid(srvowner) as fsrvowner, array_to_string(srvacl::text[], ', ') as acl
FROM pg_foreign_server srv
LEFT OUTER JOIN pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
LEFT OUTER JOIN pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
pg_catalog.array_to_string(srvoptions, ',') AS fsrvoptions,
pg_catalog.pg_get_userbyid(srvowner) as fsrvowner, pg_catalog.array_to_string(srvacl::text[], ', ') as acl
FROM pg_catalog.pg_foreign_server srv
LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
{% if data and fdwdata %}
WHERE fdw.fdwname = {{ fdwdata.name|qtLiteral }}::text and srvname = {{ data.name|qtLiteral }}::text
{% elif fdwdata %}

View File

@ -1,6 +1,6 @@
{# ============= Get the foreing server name from id ============= #}
{% if fsid %}
SELECT srvname as name FROM pg_foreign_server srv LEFT OUTER JOIN pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
SELECT srvname as name FROM pg_catalog.pg_foreign_server srv LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw
WHERE srv.oid={{fsid}}::oid;
{% endif %}
{# ============= Drop/Delete cascade user mapping ============= #}

View File

@ -1,18 +1,18 @@
{# ============= Get the properties of user mapping ============= #}
{% if fserid %}
SELECT srv.oid as fsrvid, srvname as name
FROM pg_foreign_server srv
LEFT OUTER JOIN pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
FROM pg_catalog.pg_foreign_server srv
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
WHERE srv.oid = {{fserid}}::oid
{% elif fsid or umid %}
SELECT u.umid AS oid, u.usename AS name, u.srvid AS fsid, array_to_string(u.umoptions, ',') AS umoptions, fs.srvfdw AS fdwid
FROM pg_user_mappings u
LEFT JOIN pg_foreign_server fs ON fs.oid = u.srvid
SELECT u.umid AS oid, u.usename AS name, u.srvid AS fsid, pg_catalog.array_to_string(u.umoptions, ',') AS umoptions, fs.srvfdw AS fdwid
FROM pg_catalog.pg_user_mappings u
LEFT JOIN pg_catalog.pg_foreign_server fs ON fs.oid = u.srvid
{% if fsid %} WHERE u.srvid = {{fsid}}::oid {% endif %} {% if umid %} WHERE u.umid= {{umid}}::oid {% endif %}
ORDER BY 2;
{% else %}
SELECT u.umid AS oid, u.usename AS name, u.srvid AS fsid, array_to_string(u.umoptions, ',') AS umoptions, fs.srvfdw AS fdwid
FROM pg_user_mappings u
LEFT JOIN pg_foreign_server fs ON fs.oid = u.srvid
SELECT u.umid AS oid, u.usename AS name, u.srvid AS fsid, pg_catalog.array_to_string(u.umoptions, ',') AS umoptions, fs.srvfdw AS fdwid
FROM pg_catalog.pg_user_mappings u
LEFT JOIN pg_catalog.pg_foreign_server fs ON fs.oid = u.srvid
ORDER BY 2;
{% endif %}

View File

@ -1,4 +1,4 @@
SELECT 'fdwacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
SELECT 'fdwacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
@ -7,14 +7,14 @@ FROM
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT fdwacl FROM pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_shdescription descr ON (
(SELECT fdwacl FROM pg_catalog.pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
fdw.oid=descr.objoid AND descr.classoid='pg_foreign_data_wrapper'::regclass)
{% if fid %}
WHERE fdw.oid = {{ fid|qtLiteral }}::OID
{% endif %}
) acl,
aclexplode(fdwacl) d
pg_catalog.aclexplode(fdwacl) d
) d
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)

View File

@ -1,22 +1,22 @@
{# ============= Get all the properties of foreign data wrapper ============= #}
SELECT fdw.oid, fdwname as name, fdwhandler, fdwvalidator, description,
array_to_string(fdwoptions, ',') AS fdwoptions, pg_get_userbyid(fdwowner) as fdwowner, array_to_string(fdwacl::text[], ', ') as acl,
pg_catalog.array_to_string(fdwoptions, ',') AS fdwoptions, pg_catalog.pg_get_userbyid(fdwowner) as fdwowner, pg_catalog.array_to_string(fdwacl::text[], ', ') as acl,
CASE
-- EPAS in redwood mode, concatenation of a string with NULL results as the original string
WHEN vp.proname IS NULL THEN NULL
ELSE quote_ident(vp_nsp.nspname)||'.'||quote_ident(vp.proname)
ELSE pg_catalog.quote_ident(vp_nsp.nspname)||'.'||pg_catalog.quote_ident(vp.proname)
END fdwvalue,
CASE
-- EPAS in redwood mode, concatenation of a string with NULL results as the original string
WHEN vh.proname IS NULL THEN NULL
ELSE quote_ident(vh_nsp.nspname)||'.'||quote_ident(vh.proname)
ELSE pg_catalog.quote_ident(vh_nsp.nspname)||'.'||pg_catalog.quote_ident(vh.proname)
END fdwhan
FROM pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_proc vh on vh.oid=fdwhandler
LEFT OUTER JOIN pg_proc vp on vp.oid=fdwvalidator
LEFT OUTER JOIN pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
LEFT OUTER JOIN pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
FROM pg_catalog.pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler
LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator
LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
{% if fid %}
WHERE fdw.oid={{fid}}::oid
{% endif %}

View File

@ -1,4 +1,4 @@
SELECT 'fdwacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
SELECT 'fdwacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
@ -7,8 +7,8 @@ FROM
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT fdwacl FROM pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_shdescription descr ON (
(SELECT fdwacl FROM pg_catalog.pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (
fdw.oid=descr.objoid AND descr.classoid='pg_foreign_data_wrapper'::regclass)
{% if fid %}
WHERE fdw.oid = {{ fid|qtLiteral }}::OID
@ -16,7 +16,7 @@ FROM
) acl,
(SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable,
(d).privilege_type AS privilege_type
FROM (SELECT aclexplode(fdwacl) as d FROM pg_foreign_data_wrapper fdw1
FROM (SELECT pg_catalog.aclexplode(fdwacl) as d FROM pg_catalog.pg_foreign_data_wrapper fdw1
{% if fid %}
WHERE fdw1.oid = {{ fid|qtLiteral }}::OID ) a
{% endif %}

View File

@ -1,8 +1,8 @@
{# ============= Get foreign data wrapper from fid ============= #}
{% if fid %}
SELECT fdwname as name from pg_foreign_data_wrapper WHERE oid={{fid}}::oid;
SELECT fdwname as name from pg_catalog.pg_foreign_data_wrapper WHERE oid={{fid}}::oid;
{% endif %}
{# ============= Delete/Drop cascade foreign data wrapper ============= #}
{% if name %}
DROP FOREIGN DATA WRAPPER {{ conn|qtIdent(name) }} {% if cascade %} CASCADE {% endif %};
{% endif %}
{% endif %}

View File

@ -1,5 +1,5 @@
{# ============= Get the handlers of foreign data wrapper ============= #}
SELECT nspname, proname as fdwhan,
quote_ident(nspname)||'.'||quote_ident(proname) AS schema_prefix_fdw_hand
FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace
pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(proname) AS schema_prefix_fdw_hand
FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace nsp ON nsp.oid=pronamespace
WHERE pronargs=0 AND prorettype=3115;

View File

@ -1,22 +1,22 @@
{# ============= Get all the properties of foreign data wrapper ============= #}
SELECT fdw.oid, fdwname as name, fdwhandler, fdwvalidator, description,
array_to_string(fdwoptions, ',') AS fdwoptions, pg_get_userbyid(fdwowner) as fdwowner, array_to_string(fdwacl::text[], ', ') as acl,
pg_catalog.array_to_string(fdwoptions, ',') AS fdwoptions, pg_catalog.pg_get_userbyid(fdwowner) as fdwowner, pg_catalog.array_to_string(fdwacl::text[], ', ') as acl,
CASE
-- EPAS in redwood mode, concatenation of a string with NULL results as the original string
WHEN vp.proname IS NULL THEN NULL
ELSE quote_ident(vp_nsp.nspname)||'.'||quote_ident(vp.proname)
ELSE pg_catalog.quote_ident(vp_nsp.nspname)||'.'||pg_catalog.quote_ident(vp.proname)
END fdwvalue,
CASE
-- EPAS in redwood mode, concatenation of a string with NULL results as the original string
WHEN vh.proname IS NULL THEN NULL
ELSE quote_ident(vh_nsp.nspname)||'.'||quote_ident(vh.proname)
ELSE pg_catalog.quote_ident(vh_nsp.nspname)||'.'||pg_catalog.quote_ident(vh.proname)
END fdwhan
FROM pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_proc vh on vh.oid=fdwhandler
LEFT OUTER JOIN pg_proc vp on vp.oid=fdwvalidator
LEFT OUTER JOIN pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
LEFT OUTER JOIN pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
FROM pg_catalog.pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler
LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator
LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
{% if fid %}
WHERE fdw.oid={{fid}}::oid
{% endif %}

View File

@ -1,5 +1,5 @@
{# ============= Get the validators of foreign data wrapper ============= #}
SELECT nspname, proname as fdwvalue,
quote_ident(nspname)||'.'||quote_ident(proname) AS schema_prefix_fdw_val
FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace
pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(proname) AS schema_prefix_fdw_val
FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace nsp ON nsp.oid=pronamespace
WHERE proargtypes[0]=1009 AND proargtypes[1]=26;

View File

@ -1,5 +1,5 @@
SELECT 'lanacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor,
array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
@ -8,11 +8,11 @@ FROM
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT lanacl FROM pg_language lan
LEFT OUTER JOIN pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass)
(SELECT lanacl FROM pg_catalog.pg_language lan
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass)
WHERE lan.oid = {{ lid|qtLiteral }}::OID
) acl,
aclexplode(lanacl) d
pg_catalog.aclexplode(lanacl) d
) d
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)

View File

@ -1,5 +1,5 @@
SELECT 'lanacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor,
array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
@ -8,13 +8,13 @@ FROM
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT lanacl FROM pg_language lan
LEFT OUTER JOIN pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass)
(SELECT lanacl FROM pg_catalog.pg_language lan
LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass)
WHERE lan.oid = {{ lid|qtLiteral }}::OID
) acl,
(SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable,
(d).privilege_type AS privilege_type
FROM (SELECT aclexplode(lanacl) as d FROM pg_language lan1
FROM (SELECT pg_catalog.aclexplode(lanacl) as d FROM pg_catalog.pg_language lan1
WHERE lan1.oid = {{ lid|qtLiteral }}::OID ) a
) d
) d

View File

@ -1,6 +1,6 @@
{# ============= Get the language name using oid ============= #}
{% if lid %}
SELECT lanname FROM pg_language WHERE oid = {{lid}}::oid;
SELECT lanname FROM pg_catalog.pg_language WHERE oid = {{lid}}::oid;
{% endif %}
{# ============= Drop the language ============= #}
{% if lname %}

View File

@ -1,6 +1,6 @@
SELECT
CASE WHEN nspname != 'pg_catalog' THEN quote_ident(nspname) || '.' || quote_ident(proname)
ELSE quote_ident(proname)
CASE WHEN nspname != 'pg_catalog' THEN pg_catalog.quote_ident(nspname) || '.' || pg_catalog.quote_ident(proname)
ELSE pg_catalog.quote_ident(proname)
END AS label,
CASE
WHEN prorettype = 2280 THEN 'handler'
@ -8,8 +8,8 @@ SELECT
ELSE 'validator'
END AS prop_type
FROM
pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace
pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace nsp ON nsp.oid=pronamespace
WHERE
prorettype=2280 OR
(prorettype=2278 AND proargtypes[0]=26) OR
(prorettype=2278 AND proargtypes[0]=2281)
(prorettype=2278 AND proargtypes[0]=2281)

View File

@ -1,14 +1,14 @@
SELECT
lan.oid as oid, lanname as name, lanpltrusted as trusted,
array_to_string(lanacl::text[], ', ') as acl, hp.proname as lanproc,
pg_catalog.array_to_string(lanacl::text[], ', ') as acl, hp.proname as lanproc,
vp.proname as lanval, description,
pg_get_userbyid(lan.lanowner) as lanowner, ip.proname as laninl,
(SELECT array_agg(provider || '=' || label) FROM pg_seclabel sl1 WHERE sl1.objoid=lan.oid) AS seclabels
pg_catalog.pg_get_userbyid(lan.lanowner) as lanowner, ip.proname as laninl,
(SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabel sl1 WHERE sl1.objoid=lan.oid) AS seclabels
FROM
pg_language lan JOIN pg_proc hp ON hp.oid=lanplcallfoid
LEFT OUTER JOIN pg_proc ip ON ip.oid=laninline
LEFT OUTER JOIN pg_proc vp ON vp.oid=lanvalidator
LEFT OUTER JOIN pg_description des
pg_catalog.pg_language lan JOIN pg_catalog.pg_proc hp ON hp.oid=lanplcallfoid
LEFT OUTER JOIN pg_catalog.pg_proc ip ON ip.oid=laninline
LEFT OUTER JOIN pg_catalog.pg_proc vp ON vp.oid=lanvalidator
LEFT OUTER JOIN pg_catalog.pg_description des
ON (
des.objoid=lan.oid AND des.objsubid=0 AND
des.classoid='pg_language'::regclass

View File

@ -1,7 +1,7 @@
{# ============= SELECT Language templates ============= #}
SELECT
tmplname
FROM pg_pltemplate
LEFT JOIN pg_language ON tmplname=lanname
FROM pg_catalog.pg_pltemplate
LEFT JOIN pg_catalog.pg_language ON tmplname=lanname
WHERE lanname IS NULL
ORDER BY tmplname;
ORDER BY tmplname;

View File

@ -1,8 +1,8 @@
SELECT c.oid AS oid, c.pubname AS name,
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
puballtables AS all_table,
pga.rolname AS pubowner FROM pg_publication c
JOIN pg_roles pga ON c.pubowner= pga.oid
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
{% if pbid %}
WHERE c.oid = {{ pbid }}
{% endif %}

View File

@ -2,8 +2,8 @@ SELECT c.oid AS oid, c.pubname AS name,
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
puballtables AS all_table,
pubviaroot AS publish_via_partition_root,
pga.rolname AS pubowner FROM pg_publication c
JOIN pg_roles pga ON c.pubowner= pga.oid
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
{% if pbid %}
WHERE c.oid = {{ pbid }}
{% endif %}

View File

@ -1,6 +1,6 @@
{# ============= Get the publication name using oid ============= #}
{% if pbid %}
SELECT pubname FROM pg_publication WHERE oid = {{pbid}}::oid;
SELECT pubname FROM pg_catalog.pg_publication WHERE oid = {{pbid}}::oid;
{% endif %}
{# ============= Drop the publication ============= #}
{% if pname %}

View File

@ -1,5 +1,5 @@
SELECT cl.oid AS oid,
quote_ident(pgb_table.schemaname)||'.'||quote_ident(pgb_table.tablename) AS pubtable
FROM pg_publication_tables pgb_table
LEFT JOIN pg_class cl ON pgb_table.tablename = cl.relname
pg_catalog.quote_ident(pgb_table.schemaname)||'.'||pg_catalog.quote_ident(pgb_table.tablename) AS pubtable
FROM pg_catalog.pg_publication_tables pgb_table
LEFT JOIN pg_catalog.pg_class cl ON pgb_table.tablename = cl.relname
WHERE pubname = '{{ pname }}' AND pgb_table.schemaname NOT LIKE 'pgagent';

View File

@ -1,4 +1,4 @@
SELECT quote_ident(c.table_schema)||'.'||quote_ident(c.table_name) AS table
SELECT pg_catalog.quote_ident(c.table_schema)||'.'||pg_catalog.quote_ident(c.table_name) AS table
FROM information_schema.tables c
WHERE c.table_type = 'BASE TABLE'
AND c.table_schema NOT LIKE 'pg\_%'

View File

@ -1 +1 @@
SELECT oid, pubname AS name FROM pg_publication WHERE pubname = '{{ pubname }}';
SELECT oid, pubname AS name FROM pg_catalog.pg_publication WHERE pubname = '{{ pubname }}';

View File

@ -1,3 +1,3 @@
SELECT quote_ident(pgb_table.schemaname)||'.'||quote_ident(pgb_table.tablename)
AS pubtable FROM pg_publication_tables pgb_table WHERE pubname = '{{ pname }}'
SELECT pg_catalog.quote_ident(pgb_table.schemaname)||'.'||pg_catalog.quote_ident(pgb_table.tablename)
AS pubtable FROM pg_catalog.pg_publication_tables pgb_table WHERE pubname = '{{ pname }}'
AND pgb_table.schemaname NOT LIKE 'pgagent';

View File

@ -1 +1 @@
SELECT oid , pubname AS name FROM pg_publication;
SELECT oid , pubname AS name FROM pg_catalog.pg_publication;

View File

@ -1,8 +1,8 @@
SELECT c.oid AS oid, c.pubname AS name,
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete,
puballtables AS all_table,
pga.rolname AS pubowner FROM pg_publication c
JOIN pg_roles pga ON c.pubowner= pga.oid
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
{% if pbid %}
where c.oid = {{ pbid }}
{% endif %}

View File

@ -1,10 +1,10 @@
SELECT
ref.relname AS refname, d2.refclassid, dep.deptype AS deptype
FROM pg_depend dep
LEFT JOIN pg_depend d2 ON dep.objid=d2.objid AND dep.refobjid != d2.refobjid
LEFT JOIN pg_class ref ON ref.oid=d2.refobjid
LEFT JOIN pg_attribute att ON d2.refclassid=att.attrelid AND d2.refobjsubid=att.attnum
FROM pg_catalog.pg_depend dep
LEFT JOIN pg_catalog.pg_depend d2 ON dep.objid=d2.objid AND dep.refobjid != d2.refobjid
LEFT JOIN pg_catalog.pg_class ref ON ref.oid=d2.refobjid
LEFT JOIN pg_catalog.pg_attribute att ON d2.refclassid=att.attrelid AND d2.refobjsubid=att.attnum
{{ where }} AND
dep.classid=(SELECT oid FROM pg_class WHERE relname='pg_attrdef') AND
dep.refobjid NOT IN (SELECT d3.refobjid FROM pg_depend d3 WHERE d3.objid=d2.refobjid)
dep.classid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='pg_attrdef') AND
dep.refobjid NOT IN (SELECT d3.refobjid FROM pg_catalog.pg_depend d3 WHERE d3.objid=d2.refobjid)
ORDER BY refname;

View File

@ -1,6 +1,6 @@
SELECT
attnum, attname
FROM pg_attribute att
FROM pg_catalog.pg_attribute att
WHERE att.attrelid = {{coid}}::oid
AND att.attnum > 0
AND att.attisdropped IS FALSE

View File

@ -1,38 +1,38 @@
SELECT
att.*, def.*, pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval,
CASE WHEN att.attndims > 0 THEN 1 ELSE 0 END AS isarray,
format_type(ty.oid,NULL) AS typname,
format_type(ty.oid,att.atttypmod) AS displaytypname,
pg_catalog.format_type(ty.oid,NULL) AS typname,
pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname,
tn.nspname as typnspname, et.typname as elemtypname,
ty.typstorage AS defaultstorage, cl.relname, na.nspname,
att.attstattarget, description, cs.relname AS sername,
ns.nspname AS serschema,
(SELECT count(1) FROM pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup,
(SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup,
indkey, coll.collname, nspc.nspname as collnspname , attoptions,
-- Start pgAdmin4, added to save time on client side parsing
CASE WHEN length(coll.collname::text) > 0 AND length(nspc.nspname::text) > 0 THEN
concat(quote_ident(nspc.nspname),'.',quote_ident(coll.collname))
pg_catalog.concat(pg_catalog.quote_ident(nspc.nspname),'.',pg_catalog.quote_ident(coll.collname))
ELSE '' END AS collspcname,
CASE WHEN strpos(format_type(ty.oid,att.atttypmod), '.') > 0 THEN
split_part(format_type(ty.oid,att.atttypmod), '.', 2)
ELSE format_type(ty.oid,att.atttypmod) END AS cltype,
CASE WHEN strpos(pg_catalog.format_type(ty.oid,att.atttypmod), '.') > 0 THEN
pg_catalog.split_part(format_type(ty.oid,att.atttypmod), '.', 2)
ELSE pg_catalog.format_type(ty.oid,att.atttypmod) END AS cltype,
-- End pgAdmin4
EXISTS(SELECT 1 FROM pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As isfk,
(SELECT array_agg(label) FROM pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS labels,
(SELECT array_agg(provider) FROM pg_seclabels sl2 WHERE sl2.objoid=att.attrelid AND sl2.objsubid=att.attnum) AS providers
FROM pg_attribute att
JOIN pg_type ty ON ty.oid=atttypid
JOIN pg_namespace tn ON tn.oid=ty.typnamespace
JOIN pg_class cl ON cl.oid=att.attrelid
JOIN pg_namespace na ON na.oid=cl.relnamespace
LEFT OUTER JOIN pg_type et ON et.oid=ty.typelem
LEFT OUTER JOIN pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
LEFT OUTER JOIN pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass)
LEFT OUTER JOIN (pg_depend JOIN pg_class cs ON objid=cs.oid AND classid='pg_class'::regclass AND cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum
LEFT OUTER JOIN pg_namespace ns ON ns.oid=cs.relnamespace
LEFT OUTER JOIN pg_index pi ON pi.indrelid=att.attrelid AND indisprimary
LEFT OUTER JOIN pg_collation coll ON att.attcollation=coll.oid
LEFT OUTER JOIN pg_namespace nspc ON coll.collnamespace=nspc.oid
EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As isfk,
(SELECT pg_catalog.array_agg(label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS labels,
(SELECT pg_catalog.array_agg(provider) FROM pg_catalog.pg_seclabels sl2 WHERE sl2.objoid=att.attrelid AND sl2.objsubid=att.attnum) AS providers
FROM pg_catalog.pg_attribute att
JOIN pg_catalog.pg_type ty ON ty.oid=atttypid
JOIN pg_catalog.pg_namespace tn ON tn.oid=ty.typnamespace
JOIN pg_catalog.pg_class cl ON cl.oid=att.attrelid
JOIN pg_catalog.pg_namespace na ON na.oid=cl.relnamespace
LEFT OUTER JOIN pg_catalog.pg_type et ON et.oid=ty.typelem
LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass)
LEFT OUTER JOIN (pg_catalog.pg_depend JOIN pg_catalog.pg_class cs ON objid=cs.oid AND classid='pg_class'::regclass AND cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum
LEFT OUTER JOIN pg_catalog.pg_namespace ns ON ns.oid=cs.relnamespace
LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary
LEFT OUTER JOIN pg_catalog.pg_collation coll ON att.attcollation=coll.oid
LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid
WHERE att.attrelid = {{coid}}::oid{% if clid %}
AND att.attnum = {{clid}}::int
{% endif %}

View File

@ -1,7 +1,7 @@
SELECT
c.oid, c.relname as name
FROM
pg_class c
pg_catalog.pg_class c
{% if scid %}
WHERE relnamespace = {{scid}}::oid
{% elif coid %}

View File

@ -1,10 +1,10 @@
SELECT
c.oid, c.relname as name, r.rolname AS owner, description
FROM
pg_class c
LEFT OUTER JOIN pg_description d
pg_catalog.pg_class c
LEFT OUTER JOIN pg_catalog.pg_description d
ON d.objoid=c.oid AND d.classoid='pg_class'::regclass
LEFT JOIN pg_roles r ON c.relowner = r.oid
LEFT JOIN pg_catalog.pg_roles r ON c.relowner = r.oid
WHERE
relnamespace = {{scid}}::oid
{% if coid %} AND

View File

@ -1,11 +1,11 @@
SELECT
c.oid, c.relname as name
FROM pg_class c
FROM pg_catalog.pg_class c
{% if scid %}
WHERE relnamespace = {{scid}}::oid
OR (
-- On EnterpriseDB we need to ignore some objects in the catalog, namely, _*, dual and type_object_source.
select 'sys' ~ (SELECT nsp.nspname FROM pg_namespace nsp WHERE nsp.oid = {{scid}}::oid)
select 'sys' ~ (SELECT nsp.nspname FROM pg_catalog.pg_namespace nsp WHERE nsp.oid = {{scid}}::oid)
AND
(c.relname NOT LIKE '\\_%' AND c.relname = 'dual' AND c.relname = 'type_object_source')
)

View File

@ -1,10 +1,10 @@
SELECT
c.oid, c.relname as name, r.rolname AS owner, description
FROM
pg_class c
LEFT OUTER JOIN pg_description d
pg_catalog.pg_class c
LEFT OUTER JOIN pg_catalog.pg_description d
ON d.objoid=c.oid AND d.classoid='pg_class'::regclass
LEFT JOIN pg_roles r ON c.relowner = r.oid
LEFT JOIN pg_catalog.pg_roles r ON c.relowner = r.oid
WHERE
relnamespace = {{scid}}::oid
{% if coid %} AND

View File

@ -1,18 +1,18 @@
SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_namespace nsp
FROM pg_catalog.pg_namespace nsp
WHERE nsp.oid={{scid}}::oid
AND (
(nspname = 'pg_catalog' AND EXISTS
(SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1))
(SELECT 1 FROM pg_catalog.pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1))
OR (nspname = 'pgagent' AND EXISTS
(SELECT 1 FROM pg_class WHERE relname = 'pga_job' AND relnamespace = nsp.oid LIMIT 1))
(SELECT 1 FROM pg_catalog.pg_class WHERE relname = 'pga_job' AND relnamespace = nsp.oid LIMIT 1))
OR (nspname = 'information_schema' AND EXISTS
(SELECT 1 FROM pg_class WHERE relname = 'tables' AND relnamespace = nsp.oid LIMIT 1))
(SELECT 1 FROM pg_catalog.pg_class WHERE relname = 'tables' AND relnamespace = nsp.oid LIMIT 1))
OR (nspname LIKE '_%' AND EXISTS
(SELECT 1 FROM pg_proc WHERE proname='slonyversion' AND pronamespace = nsp.oid LIMIT 1))
(SELECT 1 FROM pg_catalog.pg_proc WHERE proname='slonyversion' AND pronamespace = nsp.oid LIMIT 1))
)
AND
nspname NOT LIKE E'pg\\temp\\%'
AND
nspname NOT LIKE E'pg\\toast_temp\\%'
nspname NOT LIKE E'pg\\toast_temp\\%'

View File

@ -1,7 +1,7 @@
SELECT --nspname, collname,
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
concat(quote_ident(nspname), '.', quote_ident(collname))
pg_catalog.concat(pg_catalog.quote_ident(nspname), '.', pg_catalog.quote_ident(collname))
ELSE '' END AS copy_collation
FROM pg_collation c, pg_namespace n
FROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n
WHERE c.collnamespace=n.oid
ORDER BY nspname, collname;

View File

@ -1,5 +1,5 @@
SELECT nspname AS schema, collname AS name
FROM pg_collation c, pg_namespace n
FROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n
WHERE c.collnamespace = n.oid AND
n.oid = {{ scid }}::oid AND
c.oid = {{ coid }}::oid;

View File

@ -1,7 +1,7 @@
{# Below will provide oid for newly created collation #}
{% if data is defined %}
SELECT c.oid
FROM pg_collation c, pg_namespace n
FROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n
WHERE c.collnamespace=n.oid AND
n.nspname = {{ data.schema|qtLiteral }} AND
c.collname = {{ data.name|qtLiteral }}
@ -9,7 +9,7 @@ WHERE c.collnamespace=n.oid AND
SELECT
c.collnamespace as scid
FROM
pg_collation c
pg_catalog.pg_collation c
WHERE
c.oid = {{coid}}::oid;
{% endif %}

View File

@ -1,5 +1,5 @@
SELECT c.oid, c.collname AS name
FROM pg_collation c
FROM pg_catalog.pg_collation c
{% if scid %}
WHERE c.collnamespace = {{scid}}::oid
{% elif coid %}

View File

@ -1,8 +1,8 @@
SELECT c.oid, c.collname AS name, c.collcollate AS lc_collate, c.collctype AS lc_type,
pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
FROM pg_collation c
JOIN pg_namespace n ON n.oid=c.collnamespace
LEFT OUTER JOIN pg_description des ON (des.objoid=c.oid AND des.classoid='pg_collation'::regclass)
pg_catalog.pg_get_userbyid(c.collowner) AS owner, description, n.nspname AS schema
FROM pg_catalog.pg_collation c
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_collation'::regclass)
WHERE c.collnamespace = {{scid}}::oid
{% if coid %} AND c.oid = {{coid}}::oid {% endif %}
ORDER BY c.collname;

View File

@ -1,5 +1,5 @@
SELECT
typcategory
FROM
pg_type
pg_catalog.pg_type
WHERE typname = {{datatype}};

View File

@ -1,15 +1,15 @@
SELECT
c.oid, conname AS name, typname AS relname, nspname, description,
regexp_replace(pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') AS consrc,
pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') AS consrc,
connoinherit, convalidated, convalidated AS convalidated_p
FROM
pg_constraint c
pg_catalog.pg_constraint c
JOIN
pg_type t ON t.oid=contypid
pg_catalog.pg_type t ON t.oid=contypid
JOIN
pg_namespace nl ON nl.oid=typnamespace
pg_catalog.pg_namespace nl ON nl.oid=typnamespace
LEFT OUTER JOIN
pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
{% if doid %}
WHERE
contype = 'c' AND contypid = {{doid}}::oid

View File

@ -1,8 +1,8 @@
SELECT
d.typname as domain, bn.nspname as schema
FROM
pg_type d
pg_catalog.pg_type d
JOIN
pg_namespace bn ON bn.oid=d.typnamespace
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
WHERE
d.oid = {{doid}};

View File

@ -1,7 +1,7 @@
SELECT
oid, conname as name
FROM
pg_constraint
pg_catalog.pg_constraint
WHERE
contypid = {{doid}}::oid
AND conname={{ name|qtLiteral }};

View File

@ -1,12 +1,12 @@
SELECT
c.oid, conname AS name, typname AS relname, nspname,
regexp_replace(pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') AS consrc
pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') AS consrc
FROM
pg_constraint c
pg_catalog.pg_constraint c
JOIN
pg_type t ON t.oid=contypid
pg_catalog.pg_type t ON t.oid=contypid
JOIN
pg_namespace nl ON nl.oid=typnamespace
pg_catalog.pg_namespace nl ON nl.oid=typnamespace
{% if doid %}
WHERE
contype = 'c' AND contypid = {{doid}}::oid

View File

@ -1,9 +1,9 @@
SELECT --nspname, collname,
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
concat(nspname, '."', collname,'"')
pg_catalog.concat(nspname, '."', collname,'"')
ELSE '' END AS copy_collation
FROM
pg_collation c, pg_namespace n
pg_catalog.pg_collation c, pg_catalog.pg_namespace n
WHERE
c.collnamespace=n.oid
ORDER BY

View File

@ -1,14 +1,14 @@
SELECT
'DOMAIN' AS objectkind, c.oid as conoid, conname, typname as relname, nspname, description,
regexp_replace(pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as consrc, connoinherit, convalidated
pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as consrc, connoinherit, convalidated
FROM
pg_constraint c
pg_catalog.pg_constraint c
JOIN
pg_type t ON t.oid=contypid
pg_catalog.pg_type t ON t.oid=contypid
JOIN
pg_namespace nl ON nl.oid=typnamespace
pg_catalog.pg_namespace nl ON nl.oid=typnamespace
LEFT OUTER JOIN
pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
WHERE
contype = 'c' AND contypid = {{doid}}::oid
ORDER BY

View File

@ -1,12 +1,12 @@
SELECT
d.oid, d.typname as name, pg_get_userbyid(d.typowner) as owner,
d.oid, d.typname as name, pg_catalog.pg_get_userbyid(d.typowner) as owner,
bn.nspname as basensp
FROM
pg_type d
pg_catalog.pg_type d
JOIN
pg_type b ON b.oid = d.typbasetype
pg_catalog.pg_type b ON b.oid = d.typbasetype
JOIN
pg_namespace bn ON bn.oid=d.typnamespace
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
{% if scid is defined %}
WHERE
d.typnamespace = {{scid}}::oid

View File

@ -1,30 +1,30 @@
SELECT
d.oid, d.typname as name, d.typbasetype, format_type(b.oid,NULL) as basetype, pg_get_userbyid(d.typowner) as owner,
c.oid AS colloid, format_type(b.oid, d.typtypmod) AS fulltype,
d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype, pg_catalog.pg_get_userbyid(d.typowner) as owner,
c.oid AS colloid, pg_catalog.format_type(b.oid, d.typtypmod) AS fulltype,
CASE WHEN length(cn.nspname::text) > 0 AND length(c.collname::text) > 0 THEN
concat(cn.nspname, '."', c.collname,'"')
pg_catalog.concat(cn.nspname, '."', c.collname,'"')
ELSE '' END AS collname,
d.typtypmod, d.typnotnull, d.typdefault, d.typndims, d.typdelim, bn.nspname as basensp,
description, (SELECT COUNT(1) FROM pg_type t2 WHERE t2.typname=d.typname) > 1 AS domisdup,
(SELECT COUNT(1) FROM pg_type t3 WHERE t3.typname=b.typname) > 1 AS baseisdup,
description, (SELECT COUNT(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=d.typname) > 1 AS domisdup,
(SELECT COUNT(1) FROM pg_catalog.pg_type t3 WHERE t3.typname=b.typname) > 1 AS baseisdup,
(SELECT
array_agg(provider || '=' || label)
pg_catalog.array_agg(provider || '=' || label)
FROM
pg_seclabel sl1
pg_catalog.pg_seclabel sl1
WHERE
sl1.objoid=d.oid) AS seclabels
FROM
pg_type d
pg_catalog.pg_type d
JOIN
pg_type b ON b.oid = d.typbasetype
pg_catalog.pg_type b ON b.oid = d.typbasetype
JOIN
pg_namespace bn ON bn.oid=d.typnamespace
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
LEFT OUTER JOIN
pg_description des ON (des.objoid=d.oid AND des.classoid='pg_type'::regclass)
pg_catalog.pg_description des ON (des.objoid=d.oid AND des.classoid='pg_type'::regclass)
LEFT OUTER JOIN
pg_collation c ON d.typcollation=c.oid
pg_catalog.pg_collation c ON d.typcollation=c.oid
LEFT OUTER JOIN
pg_namespace cn ON c.collnamespace=cn.oid
pg_catalog.pg_namespace cn ON c.collnamespace=cn.oid
WHERE
d.typnamespace = {{scid}}::oid
{% if doid %}

View File

@ -2,9 +2,9 @@
SELECT
d.typname as name, bn.nspname as basensp
FROM
pg_type d
pg_catalog.pg_type d
JOIN
pg_namespace bn ON bn.oid=d.typnamespace
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
WHERE
d.typnamespace = {{scid}}::oid
AND

View File

@ -1,9 +1,9 @@
SELECT --nspname, collname,
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
concat(nspname, '."', collname,'"')
pg_catalog.concat(nspname, '."', collname,'"')
ELSE '' END AS copy_collation
FROM
pg_collation c, pg_namespace n
pg_catalog.pg_collation c, pg_catalog.pg_namespace n
WHERE
c.collnamespace=n.oid
ORDER BY

View File

@ -1,14 +1,14 @@
SELECT
'DOMAIN' AS objectkind, c.oid as conoid, conname, typname as relname, nspname, description,
regexp_replace(pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as cons
pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as cons
FROM
pg_constraint c
pg_catalog.pg_constraint c
JOIN
pg_type t ON t.oid=contypid
pg_catalog.pg_type t ON t.oid=contypid
JOIN
pg_namespace nl ON nl.oid=typnamespace
pg_catalog.pg_namespace nl ON nl.oid=typnamespace
LEFT OUTER JOIN
pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass)
WHERE
contype = 'c'
AND contypid = {{doid}}::oid

View File

@ -2,16 +2,16 @@
SELECT
d.typnamespace as scid
FROM
pg_type d
pg_catalog.pg_type d
WHERE
d.oid={{ doid }}::oid;
{% else %}
SELECT
d.oid
FROM
pg_type d
pg_catalog.pg_type d
JOIN
pg_namespace bn ON bn.oid=d.typnamespace
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
WHERE
bn.nspname = {{ basensp|qtLiteral }}
AND d.typname={{ name|qtLiteral }};

View File

@ -1,12 +1,12 @@
SELECT
d.oid, d.typname as name, pg_get_userbyid(d.typowner) as owner,
d.oid, d.typname as name, pg_catalog.pg_get_userbyid(d.typowner) as owner,
bn.nspname as basensp
FROM
pg_type d
pg_catalog.pg_type d
JOIN
pg_type b ON b.oid = d.typbasetype
pg_catalog.pg_type b ON b.oid = d.typbasetype
JOIN
pg_namespace bn ON bn.oid=d.typnamespace
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
{% if scid %}
WHERE
d.typnamespace = {{scid}}::oid

View File

@ -1,31 +1,31 @@
SELECT
d.oid, d.typname as name, d.typbasetype, format_type(b.oid,NULL) as basetype,
pg_get_userbyid(d.typowner) as owner,
c.oid AS colloid, format_type(b.oid, d.typtypmod) AS fulltype,
d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype,
pg_catalog.pg_get_userbyid(d.typowner) as owner,
c.oid AS colloid, pg_catalog.format_type(b.oid, d.typtypmod) AS fulltype,
CASE WHEN length(cn.nspname::text) > 0 AND length(c.collname::text) > 0 THEN
concat(cn.nspname, '."', c.collname,'"')
pg_catalog.concat(cn.nspname, '."', c.collname,'"')
ELSE '' END AS collname,
d.typtypmod, d.typnotnull, d.typdefault, d.typndims, d.typdelim, bn.nspname as basensp,
description, (SELECT COUNT(1) FROM pg_type t2 WHERE t2.typname=d.typname) > 1 AS domisdup,
(SELECT COUNT(1) FROM pg_type t3 WHERE t3.typname=b.typname) > 1 AS baseisdup,
description, (SELECT COUNT(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=d.typname) > 1 AS domisdup,
(SELECT COUNT(1) FROM pg_catalog.pg_type t3 WHERE t3.typname=b.typname) > 1 AS baseisdup,
(SELECT
array_agg(provider || '=' || label)
pg_catalog.array_agg(provider || '=' || label)
FROM
pg_seclabel sl1
pg_catalog.pg_seclabel sl1
WHERE
sl1.objoid=d.oid) AS seclabels
FROM
pg_type d
pg_catalog.pg_type d
JOIN
pg_type b ON b.oid = d.typbasetype
pg_catalog.pg_type b ON b.oid = d.typbasetype
JOIN
pg_namespace bn ON bn.oid=d.typnamespace
pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace
LEFT OUTER JOIN
pg_description des ON (des.objoid=d.oid AND des.classoid='pg_type'::regclass)
pg_catalog.pg_description des ON (des.objoid=d.oid AND des.classoid='pg_type'::regclass)
LEFT OUTER JOIN
pg_collation c ON d.typcollation=c.oid
pg_catalog.pg_collation c ON d.typcollation=c.oid
LEFT OUTER JOIN
pg_namespace cn ON c.collnamespace=cn.oid
pg_catalog.pg_namespace cn ON c.collnamespace=cn.oid
WHERE
d.typnamespace = {{scid}}::oid
{% if doid %}

View File

@ -1,9 +1,9 @@
SELECT
oid as conoid, conname, contype,
BTRIM(substring(pg_get_constraintdef(oid, true) from '\(.+\)'), '()') as consrc,
pg_catalog.BTRIM(substring(pg_catalog.pg_get_constraintdef(oid, true) from '\(.+\)'), '()') as consrc,
connoinherit, convalidated, conislocal
FROM
pg_constraint
pg_catalog.pg_constraint
WHERE
conrelid={{foid}}::oid
ORDER by conname;

View File

@ -1,7 +1,7 @@
SELECT
COALESCE(gt.rolname, 'PUBLIC') AS grantee,
g.rolname AS grantor, array_agg(privilege_type) AS privileges,
array_agg(is_grantable) AS grantable
g.rolname AS grantor, pg_catalog.array_agg(privilege_type) AS privileges,
pg_catalog.array_agg(is_grantable) AS grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
@ -26,7 +26,7 @@ FROM
(d).is_grantable AS is_grantable,
(d).privilege_type AS privilege_type
FROM
(SELECT aclexplode(db.relacl) AS d FROM pg_class db
(SELECT pg_catalog.aclexplode(db.relacl) AS d FROM pg_catalog.pg_class db
WHERE db.oid = {{foid}}::OID) a ORDER BY privilege_type
) d
) d

View File

@ -2,9 +2,9 @@
SELECT
c.relname AS name, nspname as basensp
FROM
pg_class c
pg_catalog.pg_class c
LEFT OUTER JOIN
pg_namespace nsp ON (nsp.oid=c.relnamespace)
pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace)
WHERE
c.relnamespace = {{scid}}::oid
AND

View File

@ -1,9 +1,9 @@
SELECT --nspname, collname,
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
concat(nspname, '."', collname,'"')
pg_catalog.concat(nspname, '."', collname,'"')
ELSE '' END AS copy_collation
FROM
pg_collation c, pg_namespace n
pg_catalog.pg_collation c, pg_catalog.pg_namespace n
WHERE
c.collnamespace=n.oid
ORDER BY nspname, collname;

View File

@ -1,24 +1,24 @@
SELECT
attname, attndims, atttypmod, attoptions, attfdwoptions, format_type(t.oid,NULL) AS datatype,
attname, attndims, atttypmod, attoptions, attfdwoptions, pg_catalog.format_type(t.oid,NULL) AS datatype,
attnotnull, attstattarget, attnum, format_type(t.oid, att.atttypmod) AS fulltype,
CASE WHEN length(cn.nspname::text) > 0 AND length(cl.collname::text) > 0 THEN
concat(cn.nspname, '."', cl.collname,'"') ELSE '' END AS collname,
(SELECT COUNT(1) from pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup,
(SELECT COUNT(1) from pg_catalog.pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup,
pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS typdefault
FROM
pg_attribute att
pg_catalog.pg_attribute att
JOIN
pg_type t ON t.oid=atttypid
pg_catalog.pg_type t ON t.oid=atttypid
JOIN
pg_namespace nsp ON t.typnamespace=nsp.oid
pg_catalog.pg_namespace nsp ON t.typnamespace=nsp.oid
LEFT OUTER JOIN
pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
LEFT OUTER JOIN
pg_type b ON t.typelem=b.oid
pg_catalog.pg_type b ON t.typelem=b.oid
LEFT OUTER JOIN
pg_collation cl ON att.attcollation=cl.oid
pg_catalog.pg_collation cl ON att.attcollation=cl.oid
LEFT OUTER JOIN
pg_namespace cn ON cl.collnamespace=cn.oid
pg_catalog.pg_namespace cn ON cl.collnamespace=cn.oid
WHERE
att.attrelid={{foid}}::oid
AND attnum>0

View File

@ -1,7 +1,7 @@
SELECT
conname, contype, consrc, conislocal
FROM
pg_constraint
pg_catalog.pg_constraint
WHERE
conrelid={{foid}}::oid
ORDER by conname;

View File

@ -1,6 +1,6 @@
SELECT
srvname
FROM
pg_foreign_server
pg_catalog.pg_foreign_server
ORDER BY
srvname;

View File

@ -1,24 +1,24 @@
SELECT
c.oid, c.relname AS name, c.relacl, pg_get_userbyid(relowner) AS owner,
c.oid, c.relname AS name, c.relacl, pg_catalog.pg_get_userbyid(relowner) AS owner,
ftoptions, srvname AS ftsrvname, description, nspname as basensp, consrc,
(SELECT
array_agg(provider || '=' || label)
pg_catalog.array_agg(provider || '=' || label)
FROM
pg_seclabel sl1
pg_catalog.pg_seclabel sl1
WHERE
sl1.objoid=c.oid) AS seclabels
FROM
pg_class c
pg_catalog.pg_class c
JOIN
pg_foreign_table ft ON c.oid=ft.ftrelid
pg_catalog.pg_foreign_table ft ON c.oid=ft.ftrelid
LEFT OUTER JOIN
pg_foreign_server fs ON ft.ftserver=fs.oid
pg_catalog.pg_foreign_server fs ON ft.ftserver=fs.oid
LEFT OUTER JOIN
pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
LEFT OUTER JOIN
pg_namespace nsp ON (nsp.oid=c.relnamespace)
pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace)
LEFT OUTER JOIN
pg_constraint cn ON (cn.conrelid=c.oid)
pg_catalog.pg_constraint cn ON (cn.conrelid=c.oid)
WHERE
c.relnamespace = {{scid}}::oid
{% if foid %}

View File

@ -1,42 +1,42 @@
WITH INH_TABLES AS
(SELECT
distinct on (at.attname) attname, ph.inhparent AS inheritedid, ph.inhseqno,
concat(nmsp_parent.nspname, '.',parent.relname ) AS inheritedfrom
pg_catalog.concat(nmsp_parent.nspname, '.',parent.relname ) AS inheritedfrom
FROM
pg_attribute at
pg_catalog.pg_attribute at
JOIN
pg_inherits ph ON ph.inhparent = at.attrelid AND ph.inhrelid = {{foid}}::oid
pg_catalog.pg_inherits ph ON ph.inhparent = at.attrelid AND ph.inhrelid = {{foid}}::oid
JOIN
pg_class parent ON ph.inhparent = parent.oid
pg_catalog.pg_class parent ON ph.inhparent = parent.oid
JOIN
pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
pg_catalog.pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace
GROUP BY at.attname, ph.inhparent, ph.inhseqno, inheritedfrom
ORDER BY at.attname, ph.inhparent, ph.inhseqno, inheritedfrom
)
SELECT INH.inheritedfrom, INH.inheritedid, att.attoptions, attfdwoptions,
att.attname, att.attndims, att.atttypmod, format_type(t.oid,NULL) AS datatype,
att.attnotnull, att.attstattarget, att.attnum, format_type(t.oid, att.atttypmod) AS fulltype,
att.attname, att.attndims, att.atttypmod, pg_catalog.format_type(t.oid,NULL) AS datatype,
att.attnotnull, att.attstattarget, att.attnum, pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype,
CASE WHEN length(cn.nspname::text) > 0 AND length(cl.collname::text) > 0 THEN
concat(cn.nspname, '."', cl.collname,'"')
pg_catalog.concat(cn.nspname, '."', cl.collname,'"')
ELSE '' END AS collname,
pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS typdefault,
(SELECT COUNT(1) from pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup
FROM
pg_attribute att
pg_catalog.pg_attribute att
LEFT JOIN
INH_TABLES as INH ON att.attname = INH.attname
JOIN
pg_type t ON t.oid=atttypid
pg_catalog.pg_type t ON t.oid=atttypid
JOIN
pg_namespace nsp ON t.typnamespace=nsp.oid
pg_catalog.pg_namespace nsp ON t.typnamespace=nsp.oid
LEFT OUTER JOIN
pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
LEFT OUTER JOIN
pg_type b ON t.typelem=b.oid
pg_catalog.pg_type b ON t.typelem=b.oid
LEFT OUTER JOIN
pg_collation cl ON att.attcollation=cl.oid
pg_catalog.pg_collation cl ON att.attcollation=cl.oid
LEFT OUTER JOIN
pg_namespace cn ON cl.collnamespace=cn.oid
pg_catalog.pg_namespace cn ON cl.collnamespace=cn.oid
WHERE
att.attrelid={{foid}}::oid
AND att.attnum>0

View File

@ -1,7 +1,7 @@
SELECT
oid as conoid, conname, contype, consrc, connoinherit, convalidated, conislocal
FROM
pg_constraint
pg_catalog.pg_constraint
WHERE
conrelid={{foid}}::oid
ORDER by conname;

View File

@ -1,6 +1,6 @@
SELECT
srvname
FROM
pg_foreign_server
pg_catalog.pg_foreign_server
ORDER
BY srvname;

View File

@ -1,14 +1,14 @@
{% if attrelid %}
SELECT
a.attname, format_type(a.atttypid, NULL) AS datatype,
a.attname, pg_catalog.format_type(a.atttypid, NULL) AS datatype,
quote_ident(n.nspname)||'.'||quote_ident(c.relname) as inheritedfrom,
c.oid as inheritedid
FROM
pg_class c
pg_catalog.pg_class c
JOIN
pg_namespace n ON c.relnamespace=n.oid
pg_catalog.pg_namespace n ON c.relnamespace=n.oid
JOIN
pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped AND a.attnum>0
pg_catalog.pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped AND a.attnum>0
WHERE
c.oid = {{attrelid}}::OID
{% endif %}

View File

@ -1,9 +1,9 @@
{% 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
pg_catalog.array_agg(quote_ident(n.nspname) || '.' || quote_ident(c.relname)) as inherits
FROM
pg_class c, pg_namespace n
pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE
c.relnamespace=n.oid AND c.relkind IN ('r', 'f')
AND c.oid in {{attrelid}};
@ -12,7 +12,7 @@ WHERE
SELECT
c.oid AS value, quote_ident(n.nspname) || '.' || quote_ident(c.relname) as label
FROM
pg_class c, pg_namespace n
pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE
c.relnamespace=n.oid AND c.relkind IN ('r', 'f')
{% if not show_system_objects %}

View File

@ -1,10 +1,10 @@
SELECT
c.oid, c.relname AS name, c.relacl, pg_get_userbyid(relowner) AS owner,
c.oid, c.relname AS name, c.relacl, pg_catalog.pg_get_userbyid(relowner) AS owner,
ftoptions, srvname AS ftsrvname, description, nspname AS basensp,
(SELECT
array_agg(provider || '=' || label)
FROM
pg_seclabel sl1
pg_catalog.pg_seclabel sl1
WHERE
sl1.objoid=c.oid) AS seclabels
{% if foid %},
@ -14,15 +14,15 @@ SELECT
i.inhrelid = {{foid}}::oid GROUP BY i.inhrelid) AS inherits
{% endif %}
FROM
pg_class c
pg_catalog.pg_class c
JOIN
pg_foreign_table ft ON c.oid=ft.ftrelid
pg_catalog.pg_foreign_table ft ON c.oid=ft.ftrelid
LEFT OUTER JOIN
pg_foreign_server fs ON ft.ftserver=fs.oid
pg_catalog.pg_foreign_server fs ON ft.ftserver=fs.oid
LEFT OUTER JOIN
pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
LEFT OUTER JOIN
pg_namespace nsp ON (nsp.oid=c.relnamespace)
pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace)
WHERE
c.relnamespace = {{scid}}::oid
{% if foid %}

View File

@ -2,9 +2,9 @@
SELECT
c.relname AS name, nspname as basensp
FROM
pg_class c
pg_catalog.pg_class c
LEFT OUTER JOIN
pg_namespace nsp ON (nsp.oid=c.relnamespace)
pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace)
WHERE
c.relnamespace = {{scid}}::oid
AND c.oid = {{foid}}::oid;

View File

@ -1,9 +1,9 @@
SELECT --nspname, collname,
CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN
concat(nspname, '."', collname,'"')
pg_catalog.concat(nspname, '."', collname,'"')
ELSE '' END AS copy_collation
FROM
pg_collation c, pg_namespace n
pg_catalog.pg_collation c, pg_namespace n
WHERE
c.collnamespace=n.oid
ORDER BY

View File

@ -1,15 +1,15 @@
SELECT
attname, attndims, atttypmod, format_type(t.oid,NULL) AS datatype,
format_type(t.oid, att.atttypmod) AS fulltype, attnotnull, attnum,
(SELECT COUNT(1) from pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup
attname, attndims, atttypmod, pg_catalog.format_type(t.oid,NULL) AS datatype,
pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype, attnotnull, attnum,
(SELECT COUNT(1) from pg_catalog.pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup
FROM
pg_attribute att
pg_catalog.pg_attribute att
JOIN
pg_type t ON t.oid=atttypid
pg_catalog.pg_type t ON t.oid=atttypid
JOIN
pg_namespace nsp ON t.typnamespace=nsp.oid
pg_catalog.pg_namespace nsp ON t.typnamespace=nsp.oid
LEFT OUTER JOIN
pg_type b ON t.typelem=b.oid
pg_catalog.pg_type b ON t.typelem=b.oid
WHERE
att.attrelid={{foid}}::oid
AND attnum>0

View File

@ -1,7 +1,7 @@
SELECT
conname, contype, consrc
FROM
pg_constraint
pg_catalog.pg_constraint
WHERE
conrelid={{foid}}::oid
ORDER by conname;

View File

@ -1,5 +1,5 @@
SELECT
srvname
FROM
pg_foreign_server
pg_catalog.pg_foreign_server
ORDER BY srvname;

View File

@ -2,9 +2,9 @@
SELECT
c.oid, bn.oid as scid
FROM
pg_class c
pg_catalog.pg_class c
JOIN
pg_namespace bn ON bn.oid=c.relnamespace
pg_catalog.pg_namespace bn ON bn.oid=c.relnamespace
WHERE
bn.nspname = {{ basensp|qtLiteral }}
AND c.relname={{ name|qtLiteral }};
@ -13,7 +13,7 @@ WHERE
SELECT
c.relnamespace as scid
FROM
pg_class c
pg_catalog.pg_class c
WHERE
c.oid = {{foid}}::oid;
{% endif %}

View File

@ -1,14 +1,14 @@
SELECT
c.oid, c.relname AS name, pg_get_userbyid(relowner) AS owner,
c.oid, c.relname AS name, pg_catalog.pg_get_userbyid(relowner) AS owner,
ftoptions, nspname as basensp, description
FROM
pg_class c
pg_catalog.pg_class c
JOIN
pg_foreign_table ft ON c.oid=ft.ftrelid
pg_catalog.pg_foreign_table ft ON c.oid=ft.ftrelid
LEFT OUTER JOIN
pg_namespace nsp ON (nsp.oid=c.relnamespace)
pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace)
LEFT OUTER JOIN
pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
WHERE
{% if scid %}
c.relnamespace = {{scid}}::oid

View File

@ -1,22 +1,22 @@
SELECT
c.oid, c.relname AS name, pg_get_userbyid(relowner) AS owner,
c.oid, c.relname AS name, pg_catalog.pg_get_userbyid(relowner) AS owner,
ftoptions, srvname AS ftsrvname, description, nspname as basensp,
(SELECT
array_agg(provider || '=' || label)
pg_catalog.array_agg(provider || '=' || label)
FROM
pg_seclabel sl1
pg_catalog.pg_seclabel sl1
WHERE
sl1.objoid=c.oid) AS seclabels
FROM
pg_class c
pg_catalog.pg_class c
JOIN
pg_foreign_table ft ON c.oid=ft.ftrelid
pg_catalog.pg_foreign_table ft ON c.oid=ft.ftrelid
LEFT OUTER JOIN
pg_foreign_server fs ON ft.ftserver=fs.oid
pg_catalog.pg_foreign_server fs ON ft.ftserver=fs.oid
LEFT OUTER JOIN
pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass)
LEFT OUTER JOIN
pg_namespace nsp ON (nsp.oid=c.relnamespace)
pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace)
WHERE
c.relnamespace = {{scid}}::oid
{% if foid %}

View File

@ -1,14 +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
SELECT 1 FROM pg_catalog.pg_class
WHERE relnamespace=typnamespace
AND relname = typname AND relkind != 'c')
AND (typname NOT LIKE '_%' OR NOT EXISTS (
SELECT 1 FROM pg_class
SELECT 1 FROM pg_catalog.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 %}
{% endif %}

View File

@ -6,10 +6,10 @@ SELECT
nspname,
n.oid as schemaoid
FROM
pg_ts_config cfg
JOIN pg_namespace n
pg_catalog.pg_ts_config cfg
JOIN pg_catalog.pg_namespace n
ON n.oid=cfgnamespace
ORDER BY
nspname,
cfgname
{% endif %}
{% endif %}

View File

@ -1,8 +1,8 @@
{# FETCH DICTIONARIES statement #}
SELECT
CASE WHEN (pg_ns.nspname != 'pg_catalog') THEN
CONCAT(pg_ns.nspname, '.', pg_td.dictname)
pg_catalog.CONCAT(pg_ns.nspname, '.', pg_td.dictname)
ELSE pg_td.dictname END AS dictname
FROM pg_ts_dict pg_td
LEFT OUTER JOIN pg_namespace pg_ns
FROM pg_catalog.pg_ts_dict pg_td
LEFT OUTER JOIN pg_catalog.pg_namespace pg_ns
ON pg_td.dictnamespace = pg_ns.oid;

View File

@ -6,12 +6,12 @@ SELECT
SELECT
nspname
FROM
pg_namespace
pg_catalog.pg_namespace
WHERE
oid = cfg.cfgnamespace
) as schema
FROM
pg_ts_config cfg
pg_catalog.pg_ts_config cfg
WHERE
cfg.oid = {{cfgid}}::OID;
{% endif %}

Some files were not shown because too many files have changed in this diff Show More