Cast OIDs to oid not int, otherwise we lose half the range which results in objects not being accessible. Fixes #1951

This commit is contained in:
Murtuza Zabuawala 2016-11-11 14:36:41 +00:00 committed by Dave Page
parent 6f30cabdbb
commit 00d2ab0338
82 changed files with 128 additions and 128 deletions

View File

@ -10,7 +10,7 @@
LEFT JOIN pg_namespace np ON np.oid=pr.pronamespace 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) LEFT OUTER JOIN pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass)
{% if cid %} {% if cid %}
WHERE ca.oid={{cid}}::int WHERE ca.oid={{cid}}::oid
{% endif %} {% endif %}
{# Check for Show system object #} {# Check for Show system object #}
{% if (not showsysobj) and datlastsysoid %} {% if (not showsysobj) and datlastsysoid %}

View File

@ -43,7 +43,7 @@
LEFT OUTER JOIN pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass) LEFT OUTER JOIN pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass)
{% if cid %} {% if cid %}
WHERE ca.oid={{cid}}::int WHERE ca.oid={{cid}}::oid
{% endif %} {% endif %}
{# Check for Show system object #} {# Check for Show system object #}

View File

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

View File

@ -1,6 +1,6 @@
SELECT e.oid, e.evtname AS name SELECT e.oid, e.evtname AS name
FROM pg_event_trigger e FROM pg_event_trigger e
{% if etid %} {% if etid %}
WHERE e.oid={{etid}}::int WHERE e.oid={{etid}}::oid
{% endif %} {% endif %}
ORDER BY e.evtname ORDER BY e.evtname

View File

@ -12,6 +12,6 @@ array_to_string(array(select quote_literal(x) from unnest(evttags) as t(x)), ',
pg_namespace n pg_namespace n
WHERE p.pronamespace = n.oid WHERE p.pronamespace = n.oid
{% if etid %} {% if etid %}
AND e.oid={{etid}}::int AND e.oid={{etid}}::oid
{% endif %} {% endif %}
ORDER BY e.evtname ORDER BY e.evtname

View File

@ -1,7 +1,7 @@
{#============================Drop/Cascade Extension by name=========================#} {#============================Drop/Cascade Extension by name=========================#}
{% if eid %} {% if eid %}
SELECT x.extname from pg_extension x SELECT x.extname from pg_extension x
WHERE x.oid = {{ eid }}::int WHERE x.oid = {{ eid }}::oid
{% endif %} {% endif %}
{% if name %} {% if name %}
DROP EXTENSION {{ conn|qtIdent(name) }} {% if cascade %} CASCADE {% endif %} DROP EXTENSION {{ conn|qtIdent(name) }} {% if cascade %} CASCADE {% endif %}

View File

@ -9,7 +9,7 @@ FROM
LEFT JOIN pg_namespace n ON x.extnamespace=n.oid LEFT JOIN pg_namespace n ON x.extnamespace=n.oid
JOIN pg_available_extensions() e(name, default_version, comment) ON x.extname=e.name JOIN pg_available_extensions() e(name, default_version, comment) ON x.extname=e.name
{%- if eid %} {%- if eid %}
WHERE x.oid = {{eid}}::int WHERE x.oid = {{eid}}::oid
{% elif ename %} {% elif ename %}
WHERE x.extname = {{ename|qtLiteral}}::text WHERE x.extname = {{ename|qtLiteral}}::text
{% else %} {% else %}

View File

@ -1,7 +1,7 @@
{# ============= Give foreign server name from foreign server id ============= #} {# ============= Give foreign server name from foreign server id ============= #}
{% if fsid %} {% 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_foreign_data_wrapper fdw on fdw.oid=srvfdw
WHERE srv.oid={{fsid}}::int; WHERE srv.oid={{fsid}}::oid;
{% endif %} {% endif %}
{# ============= Delete/Drop cascade foreign server ============= #} {# ============= Delete/Drop cascade foreign server ============= #}
{% if name %} {% if name %}

View File

@ -4,7 +4,7 @@ SELECT fdw.oid as fdwoid,
fdwname as name fdwname as name
FROM pg_foreign_data_wrapper fdw 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) LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
WHERE fdw.oid={{fdwid}}::int WHERE fdw.oid={{fdwid}}::oid
{% else %} {% else %}
SELECT srv.oid as fsrvid, srvname as name, srvtype as fsrvtype, srvversion as fsrvversion, fdw.fdwname as fdwname, description, SELECT srv.oid as fsrvid, srvname as name, srvtype as fsrvtype, srvversion as fsrvversion, fdw.fdwname as fdwname, description,
array_to_string(srvoptions, ',') AS fsrvoptions, array_to_string(srvoptions, ',') AS fsrvoptions,
@ -18,10 +18,10 @@ WHERE fdw.fdwname = {{ fdwdata.name|qtLiteral }}::text and srvname = {{ data.nam
WHERE fdw.fdwname = {{fdwdata.name|qtLiteral}}::text WHERE fdw.fdwname = {{fdwdata.name|qtLiteral}}::text
{% endif %} {% endif %}
{% if fid %} {% if fid %}
WHERE srvfdw={{fid}}::int WHERE srvfdw={{fid}}::oid
{% endif %} {% endif %}
{% if fsid %} {% if fsid %}
WHERE srv.oid={{fsid}}::int WHERE srv.oid={{fsid}}::oid
{% endif %} {% endif %}
ORDER BY srvname; ORDER BY srvname;
{% endif %} {% endif %}

View File

@ -1,7 +1,7 @@
{# ============= Give foreign server name from foreign server id ============= #} {# ============= Give foreign server name from foreign server id ============= #}
{% if fsid %} {% 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_foreign_data_wrapper fdw on fdw.oid=srvfdw
WHERE srv.oid={{fsid}}::int; WHERE srv.oid={{fsid}}::oid;
{% endif %} {% endif %}
{# ============= Delete/Drop cascade foreign server ============= #} {# ============= Delete/Drop cascade foreign server ============= #}
{% if name %} {% if name %}

View File

@ -3,7 +3,7 @@
SELECT fdw.oid as fdwoid, fdwname as name SELECT fdw.oid as fdwoid, fdwname as name
FROM pg_foreign_data_wrapper fdw 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) LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
WHERE fdw.oid={{fdwid}}::int WHERE fdw.oid={{fdwid}}::oid
{% else %} {% else %}
SELECT srv.oid as fsrvid, srvname as name, srvtype as fsrvtype, srvversion as fsrvversion, fdw.fdwname as fdwname, description, SELECT srv.oid as fsrvid, srvname as name, srvtype as fsrvtype, srvversion as fsrvversion, fdw.fdwname as fdwname, description,
array_to_string(srvoptions, ',') AS fsrvoptions, array_to_string(srvoptions, ',') AS fsrvoptions,
@ -17,10 +17,10 @@ WHERE fdw.fdwname = {{ fdwdata.name|qtLiteral }}::text and srvname = {{ data.nam
WHERE fdw.fdwname = {{fdwdata.name|qtLiteral}}::text WHERE fdw.fdwname = {{fdwdata.name|qtLiteral}}::text
{% endif %} {% endif %}
{% if fid %} {% if fid %}
WHERE srvfdw={{fid}}::int WHERE srvfdw={{fid}}::oid
{% endif %} {% endif %}
{% if fsid %} {% if fsid %}
WHERE srv.oid={{fsid}}::int WHERE srv.oid={{fsid}}::oid
{% endif %} {% endif %}
ORDER BY srvname; ORDER BY srvname;
{% endif %} {% endif %}

View File

@ -1,7 +1,7 @@
{# ============= Get the foreing server name from id ============= #} {# ============= Get the foreing server name from id ============= #}
{% if fsid %} {% 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_foreign_data_wrapper fdw on fdw.oid=srvfdw
WHERE srv.oid={{fsid}}::int; WHERE srv.oid={{fsid}}::oid;
{% endif %} {% endif %}
{# ============= Drop/Delete cascade user mapping ============= #} {# ============= Drop/Delete cascade user mapping ============= #}
{% if name and data %} {% if name and data %}

View File

@ -3,14 +3,14 @@
SELECT srv.oid as fsrvid, srvname as name SELECT srv.oid as fsrvid, srvname as name
FROM pg_foreign_server srv 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) LEFT OUTER JOIN pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass)
WHERE srv.oid = {{fserid}}::int WHERE srv.oid = {{fserid}}::oid
{% endif %} {% endif %}
{% if fsid or umid or fdwdata or data %} {% if fsid or umid or fdwdata or data %}
WITH umapData AS WITH umapData AS
( (
SELECT u.oid AS um_oid, CASE WHEN u.umuser = 0::oid THEN 'PUBLIC'::name ELSE a.rolname END AS name, SELECT u.oid AS um_oid, CASE WHEN u.umuser = 0::oid THEN 'PUBLIC'::name ELSE a.rolname END AS name,
array_to_string(u.umoptions, ',') AS umoptions FROM pg_user_mapping u array_to_string(u.umoptions, ',') AS umoptions FROM pg_user_mapping u
LEFT JOIN pg_authid a ON a.oid = u.umuser {% if fsid %} WHERE u.umserver = {{fsid}}::int {% endif %} {% if umid %} WHERE u.oid= {{umid}}::int {% endif %} LEFT JOIN pg_authid a ON a.oid = u.umuser {% if fsid %} WHERE u.umserver = {{fsid}}::oid {% endif %} {% if umid %} WHERE u.oid= {{umid}}::oid {% endif %}
) )
SELECT * FROM umapData SELECT * FROM umapData
{% if data %} {% if data %}

View File

@ -1,6 +1,6 @@
{# ============= Get foreign data wrapper from fid ============= #} {# ============= Get foreign data wrapper from fid ============= #}
{% if fid %} {% if fid %}
SELECT fdwname as name from pg_foreign_data_wrapper WHERE oid={{fid}}::int; SELECT fdwname as name from pg_foreign_data_wrapper WHERE oid={{fid}}::oid;
{% endif %} {% endif %}
{# ============= Delete/Drop cascade foreign data wrapper ============= #} {# ============= Delete/Drop cascade foreign data wrapper ============= #}
{% if name %} {% if name %}

View File

@ -10,7 +10,7 @@ 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_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) LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
{% if fid %} {% if fid %}
WHERE fdw.oid={{fid}}::int WHERE fdw.oid={{fid}}::oid
{% endif %} {% endif %}
{% if fname %} {% if fname %}
WHERE fdw.fdwname={{ fname|qtLiteral }}::text WHERE fdw.fdwname={{ fname|qtLiteral }}::text

View File

@ -1,6 +1,6 @@
{# ============= Get foreign data wrapper from fid ============= #} {# ============= Get foreign data wrapper from fid ============= #}
{% if fid %} {% if fid %}
SELECT fdwname as name from pg_foreign_data_wrapper WHERE oid={{fid}}::int; SELECT fdwname as name from pg_foreign_data_wrapper WHERE oid={{fid}}::oid;
{% endif %} {% endif %}
{# ============= Delete/Drop cascade foreign data wrapper ============= #} {# ============= Delete/Drop cascade foreign data wrapper ============= #}
{% if name %} {% if name %}

View File

@ -10,7 +10,7 @@ FROM pg_foreign_data_wrapper fdw
LEFT OUTER JOIN pg_namespace vp_nsp ON vp_nsp.oid=vp.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) LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
{% if fid %} {% if fid %}
WHERE fdw.oid={{fid}}::int WHERE fdw.oid={{fid}}::oid
{% endif %} {% endif %}
{% if fname %} {% if fname %}
WHERE fdw.fdwname={{ fname|qtLiteral }}::text WHERE fdw.fdwname={{ fname|qtLiteral }}::text

View File

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

View File

@ -15,7 +15,7 @@ FROM
) )
WHERE lanispl IS TRUE WHERE lanispl IS TRUE
{% if lid %} AND {% if lid %} AND
lan.oid={{lid}}::int lan.oid={{lid}}::oid
{% endif %} {% endif %}
{% if lanname %} AND {% if lanname %} AND
lanname={{ lanname|qtLiteral }}::text lanname={{ lanname|qtLiteral }}::text

View File

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

View File

@ -15,7 +15,7 @@ FROM
) )
WHERE lanispl IS TRUE WHERE lanispl IS TRUE
{% if lid %} AND {% if lid %} AND
lan.oid={{lid}}::int lan.oid={{lid}}::oid
{% endif %} {% endif %}
{% if lanname %} AND {% if lanname %} AND
lanname={{ lanname|qtLiteral }}::text lanname={{ lanname|qtLiteral }}::text

View File

@ -3,8 +3,8 @@ SELECT
FROM FROM
pg_class c pg_class c
{% if scid %} {% if scid %}
WHERE relnamespace = {{scid}}::int WHERE relnamespace = {{scid}}::oid
{% elif coid %} {% elif coid %}
WHERE c.oid = {{coid}}::int WHERE c.oid = {{coid}}::oid
{% endif %} {% endif %}
ORDER BY relname; ORDER BY relname;

View File

@ -6,7 +6,7 @@ FROM
ON d.objoid=c.oid AND d.classoid='pg_class'::regclass ON d.objoid=c.oid AND d.classoid='pg_class'::regclass
LEFT JOIN pg_roles r ON c.relowner = r.oid LEFT JOIN pg_roles r ON c.relowner = r.oid
WHERE WHERE
relnamespace = {{scid}}::int relnamespace = {{scid}}::oid
{% if coid %} AND {% if coid %} AND
c.oid = {{coid}}::int c.oid = {{coid}}::oid
{% endif %} ORDER BY relname; {% endif %} ORDER BY relname;

View File

@ -2,14 +2,14 @@ SELECT
c.oid, c.relname as name c.oid, c.relname as name
FROM pg_class c FROM pg_class c
{% if scid %} {% if scid %}
WHERE relnamespace = {{scid}}::int WHERE relnamespace = {{scid}}::oid
OR ( OR (
-- On EnterpriseDB we need to ignore some objects in the catalog, namely, _*, dual and type_object_source. -- 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}}::int) select 'sys' ~ (SELECT nsp.nspname FROM pg_namespace nsp WHERE nsp.oid = {{scid}}::oid)
AND AND
(c.relname NOT LIKE '\\_%' AND c.relname = 'dual' AND c.relname = 'type_object_source') (c.relname NOT LIKE '\\_%' AND c.relname = 'dual' AND c.relname = 'type_object_source')
) )
{% elif coid %} {% elif coid %}
WHERE c.oid = {{coid}}::int WHERE c.oid = {{coid}}::oid
{% endif %} {% endif %}
ORDER BY relname; ORDER BY relname;

View File

@ -6,15 +6,15 @@ FROM
ON d.objoid=c.oid AND d.classoid='pg_class'::regclass ON d.objoid=c.oid AND d.classoid='pg_class'::regclass
LEFT JOIN pg_roles r ON c.relowner = r.oid LEFT JOIN pg_roles r ON c.relowner = r.oid
WHERE WHERE
relnamespace = {{scid}}::int relnamespace = {{scid}}::oid
{% if coid %} AND {% if coid %} AND
c.oid = {{coid}}::int c.oid = {{coid}}::oid
{% endif %} OR ( {% endif %} OR (
-- On EnterpriseDB - ignore some objects in the catalog, whose name starts -- On EnterpriseDB - ignore some objects in the catalog, whose name starts
-- with _*, dual and type_object_source. -- with _*, dual and type_object_source.
SELECT 'sys' ~ ( SELECT 'sys' ~ (
SELECT nsp.nspname FROM pg_namespace nsp SELECT nsp.nspname FROM pg_namespace nsp
WHERE nsp.oid = {{scid}}::int WHERE nsp.oid = {{scid}}::oid
) AND ( ) AND (
c.relname NOT LIKE '\\_%' AND c.relname = 'dual' AND c.relname NOT LIKE '\\_%' AND c.relname = 'dual' AND
c.relname = 'type_object_source' c.relname = 'type_object_source'

View File

@ -1,7 +1,7 @@
SELECT SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid={{scid}}::int WHERE nsp.oid={{scid}}::oid
AND ( AND (
(nspname = 'pg_catalog' AND EXISTS (nspname = 'pg_catalog' AND EXISTS
(SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1)) (SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1))

View File

@ -8,7 +8,7 @@ JOIN
WHERE WHERE
d.typnamespace = {{scid}}::oid d.typnamespace = {{scid}}::oid
AND AND
d.oid={{doid}}::int; d.oid={{doid}}::oid;
{% endif %} {% endif %}
{% if name %} {% if name %}

View File

@ -29,7 +29,7 @@ LEFT OUTER JOIN
WHERE WHERE
d.typnamespace = {{scid}}::oid d.typnamespace = {{scid}}::oid
{% if doid %} {% if doid %}
AND d.oid={{doid}}::int AND d.oid={{doid}}::oid
{% endif %} {% endif %}
ORDER BY ORDER BY
d.typname; d.typname;

View File

@ -8,7 +8,7 @@ JOIN
WHERE WHERE
d.typnamespace = {{scid}}::oid d.typnamespace = {{scid}}::oid
AND AND
d.oid={{doid}}::int; d.oid={{doid}}::oid;
{% endif %} {% endif %}
{% if name %} {% if name %}

View File

@ -28,7 +28,7 @@ LEFT OUTER JOIN
WHERE WHERE
d.typnamespace = {{scid}}::oid d.typnamespace = {{scid}}::oid
{% if doid %} {% if doid %}
AND d.oid={{doid}}::int AND d.oid={{doid}}::oid
{% endif %} {% endif %}
ORDER BY ORDER BY
d.typname; d.typname;

View File

@ -1,7 +1,7 @@
SELECT SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid={{scid}}::int AND ( WHERE nsp.oid={{scid}}::oid AND (
(nspname = 'pg_catalog' AND EXISTS (nspname = 'pg_catalog' AND EXISTS
(SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1)) (SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1))
OR (nspname = 'pgagent' AND EXISTS OR (nspname = 'pgagent' AND EXISTS

View File

@ -3,5 +3,5 @@ SELECT nsp.nspname AS schema,
FROM FROM
pg_class rel pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -3,5 +3,5 @@ SELECT nsp.nspname AS schema,
FROM FROM
pg_class rel pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -1,5 +1,5 @@
SELECT nsp.nspname AS schema ,rel.relname AS table SELECT nsp.nspname AS schema ,rel.relname AS table
FROM pg_class rel FROM pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -1,5 +1,5 @@
SELECT nsp.nspname AS schema ,rel.relname AS table SELECT nsp.nspname AS schema ,rel.relname AS table
FROM pg_class rel FROM pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -3,5 +3,5 @@ SELECT nsp.nspname AS schema,
FROM FROM
pg_class rel pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -3,5 +3,5 @@ SELECT nsp.nspname AS schema,
FROM FROM
pg_class rel pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -3,5 +3,5 @@ SELECT nsp.nspname AS schema,
FROM FROM
pg_class rel pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -3,5 +3,5 @@ SELECT nsp.nspname AS schema,
FROM FROM
pg_class rel pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -1,5 +1,5 @@
SELECT nsp.nspname AS schema ,rel.relname AS table SELECT nsp.nspname AS schema ,rel.relname AS table
FROM pg_class rel FROM pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -3,5 +3,5 @@ SELECT nsp.nspname AS schema,
FROM FROM
pg_class rel pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -1,7 +1,7 @@
SELECT SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid={{scid}}::int WHERE nsp.oid={{scid}}::oid
AND ( AND (
(nspname = 'pg_catalog' AND EXISTS (nspname = 'pg_catalog' AND EXISTS
(SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1)) (SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1))

View File

@ -1,7 +1,7 @@
SELECT SELECT
CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport CASE WHEN nsp.nspname IN ('sys', 'dbo', 'information_schema') THEN true ELSE false END AS dbSupport
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid={{scid}}::int WHERE nsp.oid={{scid}}::oid
AND ( AND (
(nspname = 'pg_catalog' AND EXISTS (nspname = 'pg_catalog' AND EXISTS
(SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1)) (SELECT 1 FROM pg_class WHERE relname = 'pg_class' AND relnamespace = nsp.oid LIMIT 1))

View File

@ -1,5 +1,5 @@
SELECT nsp.nspname AS schema ,rel.relname AS table SELECT nsp.nspname AS schema ,rel.relname AS table
FROM pg_class rel FROM pg_class rel
JOIN pg_namespace nsp JOIN pg_namespace nsp
ON rel.relnamespace = nsp.oid::int ON rel.relnamespace = nsp.oid::oid
WHERE rel.oid = {{tid}}::int WHERE rel.oid = {{tid}}::oid

View File

@ -8,7 +8,7 @@ FROM
pg_namespace nsp pg_namespace nsp
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
( (
{{ CATALOGS.LIST('nsp') }} {{ CATALOGS.LIST('nsp') }}

View File

@ -19,7 +19,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
( (
{{ CATALOGS.LIST('nsp') }} {{ CATALOGS.LIST('nsp') }}

View File

@ -8,7 +8,7 @@ FROM
pg_namespace nsp pg_namespace nsp
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
( (
{{ CATALOGS.LIST('nsp') }} {{ CATALOGS.LIST('nsp') }}

View File

@ -20,7 +20,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
( (
{{ CATALOGS.LIST('nsp') }} {{ CATALOGS.LIST('nsp') }}

View File

@ -8,7 +8,7 @@ FROM
pg_namespace nsp pg_namespace nsp
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
nsp.nspparent = 0 AND nsp.nspparent = 0 AND
( (

View File

@ -20,7 +20,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
nsp.nspparent = 0 AND nsp.nspparent = 0 AND
( (

View File

@ -8,7 +8,7 @@ FROM
pg_namespace nsp pg_namespace nsp
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
nsp.nspparent = 0 AND nsp.nspparent = 0 AND
( (

View File

@ -21,7 +21,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% endif %} {% endif %}
nsp.nspparent = 0 AND nsp.nspparent = 0 AND
( (

View File

@ -31,7 +31,7 @@ FROM
pg_namespace nsp pg_namespace nsp
LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid) LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid)
WHERE WHERE
nsp.oid={{scid}}::int nsp.oid={{scid}}::oid
) d) a ) d) a
LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid)

View File

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

View File

@ -38,7 +38,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% else %} {% else %}
{% if show_sysobj %} {% if show_sysobj %}
nspname NOT LIKE E'pg\\_temp\\_%' AND nspname NOT LIKE E'pg\\_temp\\_%' AND

View File

@ -32,7 +32,7 @@ FROM
pg_namespace nsp pg_namespace nsp
LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid) LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid)
WHERE WHERE
nsp.oid={{scid}}::int nsp.oid={{scid}}::oid
) d) a ) d) a
LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid)

View File

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

View File

@ -44,7 +44,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% else %} {% else %}
{% if show_sysobj %} {% if show_sysobj %}
nspname NOT LIKE E'pg\\_temp\\_%' AND nspname NOT LIKE E'pg\\_temp\\_%' AND

View File

@ -31,7 +31,7 @@ FROM
pg_namespace nsp pg_namespace nsp
LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid) LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid)
WHERE WHERE
nsp.oid={{scid}}::int nsp.oid={{scid}}::oid
) d) a ) d) a
LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid)

View File

@ -9,7 +9,7 @@ FROM
WHERE WHERE
nsp.nspparent = 0 AND nsp.nspparent = 0 AND
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% else %} {% else %}
{% if not show_sysobj %} {% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND nspname NOT LIKE E'pg\_%' AND

View File

@ -37,7 +37,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% else %} {% else %}
{% if show_sysobj %} {% if show_sysobj %}
nspname NOT LIKE E'pg\\_temp\\_%' AND nspname NOT LIKE E'pg\\_temp\\_%' AND

View File

@ -32,7 +32,7 @@ FROM
pg_namespace nsp pg_namespace nsp
LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid) LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid)
WHERE WHERE
nsp.oid={{scid}}::int nsp.oid={{scid}}::oid
) d) a ) d) a
LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid)

View File

@ -9,7 +9,7 @@ FROM
WHERE WHERE
nsp.nspparent = 0 AND nsp.nspparent = 0 AND
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% else %} {% else %}
{% if not show_sysobj %} {% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND nspname NOT LIKE E'pg\_%' AND

View File

@ -43,7 +43,7 @@ FROM
LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner) LEFT JOIN pg_roles r ON (r.oid = nsp.nspowner)
WHERE WHERE
{% if scid %} {% if scid %}
nsp.oid={{scid}}::int AND nsp.oid={{scid}}::oid AND
{% else %} {% else %}
{% if show_sysobj %} {% if show_sysobj %}
nspname NOT LIKE E'pg\\_temp\\_%' AND nspname NOT LIKE E'pg\\_temp\\_%' AND

View File

@ -1,6 +1,6 @@
{# ============= Below SQL will get the resource group name using oid ============= #} {# ============= Below SQL will get the resource group name using oid ============= #}
{% if rgid %} {% if rgid %}
SELECT rgrpname FROM edb_resource_group WHERE oid = {{rgid}}::int; SELECT rgrpname FROM edb_resource_group WHERE oid = {{rgid}}::oid;
{% endif %} {% endif %}
{# ============= Below SQL will drop the resource group ============= #} {# ============= Below SQL will drop the resource group ============= #}
{% if rgname %} {% if rgname %}

View File

@ -1,6 +1,6 @@
SELECT oid, rgrpname AS name SELECT oid, rgrpname AS name
FROM edb_resource_group FROM edb_resource_group
{% if rgid %} {% if rgid %}
WHERE oid={{rgid}}::int WHERE oid={{rgid}}::oid
{% endif %} {% endif %}
ORDER BY rgrpname ORDER BY rgrpname

View File

@ -1,6 +1,6 @@
SELECT oid, rgrpname AS name, rgrpcpuratelimit AS cpu_rate_limit, rgrpdirtyratelimit AS dirty_rate_limit SELECT oid, rgrpname AS name, rgrpcpuratelimit AS cpu_rate_limit, rgrpdirtyratelimit AS dirty_rate_limit
FROM edb_resource_group FROM edb_resource_group
{% if rgid %} {% if rgid %}
WHERE oid={{rgid}}::int WHERE oid={{rgid}}::oid
{% endif %} {% endif %}
ORDER BY rgrpname ORDER BY rgrpname

View File

@ -5,7 +5,7 @@ SELECT 'd' as type, datname,
FROM pg_database db FROM pg_database db
UNION UNION
SELECT 'M', spcname, null, null, null SELECT 'M', spcname, null, null, null
FROM pg_tablespace where spcowner= {{rid}}::int FROM pg_tablespace where spcowner= {{rid}}::oid
ORDER BY 1, 2 ORDER BY 1, 2
{% endif %} {% endif %}
@ -17,24 +17,24 @@ JOIN pg_namespace cln ON cl.relnamespace=cln.oid
LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid
LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid
LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid
WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::int WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'n', null, nspname, null UNION ALL SELECT 'n', null, nspname, null
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::int WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null
FROM pg_type ty FROM pg_type ty
WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::int WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'C', null, conname, null UNION ALL SELECT 'C', null, conname, null
FROM pg_conversion co FROM pg_conversion co
WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::int WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null
FROM pg_proc pr FROM pg_proc pr
WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::int WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL
AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null
FROM pg_operator op FROM pg_operator op
LEFT JOIN pg_type tl ON tl.oid=op.oprleft LEFT JOIN pg_type tl ON tl.oid=op.oprleft
LEFT JOIN pg_type tr ON tr.oid=op.oprright LEFT JOIN pg_type tr ON tr.oid=op.oprright
WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::int WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::oid
ORDER BY 1,2,3 ORDER BY 1,2,3
{% endif %} {% endif %}

View File

@ -5,7 +5,7 @@ SELECT 'd' as type, datname,
FROM pg_database db FROM pg_database db
UNION UNION
SELECT 'M', spcname, null, null, null SELECT 'M', spcname, null, null, null
FROM pg_tablespace where spcowner= {{rid}}::int FROM pg_tablespace where spcowner= {{rid}}::oid
ORDER BY 1, 2 ORDER BY 1, 2
{% endif %} {% endif %}
@ -17,24 +17,24 @@ JOIN pg_namespace cln ON cl.relnamespace=cln.oid
LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid
LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid
LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid
WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::int WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'n', null, nspname, null UNION ALL SELECT 'n', null, nspname, null
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::int WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null
FROM pg_type ty FROM pg_type ty
WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::int WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'C', null, conname, null UNION ALL SELECT 'C', null, conname, null
FROM pg_conversion co FROM pg_conversion co
WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::int WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null
FROM pg_proc pr FROM pg_proc pr
WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::int WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL
AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null
FROM pg_operator op FROM pg_operator op
LEFT JOIN pg_type tl ON tl.oid=op.oprleft LEFT JOIN pg_type tl ON tl.oid=op.oprleft
LEFT JOIN pg_type tr ON tr.oid=op.oprright LEFT JOIN pg_type tr ON tr.oid=op.oprright
WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::int WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::oid
ORDER BY 1,2,3 ORDER BY 1,2,3
{% endif %} {% endif %}

View File

@ -11,6 +11,6 @@ SELECT
FROM FROM
pg_roles r pg_roles r
{% if rid %} {% if rid %}
WHERE r.oid = {{ rid|qtLiteral }}::int WHERE r.oid = {{ rid|qtLiteral }}::oid
{% endif %} {% endif %}
ORDER BY r.rolcanlogin, r.rolname ORDER BY r.rolcanlogin, r.rolname

View File

@ -5,7 +5,7 @@ SELECT 'd' as type, datname,
FROM pg_database db FROM pg_database db
UNION UNION
SELECT 'M', spcname, null, null, null SELECT 'M', spcname, null, null, null
FROM pg_tablespace where spcowner= {{rid}}::int FROM pg_tablespace where spcowner= {{rid}}::oid
ORDER BY 1, 2 ORDER BY 1, 2
{% endif %} {% endif %}
@ -17,24 +17,24 @@ JOIN pg_namespace cln ON cl.relnamespace=cln.oid
LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid
LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid
LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid
WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::int WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'n', null, nspname, null UNION ALL SELECT 'n', null, nspname, null
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::int WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null
FROM pg_type ty FROM pg_type ty
WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::int WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'C', null, conname, null UNION ALL SELECT 'C', null, conname, null
FROM pg_conversion co FROM pg_conversion co
WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::int WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null
FROM pg_proc pr FROM pg_proc pr
WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::int WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL
AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null
FROM pg_operator op FROM pg_operator op
LEFT JOIN pg_type tl ON tl.oid=op.oprleft LEFT JOIN pg_type tl ON tl.oid=op.oprleft
LEFT JOIN pg_type tr ON tr.oid=op.oprright LEFT JOIN pg_type tr ON tr.oid=op.oprright
WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::int WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::oid
ORDER BY 1,2,3 ORDER BY 1,2,3
{% endif %} {% endif %}

View File

@ -3,6 +3,6 @@ SELECT
FROM FROM
pg_roles r pg_roles r
{% if rid %} {% if rid %}
WHERE r.oid = {{ rid|qtLiteral }}::int WHERE r.oid = {{ rid|qtLiteral }}::oid
{% endif %} {% endif %}
ORDER BY r.rolcanlogin, r.rolname ORDER BY r.rolcanlogin, r.rolname

View File

@ -12,6 +12,6 @@ SELECT
FROM FROM
pg_roles r pg_roles r
{% if rid %} {% if rid %}
WHERE r.oid = {{ rid|qtLiteral }}::int WHERE r.oid = {{ rid|qtLiteral }}::oid
{% endif %} {% endif %}
ORDER BY r.rolcanlogin, r.rolname ORDER BY r.rolcanlogin, r.rolname

View File

@ -5,7 +5,7 @@ SELECT 'd' as type, datname,
FROM pg_database db FROM pg_database db
UNION UNION
SELECT 'M', spcname, null, null, null SELECT 'M', spcname, null, null, null
FROM pg_tablespace where spcowner={{rid}}::int FROM pg_tablespace where spcowner={{rid}}::oid
ORDER BY 1, 2 ORDER BY 1, 2
{% endif %} {% endif %}
@ -17,24 +17,24 @@ JOIN pg_namespace cln ON cl.relnamespace=cln.oid
LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid LEFT OUTER JOIN pg_index ind ON ind.indexrelid=cl.oid
LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid LEFT OUTER JOIN pg_class ci ON ind.indrelid=ci.oid
LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid LEFT OUTER JOIN pg_namespace cin ON ci.relnamespace=cin.oid
WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::int WHERE cl.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'n', null, nspname, null UNION ALL SELECT 'n', null, nspname, null
FROM pg_namespace nsp FROM pg_namespace nsp
WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::int WHERE nsp.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null
FROM pg_type ty FROM pg_type ty
WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::int WHERE ty.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'C', null, conname, null UNION ALL SELECT 'C', null, conname, null
FROM pg_conversion co FROM pg_conversion co
WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::int WHERE co.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::oid
UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null
FROM pg_proc pr FROM pg_proc pr
WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::int WHERE pr.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::oid
UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL
AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null
FROM pg_operator op FROM pg_operator op
LEFT JOIN pg_type tl ON tl.oid=op.oprleft LEFT JOIN pg_type tl ON tl.oid=op.oprleft
LEFT JOIN pg_type tr ON tr.oid=op.oprright LEFT JOIN pg_type tr ON tr.oid=op.oprright
WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::int WHERE op.oid IN (SELECT objid FROM pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::oid
ORDER BY 1,2,3 ORDER BY 1,2,3
{% endif %} {% endif %}

View File

@ -3,6 +3,6 @@ SELECT
FROM FROM
pg_roles r pg_roles r
{% if rid %} {% if rid %}
WHERE r.oid = {{ rid|qtLiteral }}::int WHERE r.oid = {{ rid|qtLiteral }}::oid
{% endif %} {% endif %}
ORDER BY r.rolcanlogin, r.rolname ORDER BY r.rolcanlogin, r.rolname

View File

@ -12,6 +12,6 @@ SELECT
FROM FROM
pg_roles r pg_roles r
{% if rid %} {% if rid %}
WHERE r.oid = {{ rid|qtLiteral }}::int WHERE r.oid = {{ rid|qtLiteral }}::oid
{% endif %} {% endif %}
ORDER BY r.rolcanlogin, r.rolname ORDER BY r.rolcanlogin, r.rolname

View File

@ -60,5 +60,5 @@ FROM
LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid
{% endif %} {% endif %}
{% if fid %} {% if fid %}
WHERE p.oid = {{fid}}::int; WHERE p.oid = {{fid}}::oid;
{% endif %} {% endif %}

View File

@ -60,5 +60,5 @@ FROM
LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid
{% endif %} {% endif %}
{% if fid %} {% if fid %}
WHERE p.oid = {{fid}}::int; WHERE p.oid = {{fid}}::oid;
{% endif %} {% endif %}

View File

@ -60,5 +60,5 @@ FROM
LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid LEFT JOIN pg_catalog.pg_namespace g ON n.nspparent = g.oid
{% endif %} {% endif %}
{% if fid %} {% if fid %}
WHERE p.oid = {{fid}}::int; WHERE p.oid = {{fid}}::oid;
{% endif %} {% endif %}

View File

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

View File

@ -8,7 +8,7 @@ FROM
WHERE WHERE
nsp.nspparent = 0 AND nsp.nspparent = 0 AND
{% if nspid %} {% if nspid %}
nsp.oid={{nspid}}::int AND nsp.oid={{nspid}}::oid AND
{% else %} {% else %}
{% if not show_sysobj %} {% if not show_sysobj %}
nspname NOT LIKE E'pg\_%' AND nspname NOT LIKE E'pg\_%' AND

View File

@ -4,5 +4,5 @@ SELECT at.attname, ty.typname
FROM pg_attribute at LEFT JOIN pg_type ty ON (ty.oid = at.atttypid) FROM pg_attribute at LEFT JOIN pg_type ty ON (ty.oid = at.atttypid)
WHERE attrelid={{obj_id}}::oid AND attnum = ANY ( WHERE attrelid={{obj_id}}::oid AND attnum = ANY (
(SELECT con.conkey FROM pg_class rel LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid (SELECT con.conkey FROM pg_class rel LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid
AND con.contype='p' WHERE rel.relkind IN ('r','s','t') AND rel.oid = {{obj_id}}::oid)::integer[]) AND con.contype='p' WHERE rel.relkind IN ('r','s','t') AND rel.oid = {{obj_id}}::oid)::oid[])
{% endif %} {% endif %}