public inbox for [email protected]help / color / mirror / Atom feed
PATCH: Adding support of Package in synonym (pgAdmin4) 4+ messages / 2 participants [nested] [flat]
* PATCH: Adding support of Package in synonym (pgAdmin4) @ 2016-09-22 13:08 Murtuza Zabuawala <[email protected]> 2016-09-22 13:57 ` Re: PATCH: Adding support of Package in synonym (pgAdmin4) Dave Page <[email protected]> 0 siblings, 1 reply; 4+ messages in thread From: Murtuza Zabuawala @ 2016-09-22 13:08 UTC (permalink / raw) To: pgadmin-hackers Hi, PFA patch to add support for creating synonym for Packages. RM#1611 -- Regards, Murtuza Zabuawala EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers Attachments: [application/octet-stream] RM_1611.patch (9.3K, 3-RM_1611.patch) download | inline diff: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py index 9e02146..95e58b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/__init__.py @@ -195,7 +195,9 @@ class SynonymView(PGChildNodeView): ) # we will set template path for sql scripts - self.template_path = 'synonym/sql/9.1_plus' + self.template_path = 'synonym/sql/' + self.template_path += '9.5_plus' if self.manager.version >= 90500 \ + else '9.1_plus' return f(*args, **kwargs) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/js/synonym.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/js/synonym.js index c0de434..bd9900d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/js/synonym.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/js/synonym.js @@ -102,6 +102,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) { {label: "View", value: "v"}, {label: "Function", value: "f"}, {label: "Procedure", value: "p"}, + {label: "Package", value: "P"}, {label: "Public Synonym", value: "s"} ] }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.1_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.1_plus/get_oid.sql deleted file mode 100644 index 0abdfe6..0000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.1_plus/get_oid.sql +++ /dev/null @@ -1,8 +0,0 @@ -{# Below will provide oid for newly created collation #} -{% if data %} -SELECT c.oid -FROM pg_collation c, pg_namespace n -WHERE c.collnamespace=n.oid AND - n.nspname = {{ data.schema|qtLiteral }} AND - c.collname = {{ data.name|qtLiteral }} -{% endif %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/create.sql new file mode 100644 index 0000000..33c24f3 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/create.sql @@ -0,0 +1,21 @@ +{% set is_public = False %} +{% if data.schema == 'public' %} +{% set is_public = True %} +{% endif %} +{% if comment %} +-- {% if is_public %}Public{% else %}Private{% endif %} synonym: {% if is_public %}{{ conn|qtIdent(data.name) }}; +{% else %}{{ conn|qtIdent(data.schema, data.name) }}; +{% endif %} + +-- DROP {% if is_public %}PUBLIC {% endif %}SYNONYM {% if is_public %}{{ conn|qtIdent(data.name) }}; +{% else %}{{ conn|qtIdent(data.schema, data.name) }}; +{% endif %} + +{% endif %} +CREATE OR REPLACE {% if is_public %} +PUBLIC SYNONYM {{ conn|qtIdent(data.name) }} +{% else %} +SYNONYM {{ conn|qtIdent(data.schema, data.name) }} +{% endif %} + FOR {{ conn|qtIdent(data.synobjschema, data.synobjname) }}; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/delete.sql new file mode 100644 index 0000000..f697697 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/delete.sql @@ -0,0 +1,8 @@ +{% set is_public = False %} +{% if data.schema == 'public' %} +{% set is_public = True %} +{% endif %} +DROP {% if is_public %} +PUBLIC SYNONYM {{ conn|qtIdent(data.name) }}{% else %} +SYNONYM {{ conn|qtIdent(data.schema, data.name) }} +{% endif %}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/get_objects.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/get_objects.sql new file mode 100644 index 0000000..0ae7aec --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/get_objects.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/nodes.sql new file mode 100644 index 0000000..1f8259b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/nodes.sql @@ -0,0 +1,5 @@ +SELECT synname as name +FROM pg_synonym s + JOIN pg_namespace ns ON s.synnamespace = ns.oid + AND s.synnamespace = {{scid}}::oid +ORDER BY synname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/properties.sql new file mode 100644 index 0000000..ec2724a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/properties.sql @@ -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; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/update.sql new file mode 100644 index 0000000..de91b94 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonym/sql/9.5_plus/update.sql @@ -0,0 +1,10 @@ +{% set is_public = False %} +{% if o_data.schema == 'public' %} +{% set is_public = True %} +{% endif %} +CREATE OR REPLACE {% if is_public %} +PUBLIC SYNONYM {{ conn|qtIdent(o_data.name) }} +{% else %} +SYNONYM {{ conn|qtIdent(o_data.schema, o_data.name) }} +{% endif %} + FOR {{ conn|qtIdent(data.synobjschema, data.synobjname) }}; \ No newline at end of file ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PATCH: Adding support of Package in synonym (pgAdmin4) 2016-09-22 13:08 PATCH: Adding support of Package in synonym (pgAdmin4) Murtuza Zabuawala <[email protected]> @ 2016-09-22 13:57 ` Dave Page <[email protected]> 2016-09-22 14:09 ` Re: PATCH: Adding support of Package in synonym (pgAdmin4) Murtuza Zabuawala <[email protected]> 0 siblings, 1 reply; 4+ messages in thread From: Dave Page @ 2016-09-22 13:57 UTC (permalink / raw) To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers Thanks - committed. I noticed while testing that if I update a synonym (I was changing the target package), the properties list doesn't seem to auto-refresh when I hit OK on the dialogue. Can you reproduce that? On Thu, Sep 22, 2016 at 2:08 PM, Murtuza Zabuawala <[email protected]> wrote: > Hi, > > PFA patch to add support for creating synonym for Packages. > RM#1611 > > -- > Regards, > Murtuza Zabuawala > EnterpriseDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > > > -- > Sent via pgadmin-hackers mailing list ([email protected]) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgadmin-hackers > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PATCH: Adding support of Package in synonym (pgAdmin4) 2016-09-22 13:08 PATCH: Adding support of Package in synonym (pgAdmin4) Murtuza Zabuawala <[email protected]> 2016-09-22 13:57 ` Re: PATCH: Adding support of Package in synonym (pgAdmin4) Dave Page <[email protected]> @ 2016-09-22 14:09 ` Murtuza Zabuawala <[email protected]> 2016-09-22 14:36 ` Re: PATCH: Adding support of Package in synonym (pgAdmin4) Dave Page <[email protected]> 0 siblings, 1 reply; 4+ messages in thread From: Murtuza Zabuawala @ 2016-09-22 14:09 UTC (permalink / raw) To: Dave Page <[email protected]>; +Cc: pgadmin-hackers Yes, I can. Seems like it got broken after we have made changes for sorting nodes. -- Regards, Murtuza Zabuawala EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company On Thu, Sep 22, 2016 at 7:27 PM, Dave Page <[email protected]> wrote: > Thanks - committed. I noticed while testing that if I update a synonym > (I was changing the target package), the properties list doesn't seem > to auto-refresh when I hit OK on the dialogue. Can you reproduce that? > > On Thu, Sep 22, 2016 at 2:08 PM, Murtuza Zabuawala > <[email protected]> wrote: > > Hi, > > > > PFA patch to add support for creating synonym for Packages. > > RM#1611 > > > > -- > > Regards, > > Murtuza Zabuawala > > EnterpriseDB: http://www.enterprisedb.com > > The Enterprise PostgreSQL Company > > > > > > -- > > Sent via pgadmin-hackers mailing list ([email protected]) > > To make changes to your subscription: > > http://www.postgresql.org/mailpref/pgadmin-hackers > > > > > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PATCH: Adding support of Package in synonym (pgAdmin4) 2016-09-22 13:08 PATCH: Adding support of Package in synonym (pgAdmin4) Murtuza Zabuawala <[email protected]> 2016-09-22 13:57 ` Re: PATCH: Adding support of Package in synonym (pgAdmin4) Dave Page <[email protected]> 2016-09-22 14:09 ` Re: PATCH: Adding support of Package in synonym (pgAdmin4) Murtuza Zabuawala <[email protected]> @ 2016-09-22 14:36 ` Dave Page <[email protected]> 0 siblings, 0 replies; 4+ messages in thread From: Dave Page @ 2016-09-22 14:36 UTC (permalink / raw) To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers OK - I've logged it here: https://redmine.postgresql.org/issues/1728 That just became our second highest priority issue! On Thu, Sep 22, 2016 at 3:09 PM, Murtuza Zabuawala <[email protected]> wrote: > Yes, I can. > > Seems like it got broken after we have made changes for sorting nodes. > > -- > Regards, > Murtuza Zabuawala > EnterpriseDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > > On Thu, Sep 22, 2016 at 7:27 PM, Dave Page <[email protected]> wrote: >> >> Thanks - committed. I noticed while testing that if I update a synonym >> (I was changing the target package), the properties list doesn't seem >> to auto-refresh when I hit OK on the dialogue. Can you reproduce that? >> >> On Thu, Sep 22, 2016 at 2:08 PM, Murtuza Zabuawala >> <[email protected]> wrote: >> > Hi, >> > >> > PFA patch to add support for creating synonym for Packages. >> > RM#1611 >> > >> > -- >> > Regards, >> > Murtuza Zabuawala >> > EnterpriseDB: http://www.enterprisedb.com >> > The Enterprise PostgreSQL Company >> > >> > >> > -- >> > Sent via pgadmin-hackers mailing list ([email protected]) >> > To make changes to your subscription: >> > http://www.postgresql.org/mailpref/pgadmin-hackers >> > >> >> >> >> -- >> Dave Page >> Blog: http://pgsnake.blogspot.com >> Twitter: @pgsnake >> >> EnterpriseDB UK: http://www.enterprisedb.com >> The Enterprise PostgreSQL Company > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2016-09-22 14:36 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-09-22 13:08 PATCH: Adding support of Package in synonym (pgAdmin4) Murtuza Zabuawala <[email protected]> 2016-09-22 13:57 ` Dave Page <[email protected]> 2016-09-22 14:09 ` Murtuza Zabuawala <[email protected]> 2016-09-22 14:36 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox