mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-15 11:12:25 -06:00
List packages in PPAS 9.2-9.4 when creating synonyms. Fixes #1813
This commit is contained in:
parent
b134ae2cb4
commit
495a3cedb0
@ -0,0 +1,56 @@
|
||||
{###########################################}
|
||||
{### If Target Type is Function ###}
|
||||
{###########################################}
|
||||
{% if trgTyp == 'f' %}
|
||||
SELECT DISTINCT proname AS name
|
||||
FROM pg_proc p, pg_namespace n
|
||||
WHERE p.pronamespace = n.oid AND
|
||||
n.nspname = {{ trgSchema|qtLiteral }} AND
|
||||
p.protype = '0'
|
||||
ORDER BY proname;
|
||||
{###########################################}
|
||||
{### If Target Type is Procedure ###}
|
||||
{###########################################}
|
||||
{% elif trgTyp == 'p' %}
|
||||
SELECT DISTINCT proname AS name
|
||||
FROM pg_proc p, pg_namespace n
|
||||
WHERE p.pronamespace = n.oid AND
|
||||
n.nspname = {{ trgSchema|qtLiteral }} AND
|
||||
p.protype = '1'
|
||||
ORDER BY proname;
|
||||
{###########################################}
|
||||
{### If Target Type is Synonym ###}
|
||||
{###########################################}
|
||||
{% elif trgTyp == 's' %}
|
||||
SELECT synname AS name
|
||||
FROM pg_synonym
|
||||
ORDER BY synname;
|
||||
{###########################################}
|
||||
{### If Target Type is Package ###}
|
||||
{###########################################}
|
||||
{% elif trgTyp == 'P' %}
|
||||
SELECT nspname AS name
|
||||
FROM pg_namespace
|
||||
WHERE nspparent IN (
|
||||
SELECT oid
|
||||
FROM pg_namespace
|
||||
WHERE nspname = {{ trgSchema|qtLiteral }} LIMIT 1
|
||||
)
|
||||
AND nspobjecttype = 0
|
||||
ORDER BY nspname;
|
||||
{% else %}
|
||||
{###################################################}
|
||||
{### If Target Type is Table/View/M.View/Sequnce ###}
|
||||
{###################################################}
|
||||
SELECT relname AS name
|
||||
FROM pg_class c, pg_namespace n
|
||||
WHERE c.relnamespace = n.oid AND
|
||||
n.nspname = {{ trgSchema|qtLiteral }} AND
|
||||
{% if trgTyp == 'v' %}
|
||||
{# If view is select then we need to fetch both view and materialized view #}
|
||||
(c.relkind = 'v' OR c.relkind = 'm')
|
||||
{% else %}
|
||||
c.relkind = {{ trgTyp|qtLiteral }}
|
||||
{% endif %}
|
||||
ORDER BY relname;
|
||||
{% endif %}
|
@ -0,0 +1,31 @@
|
||||
SELECT synname AS name, pg_get_userbyid(synowner) AS owner,
|
||||
synobjschema, synobjname, ns.nspname as schema,
|
||||
COALESCE(
|
||||
(SELECT relkind
|
||||
FROM pg_class c, pg_namespace n
|
||||
WHERE c.relnamespace = n.oid
|
||||
AND n.nspname = synobjschema
|
||||
AND c.relname = synobjname),
|
||||
-- For Function/Procedure
|
||||
(SELECT CASE WHEN p.protype = '0' THEN 'f'::"char" ELSE 'p'::"char" END
|
||||
FROM pg_proc p, pg_namespace n
|
||||
WHERE p.pronamespace = n.oid
|
||||
AND n.nspname = synobjschema
|
||||
AND p.proname = synobjname LIMIT 1),
|
||||
-- For Package
|
||||
(SELECT CASE WHEN count(*) > 0 THEN 'P'::"char" END
|
||||
FROM pg_namespace
|
||||
WHERE nspparent IN (SELECT oid
|
||||
FROM pg_namespace
|
||||
WHERE nspname = synobjschema LIMIT 1)
|
||||
AND nspname = synobjname
|
||||
AND nspobjecttype = 0),
|
||||
-- Default s = Synonym
|
||||
's') AS targettype,
|
||||
CASE WHEN ns.nspname = 'public' THEN true ELSE false END AS is_public_synonym
|
||||
FROM pg_synonym s JOIN pg_namespace ns ON s.synnamespace = ns.oid
|
||||
WHERE s.synnamespace={{scid}}::oid
|
||||
{% if syid %}
|
||||
AND s.synname={{ syid|qtLiteral }}
|
||||
{% endif %}
|
||||
ORDER BY synname;
|
Loading…
Reference in New Issue
Block a user