public inbox for [email protected]help / color / mirror / Atom feed
[pgAdmin] RM6117 Unable to update column level privileges from security tab. 7+ messages / 4 participants [nested] [flat]
* [pgAdmin] RM6117 Unable to update column level privileges from security tab. @ 2021-02-05 19:54 Rahul Shirsat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rahul Shirsat @ 2021-02-05 19:54 UTC (permalink / raw) To: pgadmin-hackers Hi Hackers, Please find the attached patch which resolves the issue of unable to update column level privileges in the security tab. Additionally, when the user tries to change grantee, the sql wasn't generating, this too issue is resolved. This security privilege issue is resolved for the following nodes: 1.) Tables (test cases are skipped as there are no resql test cases based on pg & ppas) 2.) Columns 3.) Views 4.) MViews 5.) Types 6.) Functions 7.) Procedures 8.) Trigger functions 9.) Sequences 10.) Schema P.S for committer : Warning of whitespaces after applying patch should be ignored as it is a part of resql test case results. -- *Rahul Shirsat* Senior Software Engineer | EnterpriseDB Corporation. Attachments: [application/octet-stream] RM6117.patch (374.2K, 3-RM6117.patch) download | inline diff: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql index 5e8d357d7..6bc64af3c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql index 6b5772851..01c749ceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql @@ -60,10 +60,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql index 8c18299b4..745877342 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql @@ -59,7 +59,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql index 963a7f3be..ac13a7525 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql @@ -56,10 +56,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql index 1917283f9..916347e13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql index aad4b6612..0122a4f51 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql @@ -55,10 +55,12 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endfor %}{% endif %} {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} - +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} - {% endfor %}{% endif %} {% if 'added' in data.acl %} {% for priv in data.acl.added %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql index 6b5772851..01c749ceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql @@ -60,10 +60,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql index c9c76b82d..56ff2ad4b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql @@ -59,7 +59,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql index 963a7f3be..ac13a7525 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql @@ -56,10 +56,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql index 1917283f9..916347e13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql index f922abdc2..c2f160e22 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql @@ -47,10 +47,14 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql index 6e711724d..43836ca50 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql @@ -57,10 +57,14 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql index 65c766ca9..0b4ed30d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql @@ -45,7 +45,11 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {% if 'changed' in data.datacl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql index c1d7576e3..2030c917c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql @@ -48,7 +48,11 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {% if 'changed' in data.datacl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql index 124cbe93b..0f936f3ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql @@ -50,10 +50,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql index 92a625db0..212c5b0ba 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql @@ -53,7 +53,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql index 124cbe93b..0f936f3ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql @@ -50,10 +50,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql index ec71dee45..cd28330dc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql @@ -49,7 +49,12 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endfor %}{% endif %} {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} + +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..6c76571ec --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..67a549ead --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM postgres; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json index dc9a44520..cf0996aab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..6c76571ec --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..67a549ead --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM postgres; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json index dc9a44520..cf0996aab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..0e186f86e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE WINDOW + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json index 34225e580..0ed3b29e4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json @@ -213,7 +213,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..6c76571ec --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..a00d45f13 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json index bc1043b6c..e33cedd06 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json @@ -224,6 +224,57 @@ "expected_sql_file": "alter_function_add_acl.sql", "expected_msql_file": "alter_function_add_acl.msql" }, + { + "type": "alter", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, { "type": "alter", "name": "Alter function add acl.", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json index dc9a44520..65e7a7d02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..a00d45f13 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json index bc1043b6c..22bf13586 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json @@ -226,7 +226,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json index 870f40003..ed8de0427 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..ec7db8e1d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) +RETURNS character varying + LANGUAGE 'plpgsql' + VOLATILE SECURITY DEFINER WINDOW + COST 100 + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json index 101eb587b..56cf4c8da 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json @@ -225,7 +225,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..a00d45f13 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,24 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; + + + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json index bc1043b6c..22bf13586 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json @@ -226,7 +226,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json index 46dd89cc4..b51bc23fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json @@ -77,6 +77,40 @@ "expected_sql_file": "alter_proc_opt.sql", "expected_msql_file": "alter_proc_opt_msql.sql" }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, { "type": "delete", "name": "Drop procedure", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql index 2d42249b5..85dce035e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql @@ -84,7 +84,11 @@ COMMENT ON SEQUENCE {{ seqname }} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'SEQUENCE', priv.old_grantee, data.name, schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'SEQUENCE', priv.grantee, data.name, schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'SEQUENCE', priv.grantee, data.name, priv.without_grant, priv.with_grant, schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql new file mode 100644 index 000000000..480ba796b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql @@ -0,0 +1,19 @@ +-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/# + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 5 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; + +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql new file mode 100644 index 000000000..c8347516d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql index b392b3e31..78122be35 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql @@ -15,5 +15,3 @@ ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" IS 'Some comment'; - -GRANT ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json index 9687cf838..0995825ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json @@ -93,7 +93,51 @@ }, "expected_sql_file": "alter_seq_privs_update.sql", "expected_msql_file": "alter_seq_privs_update_msql.sql" - },{ + }, + { + "type": "alter", + "name": "Alter Sequence remove partial privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "deleted":[{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + } + }, + { + "type": "alter", + "name": "Alter Sequence change grantee in privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "changed":[{ + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_seq_change_grantee_privs.sql", + "expected_msql_file": "alter_seq_change_grantee_privs_msql.sql" + }, + { "type": "alter", "name": "Alter Sequence remove privileges", "endpoint": "NODE-sequence.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql new file mode 100644 index 000000000..b244d560e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql @@ -0,0 +1,19 @@ +-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/# + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 5 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; + +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql new file mode 100644 index 000000000..9ef112361 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql index ac21e667f..bc59956a6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql @@ -15,5 +15,3 @@ ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" IS 'Some comment'; - -GRANT ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json index 1639aac04..cafaa9252 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json @@ -93,7 +93,51 @@ }, "expected_sql_file": "alter_seq_privs_update.sql", "expected_msql_file": "alter_seq_privs_update_msql.sql" - },{ + }, + { + "type": "alter", + "name": "Alter Sequence remove partial privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "deleted":[{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + } + }, + { + "type": "alter", + "name": "Alter Sequence change grantee in privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "changed":[{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_seq_change_grantee_privs.sql", + "expected_msql_file": "alter_seq_change_grantee_privs_msql.sql" + }, + { "type": "alter", "name": "Alter Sequence remove privileges", "endpoint": "NODE-sequence.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..63674778f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..d44b1970b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json similarity index 93% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json index 0cdab1700..854d375ce 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json @@ -80,6 +80,40 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", + "attacl": { + "changed": [ + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..a72953989 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..a1c149f01 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json similarity index 96% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json index 98d701fda..29158ff32 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json @@ -51,6 +51,20 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"postgres", "grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql new file mode 100644 index 000000000..24fa69019 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql new file mode 100644 index 000000000..231d5ae9e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json similarity index 90% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json index 545aa3706..dad747fe1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json @@ -51,6 +51,20 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"postgres", "grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..7f5387c51 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..ecae7324d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql new file mode 100644 index 000000000..0d70893d5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql new file mode 100644 index 000000000..335d4b88e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql new file mode 100644 index 000000000..78b103c06 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..6749d14e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql new file mode 100644 index 000000000..4184c8168 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..e4828088b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql new file mode 100644 index 000000000..8a8e36b24 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql new file mode 100644 index 000000000..7d78c948d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql new file mode 100644 index 000000000..7a46497d9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql @@ -0,0 +1,8 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_5_$%{}[]()&*^!@""'`\/#" TO "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 2 SET MINVALUE 1 SET MAXVALUE 200 SET CACHE 2; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..560d2b978 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql new file mode 100644 index 000000000..6eede13ba --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 3 RESTART SET START 3 SET MINVALUE 3 SET MAXVALUE 30 SET CACHE 3; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql new file mode 100644 index 000000000..5aecdbec8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 3 START 3 MINVALUE 3 MAXVALUE 30 CACHE 3 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..402c270cf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET GENERATED ALWAYS SET NO CYCLE RESTART SET START 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..79cba6ad2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 2 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql new file mode 100644 index 000000000..adc24fd74 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql new file mode 100644 index 000000000..515f2cdc0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql new file mode 100644 index 000000000..c9362ce46 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql new file mode 100644 index 000000000..95817ad62 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql new file mode 100644 index 000000000..d4caec80e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql new file mode 100644 index 000000000..5506f2974 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql new file mode 100644 index 000000000..d0592b96b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql new file mode 100644 index 000000000..0f7e099f9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..4a39d912a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..987bd6106 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql new file mode 100644 index 000000000..9314e01b8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql new file mode 100644 index 000000000..61e7b4452 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql new file mode 100644 index 000000000..ad0bbd759 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql new file mode 100644 index 000000000..063b3c675 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql new file mode 100644 index 000000000..7bd916040 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..1aa62031e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql new file mode 100644 index 000000000..b80516f26 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql new file mode 100644 index 000000000..487567ade --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json new file mode 100644 index 000000000..968c0b551 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json @@ -0,0 +1,531 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.10+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_2_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "defval": "1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype": "real", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enteprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", + "attacl": { + "changed": [ + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": "50", + "attprecision": null, + "attoptions": [], + "seclabels": [], + "defval": null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype": "character", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "attidentity": "a", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "99999", + "seqcache": "10", + "seqcycle": true, + "colconstype": "i" + }, + "expected_sql_file": "create_column_int_identity.sql", + "expected_msql_file": "create_column_int_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_identity.sql", + "expected_msql_file": "alter_column_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql", + "expected_msql_file": "alter_column_drop_identity.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val": 0, + "max_val": 1000, + "cltype": "numeric", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": "10", + "attprecision": "5", + "attidentity": "a", + "attoptions": [ + { + "name": "n_distinct", + "value": "1" + } + ], + "seclabels": [] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "attnum": 4, + "attlen": "15", + "attprecision": "6", + "description": "Comment for alter", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen": "" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "99999", + "seqcache": "10", + "seqcycle": true, + "colconstype": "i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql", + "expected_msql_file": "create_column_int_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 5, + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement": "2", + "seqmax": "200", + "seqcache": "2", + "seqcycle": true, + "seqmin": "1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql", + "expected_msql_file": "alter_column_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 5, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql", + "expected_msql_file": "alter_column_drop_identity_by_default.msql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#", + "cltype": "bigint", + "attacl": [], + "description": "demo comments", + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "10", + "seqcache": "1", + "seqcycle": true, + "colconstype": "i", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_identity_for_restart_seq.sql", + "expected_msql_file": "create_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnotnull": true, + "attidentity": "a", + "seqstart": 2, + "seqcycle": false + }, + "expected_sql_file": "alter_column_identity_for_restart_seq.sql", + "expected_msql_file": "alter_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (ALWAYS) for combination of identity options & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "attidentity": "a", + "seqincrement": "3", + "seqstart": "3", + "seqmin": "3", + "seqmax": "30", + "seqcache": "3", + "seqcycle": true + }, + "expected_sql_file": "alter_column_identity_for_comb_start_seq.sql", + "expected_msql_file": "alter_column_identity_for_comb_start_seq.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..09425ce5c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..e6007db13 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql new file mode 100644 index 000000000..1ac157462 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql new file mode 100644 index 000000000..e55b117dc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql new file mode 100644 index 000000000..c345ba0a6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..ccd89d803 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql new file mode 100644 index 000000000..ade6c7e9f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..c23442003 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql new file mode 100644 index 000000000..41086ab1e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_4_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_4_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql new file mode 100644 index 000000000..e49bebfaf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_4_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_4_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql new file mode 100644 index 000000000..6b76b70de --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_8_$%{}[]()&*^!@""'`\/#" TO "new_col_8_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_8_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_8_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_8_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql new file mode 100644 index 000000000..4f96cd527 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_8_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_8_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_8_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql new file mode 100644 index 000000000..119556dc4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql new file mode 100644 index 000000000..e0fbb91c9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql new file mode 100644 index 000000000..6c00ace62 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql @@ -0,0 +1,8 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_9_$%{}[]()&*^!@""'`\/#" TO "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 2 SET MINVALUE 1 SET MAXVALUE 200 SET CACHE 2; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..a16cc8721 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql new file mode 100644 index 000000000..ad78f916e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 3 RESTART SET START 3 SET MINVALUE 3 SET MAXVALUE 30 SET CACHE 3; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql new file mode 100644 index 000000000..55c46ed20 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 3 START 3 MINVALUE 3 MAXVALUE 30 CACHE 3 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..603dcec8e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET GENERATED ALWAYS SET NO CYCLE RESTART SET START 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..75589761f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 2 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql new file mode 100644 index 000000000..0f2c754bc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql new file mode 100644 index 000000000..e7e818ef1 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql new file mode 100644 index 000000000..49aa6e672 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_5_$%{}[]()&*^!@""'`\/#" TO "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql new file mode 100644 index 000000000..c34bfc7fc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql new file mode 100644 index 000000000..41cb2a646 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql new file mode 100644 index 000000000..686ebf3c3 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql new file mode 100644 index 000000000..11ad3f86b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql new file mode 100644 index 000000000..5b4cd4a4d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..897636899 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..6c827598b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql new file mode 100644 index 000000000..925ea8c8f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql new file mode 100644 index 000000000..39e8868da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql new file mode 100644 index 000000000..22cee135b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" bigint(None, None) GENERATED ALWAYS AS (1 + 2 + 3) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql new file mode 100644 index 000000000..e06070efb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql new file mode 100644 index 000000000..95ab88727 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_8_$%{}[]()&*^!@""'`\/#" bigint(None, None) GENERATED ALWAYS AS (dummy1 + dummy2) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql new file mode 100644 index 000000000..ae40c07c4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql new file mode 100644 index 000000000..34581f0a5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql new file mode 100644 index 000000000..da3867660 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql new file mode 100644 index 000000000..dcc5e7879 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_9_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..bdc3795da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql new file mode 100644 index 000000000..0f7944bc0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql new file mode 100644 index 000000000..73f49eebf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json new file mode 100644 index 000000000..69983090e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json @@ -0,0 +1,539 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.12+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_3_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"enterprisedb", "grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"a", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity.sql", + "expected_msql_file": "create_column_int_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_identity.sql", + "expected_msql_file": "alter_column_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql", + "expected_msql_file": "alter_column_drop_identity.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"1 + 2 + 3", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated.sql", + "expected_msql_file": "create_column_int_generated.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 4, + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated.sql", + "expected_msql_file": "alter_column_generated.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "attnum": 5, + "attlen":"15", + "attprecision":"6", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen":"" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "dummy1", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "dummy2", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_8_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"dummy1 + dummy2", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated_with_existing_columns.sql", + "expected_msql_file": "create_column_int_generated_with_existing_columns.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 8, + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#", + "genexpr":"dummy1 - dummy2", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated_with_existing_columns.sql", + "expected_msql_file": "alter_column_generated_with_existing_columns.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"d", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql", + "expected_msql_file": "create_column_int_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement":"2", + "seqmax":"200", + "seqcache":"2", + "seqcycle":true, + "seqmin":"1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql", + "expected_msql_file": "alter_column_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql", + "expected_msql_file": "alter_column_drop_identity_by_default.msql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#", + "cltype": "bigint", + "attacl": [], + "description": "demo comments", + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "10", + "seqcache": "1", + "seqcycle": true, + "colconstype": "i", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_identity_for_restart_seq.sql", + "expected_msql_file": "create_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnotnull": true, + "attidentity": "a", + "seqstart": 2, + "seqcycle": false + }, + "expected_sql_file": "alter_column_identity_for_restart_seq.sql", + "expected_msql_file": "alter_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (ALWAYS) for combination of identity options & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "attidentity": "a", + "seqincrement": "3", + "seqstart": "3", + "seqmin": "3", + "seqmax": "30", + "seqcache": "3", + "seqcycle": true + }, + "expected_sql_file": "alter_column_identity_for_comb_start_seq.sql", + "expected_msql_file": "alter_column_identity_for_comb_start_seq.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql new file mode 100644 index 000000000..08de11032 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql new file mode 100644 index 000000000..c3bf26b83 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql new file mode 100644 index 000000000..7496276fb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql new file mode 100644 index 000000000..30a97ca40 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql new file mode 100644 index 000000000..bfd079ae8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql new file mode 100644 index 000000000..d96d1a1d0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql new file mode 100644 index 000000000..d1313822b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql new file mode 100644 index 000000000..f115459d4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql new file mode 100644 index 000000000..07891245e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql new file mode 100644 index 000000000..7a7445b66 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql new file mode 100644 index 000000000..f43e84a8e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql new file mode 100644 index 000000000..c5c3e10bf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql new file mode 100644 index 000000000..bde4012ff --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql new file mode 100644 index 000000000..b7c693539 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql new file mode 100644 index 000000000..b5eb2cfcd --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql new file mode 100644 index 000000000..68c7fb52a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json new file mode 100644 index 000000000..1cced1226 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json @@ -0,0 +1,193 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (Ver.default)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_1_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"enterprisedb", "grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "attnum": 3, + "attlen":"15", + "attprecision":"6", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen":"" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql index 259a2ca9d..e698ed3b8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql @@ -147,11 +147,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql index d39f8b6b9..8ca34d2cb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql @@ -107,11 +107,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql index 5d99eb66d..05702cc57 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql @@ -104,11 +104,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql index 35d769269..e9f7c6211 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql @@ -247,7 +247,11 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql index c2e61535f..c0da37b11 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql @@ -240,7 +240,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql index 28f25e925..49a8aa3b3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql @@ -236,7 +236,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql index ef0ec4e23..9c4b576ee 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql @@ -224,7 +224,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql index 47f6e1346..5bb1cdf02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql @@ -28,7 +28,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -51,7 +55,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in acl %} {% for priv in acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql index 64baa0358..495aaa538 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql @@ -28,7 +28,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -51,7 +55,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in acl %} {% for priv in acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql index 9f0a849c5..2535732fe 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql @@ -50,7 +50,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -70,7 +74,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.deftblacl %} {% for priv in data.deftblacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql index a324937bb..55b8afbca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql @@ -50,7 +50,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -70,7 +74,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.deftblacl %} {% for priv in data.deftblacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql index f9cee50b8..e42962c22 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql @@ -8,7 +8,7 @@ CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" -GRANT SELECT, UPDATE ON TABLES TO PUBLIC; +GRANT SELECT ON TABLES TO PUBLIC; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT EXECUTE ON FUNCTIONS TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql new file mode 100644 index 000000000..c8fc71a74 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql @@ -0,0 +1,22 @@ +-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/# + +-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ; + +CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + AUTHORIZATION postgres; + +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT EXECUTE ON FUNCTIONS TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT USAGE ON TYPES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql new file mode 100644 index 000000000..5f67cc02a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql @@ -0,0 +1,12 @@ +REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC; +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON TABLES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON SEQUENCES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json index 62fb3c771..85c0d6af1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json @@ -213,6 +213,49 @@ }, "expected_sql_file": "alter_schema_add_priv.sql", "expected_msql_file": "alter_schema_add_priv_msql.sql" + }, { + "type": "alter", + "name": "Alert Schema Update Privileges", + "endpoint": "NODE-schema.obj_id", + "sql_endpoint": "NODE-schema.sql_id", + "msql_endpoint": "NODE-schema.msql_id", + "data": { + "nspacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "U", + "privilege": true, + "with_grant": false + }] + }] + }, + "deftblacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + }, + "defseqacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "w", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_schema_update_priv.sql", + "expected_msql_file": "alter_schema_update_priv_msql.sql" }, { "type": "alter", "name": "Alert Schema Drop Privileges", @@ -260,7 +303,8 @@ }, "expected_sql_file": "alter_schema_drop_priv.sql", "expected_msql_file": "alter_schema_drop_priv_msql.sql" - }, { + }, + { "type": "delete", "name": "Drop Schema", "endpoint": "NODE-schema.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql index 4dbbf07e6..a18430f2b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql @@ -8,7 +8,7 @@ CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" -GRANT SELECT, UPDATE ON TABLES TO PUBLIC; +GRANT SELECT ON TABLES TO PUBLIC; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT EXECUTE ON FUNCTIONS TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql new file mode 100644 index 000000000..e200bff39 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql @@ -0,0 +1,22 @@ +-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/# + +-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ; + +CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + AUTHORIZATION enterprisedb; + +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT EXECUTE ON FUNCTIONS TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT USAGE ON TYPES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql new file mode 100644 index 000000000..bbc594d03 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql @@ -0,0 +1,14 @@ +REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC; +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON TABLES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON SEQUENCES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json index b3d23b60f..4d4a3d925 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json @@ -213,6 +213,49 @@ }, "expected_sql_file": "alter_schema_add_priv.sql", "expected_msql_file": "alter_schema_add_priv_msql.sql" + }, { + "type": "alter", + "name": "Alert Schema Update Privileges", + "endpoint": "NODE-schema.obj_id", + "sql_endpoint": "NODE-schema.sql_id", + "msql_endpoint": "NODE-schema.msql_id", + "data": { + "nspacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "U", + "privilege": true, + "with_grant": false + }] + }] + }, + "deftblacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + }, + "defseqacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "w", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_schema_update_priv.sql", + "expected_msql_file": "alter_schema_update_priv_msql.sql" }, { "type": "alter", "name": "Alert Schema Drop Privileges", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql index bd589f378..036ea2a11 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql @@ -129,7 +129,11 @@ ALTER TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }} {% endif %} {% if 'changed' in data.typacl %} {% for priv in data.typacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.old_grantee, o_data.name, o_data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.grantee, o_data.name, o_data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TYPE', priv.grantee, o_data.name, priv.without_grant, priv.with_grant, o_data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql new file mode 100644 index 000000000..5977dd022 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql @@ -0,0 +1,17 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql new file mode 100644 index 000000000..17587974f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" FROM <OWNER>; +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type_one_field.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type_one_field.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type_one_field.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type_one_field.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json similarity index 84% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json index 8b19e9024..f44f970d3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json @@ -222,6 +222,57 @@ "expected_sql_file": "alter_range_type_acl_description.sql", "expected_msql_file": "alter_range_type_acl_description.msql" }, + { + "type": "alter", + "name": "alter ACL (Remove privilege)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "alter ACL (change grantee)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_acl_grantee_change.sql", + "expected_msql_file": "alter_acl_grantee_change_msql.sql" + }, { "type": "delete", "name": "Drop RANGE type", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql new file mode 100644 index 000000000..f3a429ea2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql @@ -0,0 +1,17 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql new file mode 100644 index 000000000..4e21680e0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql new file mode 100644 index 000000000..32b0f674e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql new file mode 100644 index 000000000..4769bf1db --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql @@ -0,0 +1,20 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql new file mode 100644 index 000000000..6e6946f18 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + ADD ATTRIBUTE mname4 bigint; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql new file mode 100644 index 000000000..b864240c0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql @@ -0,0 +1,14 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql new file mode 100644 index 000000000..aafc63f4b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + DROP ATTRIBUTE mname1; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql new file mode 100644 index 000000000..013245dac --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql @@ -0,0 +1,13 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql new file mode 100644 index 000000000..4c7de8707 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql new file mode 100644 index 000000000..e114d0cfa --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql @@ -0,0 +1,16 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c', 'd'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql new file mode 100644 index 000000000..97949e79c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + ADD VALUE 'd' AFTER 'c'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql new file mode 100644 index 000000000..1a7a15307 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql @@ -0,0 +1,9 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c', 'd'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql new file mode 100644 index 000000000..c58b5eabb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql new file mode 100644 index 000000000..496f8422f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql @@ -0,0 +1,19 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql new file mode 100644 index 000000000..851cb6116 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql @@ -0,0 +1,2 @@ +COMMENT ON TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql new file mode 100644 index 000000000..3f78bfd29 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql @@ -0,0 +1,11 @@ +-- Type: shell_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +ALTER TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql new file mode 100644 index 000000000..089682b76 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql @@ -0,0 +1,6 @@ +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C" +); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql new file mode 100644 index 000000000..d48f7053d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql @@ -0,0 +1,13 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C" +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql new file mode 100644 index 000000000..16d5758bb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql @@ -0,0 +1,11 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql new file mode 100644 index 000000000..ecf7a2f6d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql @@ -0,0 +1,2 @@ +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c'); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql new file mode 100644 index 000000000..ebccea875 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql @@ -0,0 +1,9 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql new file mode 100644 index 000000000..e8a2d71fd --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql @@ -0,0 +1,4 @@ +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool +); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql new file mode 100644 index 000000000..be9c1a752 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql @@ -0,0 +1,12 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql new file mode 100644 index 000000000..bfab7af85 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql @@ -0,0 +1 @@ +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql new file mode 100644 index 000000000..126f2b7ff --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql @@ -0,0 +1,8 @@ +-- Type: shell_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +ALTER TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json new file mode 100644 index 000000000..cc662721e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json @@ -0,0 +1,284 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create ENUM type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "enum_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"e", + "schema":"public", + "composite":[], + "enum":[{"label":"a"},{"label":"b"},{"label":"c"}], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_enum_type.sql", + "expected_msql_file": "create_enum_type.msql" + }, + { + "type": "alter", + "name": "alter ENUM type and add new label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "enum": {"added": [{"label": "d"}]} + }, + "expected_sql_file": "alter_enum_type_label.sql", + "expected_msql_file": "alter_enum_type_label.msql" + }, + { + "type": "alter", + "name": "alter ENUM type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_enum_type_acl_description.sql", + "expected_msql_file": "alter_enum_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop ENUM type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + + { + "type": "create", + "name": "Create Composite type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "composite_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"c", + "schema":"public", + "composite":[ + {"member_name":"mname1","type":"bigint","is_tlength":false,"is_precision":false}, + {"member_name":"mname2","type":"character varying","tlength":50,"is_tlength":true,"is_precision":false,"collation":"pg_catalog.\"C\"","min_val":1,"max_val":2147483647,"collspcname":""}, + {"member_name":"mname3","type":"text[]","is_tlength":false,"is_precision":false,"collation":"pg_catalog.\"C\"","collspcname":""} + ], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_composite_type.sql", + "expected_msql_file": "create_composite_type.msql" + }, + { + "type": "alter", + "name": "alter Composite type and add new label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "composite": {"added": [{"member_name":"mname4","type":"bigint","is_tlength":false,"is_precision":false}]} + }, + "expected_sql_file": "alter_composite_type_add_member.sql", + "expected_msql_file": "alter_composite_type_add_member.msql" + }, + { + "type": "alter", + "name": "alter Composite type and delete label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "composite": {"deleted":[{"attnum":1,"member_name":"mname1","type":"bigint","tlength":null,"is_tlength":false,"precision":null,"is_precision":false,"collation":"","cltype":"bigint","hasSqrBracket":false,"fulltype":"bigint"}]} + }, + "expected_sql_file": "alter_composite_type_remove_member.sql", + "expected_msql_file": "alter_composite_type_remove_member.msql" + }, + { + "type": "alter", + "name": "alter Composite type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_composite_type_acl_description.sql", + "expected_msql_file": "alter_composite_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop Composite type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + { + "type": "create", + "name": "Create Composite type - one field", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "data": { + "name": "composite_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"c", + "schema":"public", + "composite":[ + {"member_name":"mname1","type":"bigint","is_tlength":false,"is_precision":false} + ], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_composite_type_one_field.sql" + }, + { + "type": "delete", + "name": "Drop Composite type - one field", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + { + "type": "create", + "name": "Create SHELL type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "shell_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"p", + "schema":"public", + "composite":[], + "enum":[], + "typacl":[], + "seclabels":[] + }, + "expected_sql_file": "create_shell_type.sql", + "expected_msql_file": "create_shell_type.msql" + }, + { + "type": "alter", + "name": "alter SHELL type and add description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test" + }, + "expected_sql_file": "alter_shell_type_acl_description.sql", + "expected_msql_file": "alter_shell_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop SHELL type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + + { + "type": "create", + "name": "Create RANGE type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "range_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"r", + "schema":"public", + "composite":[], + "enum":[], + "typacl":[], + "seclabels":[], + "typname":"bool" + }, + "expected_sql_file": "create_range_type.sql", + "expected_msql_file": "create_range_type.msql" + }, + { + "type": "alter", + "name": "alter RANGE type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_range_type_acl_description.sql", + "expected_msql_file": "alter_range_type_acl_description.msql" + }, + { + "type": "alter", + "name": "alter ACL (Remove privilege)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "alter ACL (change grantee)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_acl_grantee_change.sql", + "expected_msql_file": "alter_acl_grantee_change_msql.sql" + }, + { + "type": "delete", + "name": "Drop RANGE type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql index 291b7760a..ee8072484 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql @@ -35,7 +35,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql index d49f7fb9f..00a1329f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql index d49f7fb9f..00a1329f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql index 17c3a5f68..c3558a6fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql @@ -60,7 +60,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql index 17c3a5f68..c3558a6fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql @@ -60,7 +60,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql new file mode 100644 index 000000000..d15b0e6b6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql @@ -0,0 +1,17 @@ +-- View: public.testmview_$%{}[]()&*^!/@`# + +-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"; + +CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" +TABLESPACE pg_default +AS + SELECT 1 +WITH NO DATA; + +ALTER TABLE public."testmview_$%{}[]()&*^!/@`#" + OWNER TO postgres; + +COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" + IS 'comment1'; + +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql new file mode 100644 index 000000000..7e7a5ae53 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" FROM postgres; +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql index b3b83cd0d..09f1e9dfb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql @@ -15,4 +15,3 @@ ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" IS 'Testcomment-updated'; -GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..8165dd5a8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql new file mode 100644 index 000000000..53d6a9071 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json index 29ff3e27f..fea2f469b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json @@ -131,6 +131,63 @@ "expected_sql_file": "alter_mview_drop_all_priv.sql", "expected_msql_file": "alter_mview_drop_all_priv_msql.sql" }, + { + "type": "alter", + "name": "Alter Materialised Views (change grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "d", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "D", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "t", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_mview_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_priv_msql.sql" + }, { "type": "alter", "name": "Alter Materialised Views (change definition)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json index 14e121653..fb185dfe3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json @@ -32,7 +32,7 @@ "check_option": "local", "security_barrier": false, "comment":"Testcomment", - "datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, + "datacl":[{"grantee":"postgres", "old_grantee": "postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, "with_grant":false}]}] }, "expected_sql_file": "create_view.sql", @@ -51,7 +51,7 @@ "check_option": "cascaded", "security_barrier": true, "comment":"Testcomment-updated", - "datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, + "datacl":[{"grantee":"postgres", "grantor":"postgres", "old_grantee": "postgres", "privileges":[{"privilege_type": "a", "privilege": true, "with_grant":false}]}] }, "expected_sql_file": "alter_view.sql", @@ -101,7 +101,72 @@ "expected_sql_file": "alter_view_add_some_priv.sql", "expected_msql_file": "alter_view_add_some_priv_msql.sql" }, - { + { + "type": "alter", + "name": "Alter View (deleting privileges (PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (postgres to PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "old_grantee": "postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_priv_msql.sql" + }, + { "type": "alter", "name": "Alter View (deleting privileges)", "endpoint": "NODE-view.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql new file mode 100644 index 000000000..b55277594 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql @@ -0,0 +1,17 @@ +-- View: public.testmview_$%{}[]()&*^!/@`# + +-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"; + +CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" +TABLESPACE pg_default +AS + SELECT 1 +WITH NO DATA; + +ALTER TABLE public."testmview_$%{}[]()&*^!/@`#" + OWNER TO enterprisedb; + +COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" + IS 'comment1'; + +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql new file mode 100644 index 000000000..af097c577 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" FROM enterprisedb; +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql index d267e529c..fbd46ee55 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql @@ -14,5 +14,3 @@ ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" OWNER TO enterprisedb; COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" IS 'Testcomment-updated'; - -GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..3db18ba28 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql new file mode 100644 index 000000000..be69754a6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json index 33d0f9ba7..d0586836c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json @@ -131,6 +131,63 @@ "expected_sql_file": "alter_mview_drop_all_priv.sql", "expected_msql_file": "alter_mview_drop_all_priv_msql.sql" }, + { + "type": "alter", + "name": "Alter Materialised Views (change grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "d", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "D", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "t", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_mview_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_priv_msql.sql" + }, { "type": "alter", "name": "Alter Materialised Views (change definition)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json index f76190c2b..7e311ed96 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json @@ -82,6 +82,71 @@ }, "expected_sql_file": "alter_view_add_some_priv.sql", "expected_msql_file": "alter_view_add_some_priv_msql.sql" + }, + { + "type": "alter", + "name": "Alter View (deleting privileges (PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "enterprisedb", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (enterprisedb to PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "enterprisedb", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "old_grantee": "enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_priv_msql.sql" }, { "type": "alter", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json index 413c284dc..9dace550b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json @@ -999,6 +999,7 @@ { "grantee": "PUBLIC", "grantor": "postgres", + "old_grantee": "postgres", "privileges": [ { "privilege_type": "a", diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js index 9a0e419e6..a971f5ffe 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js @@ -259,11 +259,20 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', } }); - return { + let data = { 'grantee': this.get('grantee'), 'grantor': this.get('grantor'), 'privileges': privileges, }; + + if (!_.isUndefined(this._previousAttributes['grantee'])) { + data['old_grantee'] = this._previousAttributes['grantee']; + } + else { + data['old_grantee'] = this.get('grantee'); + } + + return data; }, validate: function() { @@ -429,7 +438,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', $tbl = $tr.closest('table'), collection = this.model.get('privileges'), grantee = this.model.get('grantee'), $allGrants, - $allPrivileges, $elGrant; + $allPrivileges, $elGrant, $allPrivilegesCheckBox, $allGrantCheckBox; this.undelegateEvents(); /* @@ -469,7 +478,6 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', $allGrants.prop('disabled', false); $elGrant.prop('disabled', false); } - } else { /* * ALL checkbox has been deselected, hence - we need to make @@ -497,16 +505,20 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', allWithGrant = checked; $allGrants.prop('checked', checked); } - /* * Set the values for each Privilege Model. */ - collection.each(function(m) { - m.set( - {'privilege': allPrivilege, 'with_grant': allWithGrant}, - {silent: true} - ); - }); + for (let x = 0; x < collection.length; x++) { + let c = collection.at(x).toJSON(); + c['privilege'] = allPrivilege; + c['with_grant'] = c['with_grant'] ? c['with_grant'] : allWithGrant; + let m = _.extend({}, c); + + // collection.get(privilege_type).set(...) does not trigger the model change event, due to which change of privilege does not occur + // so to trigger the event, manually removing/adding the same model with updated attributes on same index. + collection.remove(c); + collection.add(m, {at: x, remove: false, merge: false}); + } } else { /* * Particular privilege has been selected/deselected, which can be @@ -539,7 +551,24 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', } else if (!checked) { $allGrants.prop('checked', false); } - collection.get(privilege_type).set(attrs, {silent: true}); + + let m = {}; + m['privilege_type'] = privilege_type; + m[type] = attrs[type]; + if (!_.isUndefined(attrs['with_grant'])) { + m['with_grant'] = attrs['with_grant']; + } + + let final_m = collection.get(privilege_type).toJSON(); + _.extend(final_m, m); + + let temp_m = collection.get(privilege_type); + let ind = collection.indexOf(temp_m); + + // collection.get(privilege_type).set(...) does not trigger the model change event, due to which change of privilege does not occur + // so to trigger the event, manually removing/adding the same model with updated attributes on same index. + collection.remove(temp_m); + collection.add(final_m, {at: ind, remove: false, merge: false}); if (checked) { $allPrivileges = $tbl.find( @@ -550,6 +579,8 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', $allPrivileges.length == collection.models.length) { $allPrivileges.prop('checked', true); + $allPrivilegesCheckBox = $tbl.find('input[name=privilege][privilege=\'ALL\']'); + $allPrivilegesCheckBox.prop('checked', true); if (type == 'with_grant') { $allGrants = $tbl.find( @@ -558,6 +589,9 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', if ($allGrants.length == collection.models.length) { $allGrants.prop('disabled', false); $allGrants.prop('checked', true); + + $allGrantCheckBox = $tbl.find('input[name=with_grant][privilege=\'ALL\']'); + $allGrantCheckBox.prop('checked', true); } } else if (grantee != 'PUBLIC') { $allGrants.prop('disabled', false); diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py index 6eb5f0eaa..e074ea735 100644 --- a/web/pgadmin/browser/server_groups/servers/utils.py +++ b/web/pgadmin/browser/server_groups/servers/utils.py @@ -125,12 +125,20 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]): priv_with_grant = ['ALL'] if len(priv_without_grant) == allowed_acls_len > 1: priv_without_grant = ['ALL'] + + grantee = driver.qtIdent(None, priv['grantee']) \ + if priv['grantee'] != 'PUBLIC' else 'PUBLIC' + + old_grantee = driver.qtIdent(None, priv['old_grantee']) \ + if 'old_grantee' in priv and priv['old_grantee'] != 'PUBLIC' \ + else grantee + # Appending and returning all ACL privileges.append({ - 'grantee': driver.qtIdent(None, priv['grantee']) - if priv['grantee'] != 'PUBLIC' else 'PUBLIC', + 'grantee': grantee, 'with_grant': priv_with_grant, - 'without_grant': priv_without_grant + 'without_grant': priv_without_grant, + 'old_grantee': old_grantee }) return privileges ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin] RM6117 Unable to update column level privileges from security tab. @ 2021-02-08 04:23 Aditya Toshniwal <[email protected]> parent: Rahul Shirsat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Aditya Toshniwal @ 2021-02-08 04:23 UTC (permalink / raw) To: Rahul Shirsat <[email protected]>; +Cc: pgadmin-hackers Hi Rahul, On Sat, Feb 6, 2021 at 1:25 AM Rahul Shirsat <[email protected]> wrote: > Hi Hackers, > > Please find the attached patch which resolves the issue of unable to > update column level privileges in the security tab. > > Additionally, when the user tries to change grantee, the sql wasn't > generating, this too issue is resolved. > > This security privilege issue is resolved for the following nodes: > > 1.) Tables (test cases are skipped as there are no resql test cases based > on pg & ppas) > 2.) Columns > 3.) Views > 4.) MViews > 5.) Types > 6.) Functions > 7.) Procedures > 8.) Trigger functions > 9.) Sequences > 10.) Schema > > P.S for committer : Warning of whitespaces after applying patch should be > ignored as it is a part of resql test case results. > Probably change the SQL generation logic to avoid the trailing whitespaces ? > > -- > *Rahul Shirsat* > Senior Software Engineer | EnterpriseDB Corporation. > -- Thanks, Aditya Toshniwal pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* <http://edbpostgres.com; "Don't Complain about Heat, Plant a TREE" ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin] RM6117 Unable to update column level privileges from security tab. @ 2021-02-08 09:58 Rahul Shirsat <[email protected]> parent: Aditya Toshniwal <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rahul Shirsat @ 2021-02-08 09:58 UTC (permalink / raw) To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers Akshay, Removed some whitespace warnings. While this new patch is applied there are still 2 unknown whitespace warnings which are pointing to the wrong location. Could you please let me know if this works? On Mon, Feb 8, 2021 at 9:53 AM Aditya Toshniwal < [email protected]> wrote: > Hi Rahul, > > On Sat, Feb 6, 2021 at 1:25 AM Rahul Shirsat < > [email protected]> wrote: > >> Hi Hackers, >> >> Please find the attached patch which resolves the issue of unable to >> update column level privileges in the security tab. >> >> Additionally, when the user tries to change grantee, the sql wasn't >> generating, this too issue is resolved. >> >> This security privilege issue is resolved for the following nodes: >> >> 1.) Tables (test cases are skipped as there are no resql test cases based >> on pg & ppas) >> 2.) Columns >> 3.) Views >> 4.) MViews >> 5.) Types >> 6.) Functions >> 7.) Procedures >> 8.) Trigger functions >> 9.) Sequences >> 10.) Schema >> >> P.S for committer : Warning of whitespaces after applying patch should be >> ignored as it is a part of resql test case results. >> > Probably change the SQL generation logic to avoid the trailing whitespaces > ? > >> >> -- >> *Rahul Shirsat* >> Senior Software Engineer | EnterpriseDB Corporation. >> > > > -- > Thanks, > Aditya Toshniwal > pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* > <http://edbpostgres.com; > "Don't Complain about Heat, Plant a TREE" > -- *Rahul Shirsat* Senior Software Engineer | EnterpriseDB Corporation. Attachments: [application/octet-stream] RM6117_v2.patch (374.1K, 3-RM6117_v2.patch) download | inline diff: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql index 5e8d357d7..6bc64af3c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql index 6b5772851..01c749ceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql @@ -60,10 +60,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql index 8c18299b4..745877342 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql @@ -59,7 +59,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql index 963a7f3be..ac13a7525 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql @@ -56,10 +56,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql index 1917283f9..916347e13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql index aad4b6612..0122a4f51 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql @@ -55,10 +55,12 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endfor %}{% endif %} {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} - +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} - {% endfor %}{% endif %} {% if 'added' in data.acl %} {% for priv in data.acl.added %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql index 6b5772851..01c749ceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql @@ -60,10 +60,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql index c9c76b82d..56ff2ad4b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql @@ -59,7 +59,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql index 963a7f3be..ac13a7525 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql @@ -56,10 +56,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql index 1917283f9..916347e13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql index f922abdc2..c2f160e22 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql @@ -47,10 +47,14 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql index 6e711724d..43836ca50 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql @@ -57,10 +57,14 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql index 65c766ca9..0b4ed30d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql @@ -45,7 +45,11 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {% if 'changed' in data.datacl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql index c1d7576e3..2030c917c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql @@ -48,7 +48,11 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {% if 'changed' in data.datacl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql index 124cbe93b..0f936f3ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql @@ -50,10 +50,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql index 92a625db0..212c5b0ba 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql @@ -53,7 +53,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql index 124cbe93b..0f936f3ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql @@ -50,10 +50,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql index ec71dee45..cd28330dc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql @@ -49,7 +49,12 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endfor %}{% endif %} {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} + +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..3e6120ff2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..67a549ead --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM postgres; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json index dc9a44520..cf0996aab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..3e6120ff2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..67a549ead --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM postgres; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json index dc9a44520..cf0996aab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..7c951711f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE WINDOW + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json index 34225e580..0ed3b29e4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json @@ -213,7 +213,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..3e6120ff2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4317e3d00 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json index bc1043b6c..e33cedd06 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json @@ -224,6 +224,57 @@ "expected_sql_file": "alter_function_add_acl.sql", "expected_msql_file": "alter_function_add_acl.msql" }, + { + "type": "alter", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, { "type": "alter", "name": "Alter function add acl.", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json index dc9a44520..65e7a7d02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4317e3d00 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json index bc1043b6c..22bf13586 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json @@ -226,7 +226,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json index 870f40003..ed8de0427 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4bddbe361 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) +RETURNS character varying + LANGUAGE 'plpgsql' + VOLATILE SECURITY DEFINER WINDOW + COST 100 + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json index 101eb587b..56cf4c8da 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json @@ -225,7 +225,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4317e3d00 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json index bc1043b6c..22bf13586 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json @@ -226,7 +226,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json index 46dd89cc4..b51bc23fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json @@ -77,6 +77,40 @@ "expected_sql_file": "alter_proc_opt.sql", "expected_msql_file": "alter_proc_opt_msql.sql" }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, { "type": "delete", "name": "Drop procedure", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql index 2d42249b5..85dce035e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql @@ -84,7 +84,11 @@ COMMENT ON SEQUENCE {{ seqname }} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'SEQUENCE', priv.old_grantee, data.name, schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'SEQUENCE', priv.grantee, data.name, schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'SEQUENCE', priv.grantee, data.name, priv.without_grant, priv.with_grant, schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql new file mode 100644 index 000000000..480ba796b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql @@ -0,0 +1,19 @@ +-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/# + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 5 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; + +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql new file mode 100644 index 000000000..c8347516d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql index b392b3e31..78122be35 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql @@ -15,5 +15,3 @@ ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" IS 'Some comment'; - -GRANT ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json index 9687cf838..0995825ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json @@ -93,7 +93,51 @@ }, "expected_sql_file": "alter_seq_privs_update.sql", "expected_msql_file": "alter_seq_privs_update_msql.sql" - },{ + }, + { + "type": "alter", + "name": "Alter Sequence remove partial privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "deleted":[{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + } + }, + { + "type": "alter", + "name": "Alter Sequence change grantee in privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "changed":[{ + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_seq_change_grantee_privs.sql", + "expected_msql_file": "alter_seq_change_grantee_privs_msql.sql" + }, + { "type": "alter", "name": "Alter Sequence remove privileges", "endpoint": "NODE-sequence.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql new file mode 100644 index 000000000..b244d560e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql @@ -0,0 +1,19 @@ +-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/# + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 5 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; + +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql new file mode 100644 index 000000000..9ef112361 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql index ac21e667f..bc59956a6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql @@ -15,5 +15,3 @@ ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" IS 'Some comment'; - -GRANT ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json index 1639aac04..cafaa9252 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json @@ -93,7 +93,51 @@ }, "expected_sql_file": "alter_seq_privs_update.sql", "expected_msql_file": "alter_seq_privs_update_msql.sql" - },{ + }, + { + "type": "alter", + "name": "Alter Sequence remove partial privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "deleted":[{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + } + }, + { + "type": "alter", + "name": "Alter Sequence change grantee in privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "changed":[{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_seq_change_grantee_privs.sql", + "expected_msql_file": "alter_seq_change_grantee_privs_msql.sql" + }, + { "type": "alter", "name": "Alter Sequence remove privileges", "endpoint": "NODE-sequence.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..63674778f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..d44b1970b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json similarity index 93% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json index 0cdab1700..854d375ce 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json @@ -80,6 +80,40 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", + "attacl": { + "changed": [ + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..a72953989 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..a1c149f01 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json similarity index 96% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json index 98d701fda..29158ff32 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json @@ -51,6 +51,20 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"postgres", "grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql new file mode 100644 index 000000000..24fa69019 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql new file mode 100644 index 000000000..231d5ae9e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json similarity index 90% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json index 545aa3706..dad747fe1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json @@ -51,6 +51,20 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"postgres", "grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..7f5387c51 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..ecae7324d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql new file mode 100644 index 000000000..0d70893d5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql new file mode 100644 index 000000000..335d4b88e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql new file mode 100644 index 000000000..78b103c06 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..6749d14e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql new file mode 100644 index 000000000..4184c8168 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..e4828088b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql new file mode 100644 index 000000000..8a8e36b24 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql new file mode 100644 index 000000000..7d78c948d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql new file mode 100644 index 000000000..7a46497d9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql @@ -0,0 +1,8 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_5_$%{}[]()&*^!@""'`\/#" TO "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 2 SET MINVALUE 1 SET MAXVALUE 200 SET CACHE 2; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..560d2b978 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql new file mode 100644 index 000000000..6eede13ba --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 3 RESTART SET START 3 SET MINVALUE 3 SET MAXVALUE 30 SET CACHE 3; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql new file mode 100644 index 000000000..5aecdbec8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 3 START 3 MINVALUE 3 MAXVALUE 30 CACHE 3 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..402c270cf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET GENERATED ALWAYS SET NO CYCLE RESTART SET START 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..79cba6ad2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 2 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql new file mode 100644 index 000000000..adc24fd74 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql new file mode 100644 index 000000000..515f2cdc0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql new file mode 100644 index 000000000..c9362ce46 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql new file mode 100644 index 000000000..95817ad62 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql new file mode 100644 index 000000000..d4caec80e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql new file mode 100644 index 000000000..5506f2974 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql new file mode 100644 index 000000000..d0592b96b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql new file mode 100644 index 000000000..0f7e099f9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..4a39d912a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..987bd6106 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql new file mode 100644 index 000000000..9314e01b8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql new file mode 100644 index 000000000..61e7b4452 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql new file mode 100644 index 000000000..ad0bbd759 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql new file mode 100644 index 000000000..063b3c675 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql new file mode 100644 index 000000000..7bd916040 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..1aa62031e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql new file mode 100644 index 000000000..b80516f26 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql new file mode 100644 index 000000000..487567ade --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json new file mode 100644 index 000000000..968c0b551 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json @@ -0,0 +1,531 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.10+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_2_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "defval": "1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype": "real", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enteprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", + "attacl": { + "changed": [ + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": "50", + "attprecision": null, + "attoptions": [], + "seclabels": [], + "defval": null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype": "character", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "attidentity": "a", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "99999", + "seqcache": "10", + "seqcycle": true, + "colconstype": "i" + }, + "expected_sql_file": "create_column_int_identity.sql", + "expected_msql_file": "create_column_int_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_identity.sql", + "expected_msql_file": "alter_column_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql", + "expected_msql_file": "alter_column_drop_identity.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val": 0, + "max_val": 1000, + "cltype": "numeric", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": "10", + "attprecision": "5", + "attidentity": "a", + "attoptions": [ + { + "name": "n_distinct", + "value": "1" + } + ], + "seclabels": [] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "attnum": 4, + "attlen": "15", + "attprecision": "6", + "description": "Comment for alter", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen": "" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "99999", + "seqcache": "10", + "seqcycle": true, + "colconstype": "i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql", + "expected_msql_file": "create_column_int_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 5, + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement": "2", + "seqmax": "200", + "seqcache": "2", + "seqcycle": true, + "seqmin": "1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql", + "expected_msql_file": "alter_column_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 5, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql", + "expected_msql_file": "alter_column_drop_identity_by_default.msql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#", + "cltype": "bigint", + "attacl": [], + "description": "demo comments", + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "10", + "seqcache": "1", + "seqcycle": true, + "colconstype": "i", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_identity_for_restart_seq.sql", + "expected_msql_file": "create_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnotnull": true, + "attidentity": "a", + "seqstart": 2, + "seqcycle": false + }, + "expected_sql_file": "alter_column_identity_for_restart_seq.sql", + "expected_msql_file": "alter_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (ALWAYS) for combination of identity options & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "attidentity": "a", + "seqincrement": "3", + "seqstart": "3", + "seqmin": "3", + "seqmax": "30", + "seqcache": "3", + "seqcycle": true + }, + "expected_sql_file": "alter_column_identity_for_comb_start_seq.sql", + "expected_msql_file": "alter_column_identity_for_comb_start_seq.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..09425ce5c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..e6007db13 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql new file mode 100644 index 000000000..1ac157462 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql new file mode 100644 index 000000000..e55b117dc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql new file mode 100644 index 000000000..c345ba0a6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..ccd89d803 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql new file mode 100644 index 000000000..ade6c7e9f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..c23442003 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql new file mode 100644 index 000000000..41086ab1e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_4_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_4_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql new file mode 100644 index 000000000..e49bebfaf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_4_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_4_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql new file mode 100644 index 000000000..6b76b70de --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_8_$%{}[]()&*^!@""'`\/#" TO "new_col_8_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_8_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_8_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_8_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql new file mode 100644 index 000000000..4f96cd527 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_8_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_8_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_8_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql new file mode 100644 index 000000000..119556dc4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql new file mode 100644 index 000000000..e0fbb91c9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql new file mode 100644 index 000000000..6c00ace62 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql @@ -0,0 +1,8 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_9_$%{}[]()&*^!@""'`\/#" TO "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 2 SET MINVALUE 1 SET MAXVALUE 200 SET CACHE 2; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..a16cc8721 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql new file mode 100644 index 000000000..ad78f916e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 3 RESTART SET START 3 SET MINVALUE 3 SET MAXVALUE 30 SET CACHE 3; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql new file mode 100644 index 000000000..55c46ed20 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 3 START 3 MINVALUE 3 MAXVALUE 30 CACHE 3 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..603dcec8e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET GENERATED ALWAYS SET NO CYCLE RESTART SET START 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..75589761f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 2 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql new file mode 100644 index 000000000..0f2c754bc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql new file mode 100644 index 000000000..e7e818ef1 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql new file mode 100644 index 000000000..49aa6e672 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_5_$%{}[]()&*^!@""'`\/#" TO "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql new file mode 100644 index 000000000..c34bfc7fc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql new file mode 100644 index 000000000..41cb2a646 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql new file mode 100644 index 000000000..686ebf3c3 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql new file mode 100644 index 000000000..11ad3f86b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql new file mode 100644 index 000000000..5b4cd4a4d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..897636899 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..6c827598b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql new file mode 100644 index 000000000..925ea8c8f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql new file mode 100644 index 000000000..39e8868da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql new file mode 100644 index 000000000..22cee135b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" bigint(None, None) GENERATED ALWAYS AS (1 + 2 + 3) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql new file mode 100644 index 000000000..e06070efb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql new file mode 100644 index 000000000..95ab88727 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_8_$%{}[]()&*^!@""'`\/#" bigint(None, None) GENERATED ALWAYS AS (dummy1 + dummy2) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql new file mode 100644 index 000000000..ae40c07c4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql new file mode 100644 index 000000000..34581f0a5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql new file mode 100644 index 000000000..da3867660 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql new file mode 100644 index 000000000..dcc5e7879 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_9_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..bdc3795da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql new file mode 100644 index 000000000..0f7944bc0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql new file mode 100644 index 000000000..73f49eebf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json new file mode 100644 index 000000000..69983090e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json @@ -0,0 +1,539 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.12+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_3_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"enterprisedb", "grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"a", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity.sql", + "expected_msql_file": "create_column_int_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_identity.sql", + "expected_msql_file": "alter_column_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql", + "expected_msql_file": "alter_column_drop_identity.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"1 + 2 + 3", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated.sql", + "expected_msql_file": "create_column_int_generated.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 4, + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated.sql", + "expected_msql_file": "alter_column_generated.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "attnum": 5, + "attlen":"15", + "attprecision":"6", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen":"" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "dummy1", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "dummy2", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_8_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"dummy1 + dummy2", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated_with_existing_columns.sql", + "expected_msql_file": "create_column_int_generated_with_existing_columns.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 8, + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#", + "genexpr":"dummy1 - dummy2", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated_with_existing_columns.sql", + "expected_msql_file": "alter_column_generated_with_existing_columns.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"d", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql", + "expected_msql_file": "create_column_int_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement":"2", + "seqmax":"200", + "seqcache":"2", + "seqcycle":true, + "seqmin":"1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql", + "expected_msql_file": "alter_column_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql", + "expected_msql_file": "alter_column_drop_identity_by_default.msql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#", + "cltype": "bigint", + "attacl": [], + "description": "demo comments", + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "10", + "seqcache": "1", + "seqcycle": true, + "colconstype": "i", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_identity_for_restart_seq.sql", + "expected_msql_file": "create_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnotnull": true, + "attidentity": "a", + "seqstart": 2, + "seqcycle": false + }, + "expected_sql_file": "alter_column_identity_for_restart_seq.sql", + "expected_msql_file": "alter_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (ALWAYS) for combination of identity options & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "attidentity": "a", + "seqincrement": "3", + "seqstart": "3", + "seqmin": "3", + "seqmax": "30", + "seqcache": "3", + "seqcycle": true + }, + "expected_sql_file": "alter_column_identity_for_comb_start_seq.sql", + "expected_msql_file": "alter_column_identity_for_comb_start_seq.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql new file mode 100644 index 000000000..08de11032 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql new file mode 100644 index 000000000..c3bf26b83 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql new file mode 100644 index 000000000..7496276fb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql new file mode 100644 index 000000000..30a97ca40 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql new file mode 100644 index 000000000..bfd079ae8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql new file mode 100644 index 000000000..d96d1a1d0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql new file mode 100644 index 000000000..d1313822b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql new file mode 100644 index 000000000..f115459d4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql new file mode 100644 index 000000000..07891245e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql new file mode 100644 index 000000000..7a7445b66 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql new file mode 100644 index 000000000..f43e84a8e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql new file mode 100644 index 000000000..c5c3e10bf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql new file mode 100644 index 000000000..bde4012ff --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql new file mode 100644 index 000000000..b7c693539 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql new file mode 100644 index 000000000..b5eb2cfcd --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql new file mode 100644 index 000000000..68c7fb52a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json new file mode 100644 index 000000000..1cced1226 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json @@ -0,0 +1,193 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (Ver.default)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_1_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"enterprisedb", "grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "attnum": 3, + "attlen":"15", + "attprecision":"6", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen":"" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql index 259a2ca9d..e698ed3b8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql @@ -147,11 +147,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql index d39f8b6b9..8ca34d2cb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql @@ -107,11 +107,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql index 5d99eb66d..05702cc57 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql @@ -104,11 +104,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql index 35d769269..e9f7c6211 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql @@ -247,7 +247,11 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql index c2e61535f..c0da37b11 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql @@ -240,7 +240,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql index 28f25e925..49a8aa3b3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql @@ -236,7 +236,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql index ef0ec4e23..9c4b576ee 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql @@ -224,7 +224,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql index 47f6e1346..5bb1cdf02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql @@ -28,7 +28,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -51,7 +55,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in acl %} {% for priv in acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql index 64baa0358..495aaa538 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql @@ -28,7 +28,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -51,7 +55,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in acl %} {% for priv in acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql index 9f0a849c5..2535732fe 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql @@ -50,7 +50,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -70,7 +74,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.deftblacl %} {% for priv in data.deftblacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql index a324937bb..55b8afbca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql @@ -50,7 +50,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -70,7 +74,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.deftblacl %} {% for priv in data.deftblacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql index f9cee50b8..e42962c22 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql @@ -8,7 +8,7 @@ CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" -GRANT SELECT, UPDATE ON TABLES TO PUBLIC; +GRANT SELECT ON TABLES TO PUBLIC; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT EXECUTE ON FUNCTIONS TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql new file mode 100644 index 000000000..c8fc71a74 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql @@ -0,0 +1,22 @@ +-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/# + +-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ; + +CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + AUTHORIZATION postgres; + +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT EXECUTE ON FUNCTIONS TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT USAGE ON TYPES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql new file mode 100644 index 000000000..5f67cc02a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql @@ -0,0 +1,12 @@ +REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC; +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON TABLES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON SEQUENCES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json index 62fb3c771..85c0d6af1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json @@ -213,6 +213,49 @@ }, "expected_sql_file": "alter_schema_add_priv.sql", "expected_msql_file": "alter_schema_add_priv_msql.sql" + }, { + "type": "alter", + "name": "Alert Schema Update Privileges", + "endpoint": "NODE-schema.obj_id", + "sql_endpoint": "NODE-schema.sql_id", + "msql_endpoint": "NODE-schema.msql_id", + "data": { + "nspacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "U", + "privilege": true, + "with_grant": false + }] + }] + }, + "deftblacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + }, + "defseqacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "w", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_schema_update_priv.sql", + "expected_msql_file": "alter_schema_update_priv_msql.sql" }, { "type": "alter", "name": "Alert Schema Drop Privileges", @@ -260,7 +303,8 @@ }, "expected_sql_file": "alter_schema_drop_priv.sql", "expected_msql_file": "alter_schema_drop_priv_msql.sql" - }, { + }, + { "type": "delete", "name": "Drop Schema", "endpoint": "NODE-schema.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql index 4dbbf07e6..a18430f2b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql @@ -8,7 +8,7 @@ CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" -GRANT SELECT, UPDATE ON TABLES TO PUBLIC; +GRANT SELECT ON TABLES TO PUBLIC; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT EXECUTE ON FUNCTIONS TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql new file mode 100644 index 000000000..e200bff39 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql @@ -0,0 +1,22 @@ +-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/# + +-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ; + +CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + AUTHORIZATION enterprisedb; + +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT EXECUTE ON FUNCTIONS TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT USAGE ON TYPES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql new file mode 100644 index 000000000..bbc594d03 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql @@ -0,0 +1,14 @@ +REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC; +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON TABLES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON SEQUENCES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json index b3d23b60f..4d4a3d925 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json @@ -213,6 +213,49 @@ }, "expected_sql_file": "alter_schema_add_priv.sql", "expected_msql_file": "alter_schema_add_priv_msql.sql" + }, { + "type": "alter", + "name": "Alert Schema Update Privileges", + "endpoint": "NODE-schema.obj_id", + "sql_endpoint": "NODE-schema.sql_id", + "msql_endpoint": "NODE-schema.msql_id", + "data": { + "nspacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "U", + "privilege": true, + "with_grant": false + }] + }] + }, + "deftblacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + }, + "defseqacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "w", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_schema_update_priv.sql", + "expected_msql_file": "alter_schema_update_priv_msql.sql" }, { "type": "alter", "name": "Alert Schema Drop Privileges", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql index bd589f378..036ea2a11 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql @@ -129,7 +129,11 @@ ALTER TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }} {% endif %} {% if 'changed' in data.typacl %} {% for priv in data.typacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.old_grantee, o_data.name, o_data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.grantee, o_data.name, o_data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TYPE', priv.grantee, o_data.name, priv.without_grant, priv.with_grant, o_data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql new file mode 100644 index 000000000..5977dd022 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql @@ -0,0 +1,17 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql new file mode 100644 index 000000000..17587974f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" FROM <OWNER>; +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type_one_field.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type_one_field.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type_one_field.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type_one_field.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json similarity index 84% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json index 8b19e9024..f44f970d3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json @@ -222,6 +222,57 @@ "expected_sql_file": "alter_range_type_acl_description.sql", "expected_msql_file": "alter_range_type_acl_description.msql" }, + { + "type": "alter", + "name": "alter ACL (Remove privilege)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "alter ACL (change grantee)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_acl_grantee_change.sql", + "expected_msql_file": "alter_acl_grantee_change_msql.sql" + }, { "type": "delete", "name": "Drop RANGE type", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql new file mode 100644 index 000000000..f3a429ea2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql @@ -0,0 +1,17 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql new file mode 100644 index 000000000..4e21680e0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql new file mode 100644 index 000000000..32b0f674e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql new file mode 100644 index 000000000..4769bf1db --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql @@ -0,0 +1,20 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql new file mode 100644 index 000000000..6e6946f18 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + ADD ATTRIBUTE mname4 bigint; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql new file mode 100644 index 000000000..b864240c0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql @@ -0,0 +1,14 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql new file mode 100644 index 000000000..aafc63f4b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + DROP ATTRIBUTE mname1; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql new file mode 100644 index 000000000..013245dac --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql @@ -0,0 +1,13 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql new file mode 100644 index 000000000..4c7de8707 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql new file mode 100644 index 000000000..e114d0cfa --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql @@ -0,0 +1,16 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c', 'd'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql new file mode 100644 index 000000000..97949e79c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + ADD VALUE 'd' AFTER 'c'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql new file mode 100644 index 000000000..1a7a15307 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql @@ -0,0 +1,9 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c', 'd'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql new file mode 100644 index 000000000..c58b5eabb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql new file mode 100644 index 000000000..496f8422f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql @@ -0,0 +1,19 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql new file mode 100644 index 000000000..851cb6116 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql @@ -0,0 +1,2 @@ +COMMENT ON TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql new file mode 100644 index 000000000..3f78bfd29 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql @@ -0,0 +1,11 @@ +-- Type: shell_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +ALTER TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql new file mode 100644 index 000000000..089682b76 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql @@ -0,0 +1,6 @@ +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C" +); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql new file mode 100644 index 000000000..d48f7053d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql @@ -0,0 +1,13 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C" +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql new file mode 100644 index 000000000..16d5758bb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql @@ -0,0 +1,11 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql new file mode 100644 index 000000000..ecf7a2f6d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql @@ -0,0 +1,2 @@ +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c'); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql new file mode 100644 index 000000000..ebccea875 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql @@ -0,0 +1,9 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql new file mode 100644 index 000000000..e8a2d71fd --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql @@ -0,0 +1,4 @@ +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool +); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql new file mode 100644 index 000000000..be9c1a752 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql @@ -0,0 +1,12 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql new file mode 100644 index 000000000..bfab7af85 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql @@ -0,0 +1 @@ +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql new file mode 100644 index 000000000..126f2b7ff --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql @@ -0,0 +1,8 @@ +-- Type: shell_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +ALTER TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json new file mode 100644 index 000000000..cc662721e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json @@ -0,0 +1,284 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create ENUM type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "enum_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"e", + "schema":"public", + "composite":[], + "enum":[{"label":"a"},{"label":"b"},{"label":"c"}], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_enum_type.sql", + "expected_msql_file": "create_enum_type.msql" + }, + { + "type": "alter", + "name": "alter ENUM type and add new label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "enum": {"added": [{"label": "d"}]} + }, + "expected_sql_file": "alter_enum_type_label.sql", + "expected_msql_file": "alter_enum_type_label.msql" + }, + { + "type": "alter", + "name": "alter ENUM type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_enum_type_acl_description.sql", + "expected_msql_file": "alter_enum_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop ENUM type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + + { + "type": "create", + "name": "Create Composite type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "composite_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"c", + "schema":"public", + "composite":[ + {"member_name":"mname1","type":"bigint","is_tlength":false,"is_precision":false}, + {"member_name":"mname2","type":"character varying","tlength":50,"is_tlength":true,"is_precision":false,"collation":"pg_catalog.\"C\"","min_val":1,"max_val":2147483647,"collspcname":""}, + {"member_name":"mname3","type":"text[]","is_tlength":false,"is_precision":false,"collation":"pg_catalog.\"C\"","collspcname":""} + ], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_composite_type.sql", + "expected_msql_file": "create_composite_type.msql" + }, + { + "type": "alter", + "name": "alter Composite type and add new label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "composite": {"added": [{"member_name":"mname4","type":"bigint","is_tlength":false,"is_precision":false}]} + }, + "expected_sql_file": "alter_composite_type_add_member.sql", + "expected_msql_file": "alter_composite_type_add_member.msql" + }, + { + "type": "alter", + "name": "alter Composite type and delete label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "composite": {"deleted":[{"attnum":1,"member_name":"mname1","type":"bigint","tlength":null,"is_tlength":false,"precision":null,"is_precision":false,"collation":"","cltype":"bigint","hasSqrBracket":false,"fulltype":"bigint"}]} + }, + "expected_sql_file": "alter_composite_type_remove_member.sql", + "expected_msql_file": "alter_composite_type_remove_member.msql" + }, + { + "type": "alter", + "name": "alter Composite type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_composite_type_acl_description.sql", + "expected_msql_file": "alter_composite_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop Composite type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + { + "type": "create", + "name": "Create Composite type - one field", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "data": { + "name": "composite_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"c", + "schema":"public", + "composite":[ + {"member_name":"mname1","type":"bigint","is_tlength":false,"is_precision":false} + ], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_composite_type_one_field.sql" + }, + { + "type": "delete", + "name": "Drop Composite type - one field", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + { + "type": "create", + "name": "Create SHELL type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "shell_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"p", + "schema":"public", + "composite":[], + "enum":[], + "typacl":[], + "seclabels":[] + }, + "expected_sql_file": "create_shell_type.sql", + "expected_msql_file": "create_shell_type.msql" + }, + { + "type": "alter", + "name": "alter SHELL type and add description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test" + }, + "expected_sql_file": "alter_shell_type_acl_description.sql", + "expected_msql_file": "alter_shell_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop SHELL type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + + { + "type": "create", + "name": "Create RANGE type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "range_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"r", + "schema":"public", + "composite":[], + "enum":[], + "typacl":[], + "seclabels":[], + "typname":"bool" + }, + "expected_sql_file": "create_range_type.sql", + "expected_msql_file": "create_range_type.msql" + }, + { + "type": "alter", + "name": "alter RANGE type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_range_type_acl_description.sql", + "expected_msql_file": "alter_range_type_acl_description.msql" + }, + { + "type": "alter", + "name": "alter ACL (Remove privilege)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "alter ACL (change grantee)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_acl_grantee_change.sql", + "expected_msql_file": "alter_acl_grantee_change_msql.sql" + }, + { + "type": "delete", + "name": "Drop RANGE type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql index 291b7760a..ee8072484 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql @@ -35,7 +35,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql index d49f7fb9f..00a1329f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql index d49f7fb9f..00a1329f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql index 17c3a5f68..c3558a6fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql @@ -60,7 +60,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql index 17c3a5f68..c3558a6fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql @@ -60,7 +60,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql new file mode 100644 index 000000000..d15b0e6b6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql @@ -0,0 +1,17 @@ +-- View: public.testmview_$%{}[]()&*^!/@`# + +-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"; + +CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" +TABLESPACE pg_default +AS + SELECT 1 +WITH NO DATA; + +ALTER TABLE public."testmview_$%{}[]()&*^!/@`#" + OWNER TO postgres; + +COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" + IS 'comment1'; + +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql new file mode 100644 index 000000000..7e7a5ae53 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" FROM postgres; +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql index b3b83cd0d..09f1e9dfb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql @@ -15,4 +15,3 @@ ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" IS 'Testcomment-updated'; -GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..8165dd5a8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql new file mode 100644 index 000000000..53d6a9071 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json index 29ff3e27f..fea2f469b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json @@ -131,6 +131,63 @@ "expected_sql_file": "alter_mview_drop_all_priv.sql", "expected_msql_file": "alter_mview_drop_all_priv_msql.sql" }, + { + "type": "alter", + "name": "Alter Materialised Views (change grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "d", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "D", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "t", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_mview_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_priv_msql.sql" + }, { "type": "alter", "name": "Alter Materialised Views (change definition)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json index 14e121653..fb185dfe3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json @@ -32,7 +32,7 @@ "check_option": "local", "security_barrier": false, "comment":"Testcomment", - "datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, + "datacl":[{"grantee":"postgres", "old_grantee": "postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, "with_grant":false}]}] }, "expected_sql_file": "create_view.sql", @@ -51,7 +51,7 @@ "check_option": "cascaded", "security_barrier": true, "comment":"Testcomment-updated", - "datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, + "datacl":[{"grantee":"postgres", "grantor":"postgres", "old_grantee": "postgres", "privileges":[{"privilege_type": "a", "privilege": true, "with_grant":false}]}] }, "expected_sql_file": "alter_view.sql", @@ -101,7 +101,72 @@ "expected_sql_file": "alter_view_add_some_priv.sql", "expected_msql_file": "alter_view_add_some_priv_msql.sql" }, - { + { + "type": "alter", + "name": "Alter View (deleting privileges (PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (postgres to PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "old_grantee": "postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_priv_msql.sql" + }, + { "type": "alter", "name": "Alter View (deleting privileges)", "endpoint": "NODE-view.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql new file mode 100644 index 000000000..b55277594 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql @@ -0,0 +1,17 @@ +-- View: public.testmview_$%{}[]()&*^!/@`# + +-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"; + +CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" +TABLESPACE pg_default +AS + SELECT 1 +WITH NO DATA; + +ALTER TABLE public."testmview_$%{}[]()&*^!/@`#" + OWNER TO enterprisedb; + +COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" + IS 'comment1'; + +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql new file mode 100644 index 000000000..af097c577 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" FROM enterprisedb; +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql index d267e529c..fbd46ee55 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql @@ -14,5 +14,3 @@ ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" OWNER TO enterprisedb; COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" IS 'Testcomment-updated'; - -GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..3db18ba28 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql new file mode 100644 index 000000000..be69754a6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json index 33d0f9ba7..d0586836c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json @@ -131,6 +131,63 @@ "expected_sql_file": "alter_mview_drop_all_priv.sql", "expected_msql_file": "alter_mview_drop_all_priv_msql.sql" }, + { + "type": "alter", + "name": "Alter Materialised Views (change grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "d", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "D", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "t", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_mview_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_priv_msql.sql" + }, { "type": "alter", "name": "Alter Materialised Views (change definition)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json index f76190c2b..7e311ed96 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json @@ -82,6 +82,71 @@ }, "expected_sql_file": "alter_view_add_some_priv.sql", "expected_msql_file": "alter_view_add_some_priv_msql.sql" + }, + { + "type": "alter", + "name": "Alter View (deleting privileges (PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "enterprisedb", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (enterprisedb to PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "enterprisedb", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "old_grantee": "enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_priv_msql.sql" }, { "type": "alter", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json index 413c284dc..9dace550b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json @@ -999,6 +999,7 @@ { "grantee": "PUBLIC", "grantor": "postgres", + "old_grantee": "postgres", "privileges": [ { "privilege_type": "a", diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js index 9a0e419e6..a971f5ffe 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js @@ -259,11 +259,20 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', } }); - return { + let data = { 'grantee': this.get('grantee'), 'grantor': this.get('grantor'), 'privileges': privileges, }; + + if (!_.isUndefined(this._previousAttributes['grantee'])) { + data['old_grantee'] = this._previousAttributes['grantee']; + } + else { + data['old_grantee'] = this.get('grantee'); + } + + return data; }, validate: function() { @@ -429,7 +438,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', $tbl = $tr.closest('table'), collection = this.model.get('privileges'), grantee = this.model.get('grantee'), $allGrants, - $allPrivileges, $elGrant; + $allPrivileges, $elGrant, $allPrivilegesCheckBox, $allGrantCheckBox; this.undelegateEvents(); /* @@ -469,7 +478,6 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', $allGrants.prop('disabled', false); $elGrant.prop('disabled', false); } - } else { /* * ALL checkbox has been deselected, hence - we need to make @@ -497,16 +505,20 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', allWithGrant = checked; $allGrants.prop('checked', checked); } - /* * Set the values for each Privilege Model. */ - collection.each(function(m) { - m.set( - {'privilege': allPrivilege, 'with_grant': allWithGrant}, - {silent: true} - ); - }); + for (let x = 0; x < collection.length; x++) { + let c = collection.at(x).toJSON(); + c['privilege'] = allPrivilege; + c['with_grant'] = c['with_grant'] ? c['with_grant'] : allWithGrant; + let m = _.extend({}, c); + + // collection.get(privilege_type).set(...) does not trigger the model change event, due to which change of privilege does not occur + // so to trigger the event, manually removing/adding the same model with updated attributes on same index. + collection.remove(c); + collection.add(m, {at: x, remove: false, merge: false}); + } } else { /* * Particular privilege has been selected/deselected, which can be @@ -539,7 +551,24 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', } else if (!checked) { $allGrants.prop('checked', false); } - collection.get(privilege_type).set(attrs, {silent: true}); + + let m = {}; + m['privilege_type'] = privilege_type; + m[type] = attrs[type]; + if (!_.isUndefined(attrs['with_grant'])) { + m['with_grant'] = attrs['with_grant']; + } + + let final_m = collection.get(privilege_type).toJSON(); + _.extend(final_m, m); + + let temp_m = collection.get(privilege_type); + let ind = collection.indexOf(temp_m); + + // collection.get(privilege_type).set(...) does not trigger the model change event, due to which change of privilege does not occur + // so to trigger the event, manually removing/adding the same model with updated attributes on same index. + collection.remove(temp_m); + collection.add(final_m, {at: ind, remove: false, merge: false}); if (checked) { $allPrivileges = $tbl.find( @@ -550,6 +579,8 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', $allPrivileges.length == collection.models.length) { $allPrivileges.prop('checked', true); + $allPrivilegesCheckBox = $tbl.find('input[name=privilege][privilege=\'ALL\']'); + $allPrivilegesCheckBox.prop('checked', true); if (type == 'with_grant') { $allGrants = $tbl.find( @@ -558,6 +589,9 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', if ($allGrants.length == collection.models.length) { $allGrants.prop('disabled', false); $allGrants.prop('checked', true); + + $allGrantCheckBox = $tbl.find('input[name=with_grant][privilege=\'ALL\']'); + $allGrantCheckBox.prop('checked', true); } } else if (grantee != 'PUBLIC') { $allGrants.prop('disabled', false); diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py index 6eb5f0eaa..e074ea735 100644 --- a/web/pgadmin/browser/server_groups/servers/utils.py +++ b/web/pgadmin/browser/server_groups/servers/utils.py @@ -125,12 +125,20 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]): priv_with_grant = ['ALL'] if len(priv_without_grant) == allowed_acls_len > 1: priv_without_grant = ['ALL'] + + grantee = driver.qtIdent(None, priv['grantee']) \ + if priv['grantee'] != 'PUBLIC' else 'PUBLIC' + + old_grantee = driver.qtIdent(None, priv['old_grantee']) \ + if 'old_grantee' in priv and priv['old_grantee'] != 'PUBLIC' \ + else grantee + # Appending and returning all ACL privileges.append({ - 'grantee': driver.qtIdent(None, priv['grantee']) - if priv['grantee'] != 'PUBLIC' else 'PUBLIC', + 'grantee': grantee, 'with_grant': priv_with_grant, - 'without_grant': priv_without_grant + 'without_grant': priv_without_grant, + 'old_grantee': old_grantee }) return privileges ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin] RM6117 Unable to update column level privileges from security tab. @ 2021-02-09 11:15 Akshay Joshi <[email protected]> parent: Rahul Shirsat <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Akshay Joshi @ 2021-02-09 11:15 UTC (permalink / raw) To: Nikhil Mohite <[email protected]>; +Cc: Aditya Toshniwal <[email protected]>; pgadmin-hackers; Rahul Shirsat <[email protected]> Hi Nikhil Can you please review the patch thoroughly? On Mon, Feb 8, 2021 at 3:28 PM Rahul Shirsat <[email protected]> wrote: > Akshay, > > Removed some whitespace warnings. While this new patch is applied there > are still 2 unknown whitespace warnings which are pointing to the wrong > location. > > Could you please let me know if this works? > > On Mon, Feb 8, 2021 at 9:53 AM Aditya Toshniwal < > [email protected]> wrote: > >> Hi Rahul, >> >> On Sat, Feb 6, 2021 at 1:25 AM Rahul Shirsat < >> [email protected]> wrote: >> >>> Hi Hackers, >>> >>> Please find the attached patch which resolves the issue of unable to >>> update column level privileges in the security tab. >>> >>> Additionally, when the user tries to change grantee, the sql wasn't >>> generating, this too issue is resolved. >>> >>> This security privilege issue is resolved for the following nodes: >>> >>> 1.) Tables (test cases are skipped as there are no resql test cases >>> based on pg & ppas) >>> 2.) Columns >>> 3.) Views >>> 4.) MViews >>> 5.) Types >>> 6.) Functions >>> 7.) Procedures >>> 8.) Trigger functions >>> 9.) Sequences >>> 10.) Schema >>> >>> P.S for committer : Warning of whitespaces after applying patch should >>> be ignored as it is a part of resql test case results. >>> >> Probably change the SQL generation logic to avoid the trailing >> whitespaces ? >> >>> >>> -- >>> *Rahul Shirsat* >>> Senior Software Engineer | EnterpriseDB Corporation. >>> >> >> >> -- >> Thanks, >> Aditya Toshniwal >> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* >> <http://edbpostgres.com; >> "Don't Complain about Heat, Plant a TREE" >> > > > -- > *Rahul Shirsat* > Senior Software Engineer | EnterpriseDB Corporation. > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Principal Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin] RM6117 Unable to update column level privileges from security tab. @ 2021-02-10 07:27 Nikhil Mohite <[email protected]> parent: Akshay Joshi <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Nikhil Mohite @ 2021-02-10 07:27 UTC (permalink / raw) To: Rahul Shirsat <[email protected]>; +Cc: Aditya Toshniwal <[email protected]>; pgadmin-hackers; Akshay Joshi <[email protected]> Hi Rahul, While reviewing the patch, found one observation with update privileges. 1. While creating a table add any privileges for any user and save. (e.g: Add Insert to user1) 2. Open table properties and update privileges for the same user by editing the privilege (e.g: Now Add Update to user1), check "Save" button is enabled.(Don't save the new privileges ) 3. Now if we retore the privilege to older values "Save" button remains enabled. (e.g: Deselect "Update" from privilege.) 4. SQL is also getting generated after restoring the privilege to older values. [image: image.png] Regards, Nikhil Mohite. On Tue, Feb 9, 2021 at 4:45 PM Akshay Joshi <[email protected]> wrote: > Hi Nikhil > > Can you please review the patch thoroughly? > > On Mon, Feb 8, 2021 at 3:28 PM Rahul Shirsat < > [email protected]> wrote: > >> Akshay, >> >> Removed some whitespace warnings. While this new patch is applied there >> are still 2 unknown whitespace warnings which are pointing to the wrong >> location. >> >> Could you please let me know if this works? >> >> On Mon, Feb 8, 2021 at 9:53 AM Aditya Toshniwal < >> [email protected]> wrote: >> >>> Hi Rahul, >>> >>> On Sat, Feb 6, 2021 at 1:25 AM Rahul Shirsat < >>> [email protected]> wrote: >>> >>>> Hi Hackers, >>>> >>>> Please find the attached patch which resolves the issue of unable to >>>> update column level privileges in the security tab. >>>> >>>> Additionally, when the user tries to change grantee, the sql wasn't >>>> generating, this too issue is resolved. >>>> >>>> This security privilege issue is resolved for the following nodes: >>>> >>>> 1.) Tables (test cases are skipped as there are no resql test cases >>>> based on pg & ppas) >>>> 2.) Columns >>>> 3.) Views >>>> 4.) MViews >>>> 5.) Types >>>> 6.) Functions >>>> 7.) Procedures >>>> 8.) Trigger functions >>>> 9.) Sequences >>>> 10.) Schema >>>> >>>> P.S for committer : Warning of whitespaces after applying patch should >>>> be ignored as it is a part of resql test case results. >>>> >>> Probably change the SQL generation logic to avoid the trailing >>> whitespaces ? >>> >>>> >>>> -- >>>> *Rahul Shirsat* >>>> Senior Software Engineer | EnterpriseDB Corporation. >>>> >>> >>> >>> -- >>> Thanks, >>> Aditya Toshniwal >>> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* >>> <http://edbpostgres.com; >>> "Don't Complain about Heat, Plant a TREE" >>> >> >> >> -- >> *Rahul Shirsat* >> Senior Software Engineer | EnterpriseDB Corporation. >> > > > -- > *Thanks & Regards* > *Akshay Joshi* > *pgAdmin Hacker | Principal Software Architect* > *EDB Postgres <http://edbpostgres.com>* > > *Mobile: +91 976-788-8246* > Attachments: [image/png] image.png (40.2K, 3-image.png) download | view image ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin] RM6117 Unable to update column level privileges from security tab. @ 2021-02-10 09:42 Rahul Shirsat <[email protected]> parent: Nikhil Mohite <[email protected]> 0 siblings, 1 reply; 7+ messages in thread From: Rahul Shirsat @ 2021-02-10 09:42 UTC (permalink / raw) To: Nikhil Mohite <[email protected]>; +Cc: Aditya Toshniwal <[email protected]>; pgadmin-hackers; Akshay Joshi <[email protected]> Hi Team, The above observation is fixed. Please find the updated patch below. On Wed, Feb 10, 2021 at 12:57 PM Nikhil Mohite < [email protected]> wrote: > Hi Rahul, > > While reviewing the patch, found one observation with update privileges. > 1. While creating a table add any privileges for any user and save. (e.g: > Add Insert to user1) > 2. Open table properties and update privileges for the same user by > editing the privilege (e.g: Now Add Update to user1), check "Save" button > is enabled.(Don't save the new privileges ) > 3. Now if we retore the privilege to older values "Save" button remains > enabled. (e.g: Deselect "Update" from privilege.) > 4. SQL is also getting generated after restoring the privilege to older > values. > [image: image.png] > > > Regards, > Nikhil Mohite. > > > > On Tue, Feb 9, 2021 at 4:45 PM Akshay Joshi <[email protected]> > wrote: > >> Hi Nikhil >> >> Can you please review the patch thoroughly? >> >> On Mon, Feb 8, 2021 at 3:28 PM Rahul Shirsat < >> [email protected]> wrote: >> >>> Akshay, >>> >>> Removed some whitespace warnings. While this new patch is applied there >>> are still 2 unknown whitespace warnings which are pointing to the wrong >>> location. >>> >>> Could you please let me know if this works? >>> >>> On Mon, Feb 8, 2021 at 9:53 AM Aditya Toshniwal < >>> [email protected]> wrote: >>> >>>> Hi Rahul, >>>> >>>> On Sat, Feb 6, 2021 at 1:25 AM Rahul Shirsat < >>>> [email protected]> wrote: >>>> >>>>> Hi Hackers, >>>>> >>>>> Please find the attached patch which resolves the issue of unable to >>>>> update column level privileges in the security tab. >>>>> >>>>> Additionally, when the user tries to change grantee, the sql wasn't >>>>> generating, this too issue is resolved. >>>>> >>>>> This security privilege issue is resolved for the following nodes: >>>>> >>>>> 1.) Tables (test cases are skipped as there are no resql test cases >>>>> based on pg & ppas) >>>>> 2.) Columns >>>>> 3.) Views >>>>> 4.) MViews >>>>> 5.) Types >>>>> 6.) Functions >>>>> 7.) Procedures >>>>> 8.) Trigger functions >>>>> 9.) Sequences >>>>> 10.) Schema >>>>> >>>>> P.S for committer : Warning of whitespaces after applying patch should >>>>> be ignored as it is a part of resql test case results. >>>>> >>>> Probably change the SQL generation logic to avoid the trailing >>>> whitespaces ? >>>> >>>>> >>>>> -- >>>>> *Rahul Shirsat* >>>>> Senior Software Engineer | EnterpriseDB Corporation. >>>>> >>>> >>>> >>>> -- >>>> Thanks, >>>> Aditya Toshniwal >>>> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* >>>> <http://edbpostgres.com; >>>> "Don't Complain about Heat, Plant a TREE" >>>> >>> >>> >>> -- >>> *Rahul Shirsat* >>> Senior Software Engineer | EnterpriseDB Corporation. >>> >> >> >> -- >> *Thanks & Regards* >> *Akshay Joshi* >> *pgAdmin Hacker | Principal Software Architect* >> *EDB Postgres <http://edbpostgres.com>* >> >> *Mobile: +91 976-788-8246* >> > -- *Rahul Shirsat* Senior Software Engineer | EnterpriseDB Corporation. Attachments: [image/png] image.png (40.2K, 3-image.png) download | view image [application/octet-stream] RM6117_v3.patch (370.2K, 4-RM6117_v3.patch) download | inline diff: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql index 5e8d357d7..6bc64af3c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/11_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql index 6b5772851..01c749ceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/12_plus/update.sql @@ -60,10 +60,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql index 8c18299b4..745877342 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql @@ -59,7 +59,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql index 963a7f3be..ac13a7525 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql @@ -56,10 +56,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql index 1917283f9..916347e13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql index aad4b6612..0122a4f51 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/update.sql @@ -55,10 +55,12 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endfor %}{% endif %} {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} - +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} - {% endfor %}{% endif %} {% if 'added' in data.acl %} {% for priv in data.acl.added %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql index 6b5772851..01c749ceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/12_plus/update.sql @@ -60,10 +60,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql index c9c76b82d..56ff2ad4b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql @@ -59,7 +59,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql index 963a7f3be..ac13a7525 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql @@ -56,10 +56,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql index 1917283f9..916347e13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql @@ -58,10 +58,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql index f922abdc2..c2f160e22 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/update.sql @@ -47,10 +47,14 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql index 6e711724d..43836ca50 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/11_plus/update.sql @@ -57,10 +57,14 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql index 65c766ca9..0b4ed30d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql @@ -45,7 +45,11 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {% if 'changed' in data.datacl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql index c1d7576e3..2030c917c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql @@ -48,7 +48,11 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {% if 'changed' in data.datacl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql index 124cbe93b..0f936f3ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/11_plus/update.sql @@ -50,10 +50,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql index 92a625db0..212c5b0ba 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql @@ -53,7 +53,11 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql index 124cbe93b..0f936f3ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql @@ -50,10 +50,14 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtype {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} -{% if 'changed' in data.datacl %} +{% if 'changed' in data.acl %} {% for priv in data.acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql index ec71dee45..cd28330dc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/update.sql @@ -49,7 +49,12 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endfor %}{% endif %} {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} + +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.old_grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..3e6120ff2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..67a549ead --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM postgres; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json index dc9a44520..cf0996aab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/11_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..3e6120ff2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..67a549ead --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM postgres; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json index dc9a44520..cf0996aab 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/12_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..7c951711f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE WINDOW + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json index 34225e580..0ed3b29e4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json @@ -213,7 +213,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..a5c3dd5e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..3e6120ff2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO postgres; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json index 43c034d61..9ff8bb6b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json @@ -214,7 +214,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4317e3d00 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json index bc1043b6c..e33cedd06 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_function.json @@ -224,6 +224,57 @@ "expected_sql_file": "alter_function_add_acl.sql", "expected_msql_file": "alter_function_add_acl.msql" }, + { + "type": "alter", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, { "type": "alter", "name": "Alter function add acl.", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json index dc9a44520..65e7a7d02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/11_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4317e3d00 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json index bc1043b6c..22bf13586 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_function.json @@ -226,7 +226,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json index 870f40003..ed8de0427 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/12_plus/test_procedures.json @@ -47,7 +47,91 @@ }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure delete privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter procedure change privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_proc_change_grantee_priv.sql", + "expected_msql_file": "alter_proc_change_grantee_priv.msql" + }, + { "type": "delete", "name": "Drop procedure", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4bddbe361 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) +RETURNS character varying + LANGUAGE 'plpgsql' + VOLATILE SECURITY DEFINER WINDOW + COST 100 + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json index 101eb587b..56cf4c8da 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json @@ -225,7 +225,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql new file mode 100644 index 000000000..0333fa578 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql @@ -0,0 +1,3 @@ +REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql new file mode 100644 index 000000000..4317e3d00 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql @@ -0,0 +1,21 @@ +-- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() + +-- DROP FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"(); + +CREATE OR REPLACE FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"( + ) + RETURNS character varying + LANGUAGE 'plpgsql' + COST 100 + VOLATILE SECURITY DEFINER PARALLEL UNSAFE + SET enable_sort='true' +AS $BODY$ +begin +select '1'; +end +$BODY$; + +ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() + OWNER TO enterprisedb; + +GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql new file mode 100644 index 000000000..5577b14cc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql @@ -0,0 +1,13 @@ +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(IN i1 integer) + LANGUAGE 'plpgsql' + + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +REVOKE ALL ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) FROM enterprisedb; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql new file mode 100644 index 000000000..94af35464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql @@ -0,0 +1,18 @@ +-- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) + +-- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); + +CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( + i1 integer) +LANGUAGE 'plpgsql' + SET application_name='pgadmin' +AS $BODY$ +begin +select 1; +end; +$BODY$; + +GRANT EXECUTE ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) TO PUBLIC; + +COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) + IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json index bc1043b6c..22bf13586 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json @@ -226,7 +226,58 @@ }, { "type": "alter", - "name": "Alter function add acl.", + "name": "Alter function remove partial privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter function change grantee in privileges.", + "endpoint": "NODE-function.obj_id", + "msql_endpoint": "NODE-function.msql_id", + "sql_endpoint": "NODE-function.sql_id", + "data": { + "acl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "X", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_function_change_grantee_acl.sql", + "expected_msql_file": "alter_function_change_grantee_acl.msql" + }, + { + "type": "alter", + "name": "Alter function delete acl.", "endpoint": "NODE-function.obj_id", "msql_endpoint": "NODE-function.msql_id", "sql_endpoint": "NODE-function.sql_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json index 46dd89cc4..b51bc23fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json @@ -77,6 +77,40 @@ "expected_sql_file": "alter_proc_opt.sql", "expected_msql_file": "alter_proc_opt_msql.sql" }, + { + "type": "alter", + "name": "Alter procedure add privileges", + "endpoint": "NODE-procedure.obj_id", + "sql_endpoint": "NODE-procedure.sql_id", + "data": { + "acl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + }, + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege": true, + "privilege_type": "X", + "with_grant": false + } + ] + } + ] + } + } + }, { "type": "delete", "name": "Drop procedure", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql index 2d42249b5..85dce035e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/update.sql @@ -84,7 +84,11 @@ COMMENT ON SEQUENCE {{ seqname }} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'SEQUENCE', priv.old_grantee, data.name, schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'SEQUENCE', priv.grantee, data.name, schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'SEQUENCE', priv.grantee, data.name, priv.without_grant, priv.with_grant, schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql new file mode 100644 index 000000000..480ba796b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs.sql @@ -0,0 +1,19 @@ +-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/# + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 5 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; + +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql new file mode 100644 index 000000000..c8347516d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_change_grantee_privs_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql index b392b3e31..78122be35 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/alter_seq_privs_remove.sql @@ -15,5 +15,3 @@ ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" IS 'Some comment'; - -GRANT ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json index 9687cf838..0995825ca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/pg/default/test_sequences_pg.json @@ -93,7 +93,51 @@ }, "expected_sql_file": "alter_seq_privs_update.sql", "expected_msql_file": "alter_seq_privs_update_msql.sql" - },{ + }, + { + "type": "alter", + "name": "Alter Sequence remove partial privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "deleted":[{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + } + }, + { + "type": "alter", + "name": "Alter Sequence change grantee in privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "changed":[{ + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_seq_change_grantee_privs.sql", + "expected_msql_file": "alter_seq_change_grantee_privs_msql.sql" + }, + { "type": "alter", "name": "Alter Sequence remove privileges", "endpoint": "NODE-sequence.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql new file mode 100644 index 000000000..b244d560e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs.sql @@ -0,0 +1,19 @@ +-- SEQUENCE: public.Seq1_$%{}[]()&*^!@"'`\/# + +-- DROP SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#"; + +CREATE SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + CYCLE + INCREMENT 12 + START 5 + MINVALUE 2 + MAXVALUE 9992 + CACHE 2; + +ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" + IS 'Some comment'; + +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql new file mode 100644 index 000000000..9ef112361 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_change_grantee_privs_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT SELECT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql index ac21e667f..bc59956a6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/alter_seq_privs_remove.sql @@ -15,5 +15,3 @@ ALTER SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" COMMENT ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" IS 'Some comment'; - -GRANT ALL ON SEQUENCE public."Seq1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json index 1639aac04..cafaa9252 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/ppas/default/test_sequences_ppas.json @@ -93,7 +93,51 @@ }, "expected_sql_file": "alter_seq_privs_update.sql", "expected_msql_file": "alter_seq_privs_update_msql.sql" - },{ + }, + { + "type": "alter", + "name": "Alter Sequence remove partial privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "deleted":[{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + } + }, + { + "type": "alter", + "name": "Alter Sequence change grantee in privileges", + "endpoint": "NODE-sequence.obj_id", + "sql_endpoint": "NODE-sequence.sql_id", + "msql_endpoint": "NODE-sequence.msql_id", + "data": { + "relacl": { + "changed":[{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges":[{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_seq_change_grantee_privs.sql", + "expected_msql_file": "alter_seq_change_grantee_privs_msql.sql" + }, + { "type": "alter", "name": "Alter Sequence remove privileges", "endpoint": "NODE-sequence.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..63674778f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..d44b1970b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json similarity index 93% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json index 0cdab1700..854d375ce 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/10_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json @@ -80,6 +80,40 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", + "attacl": { + "changed": [ + { + "grantee": "postgres", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..a72953989 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..a1c149f01 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_drop_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_generated_with_existing_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_generated_with_existing_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_comb_start_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_generated_with_existing_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_generated_with_existing_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_int_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json similarity index 96% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json index 98d701fda..29158ff32 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/12_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/12_plus/test.json @@ -51,6 +51,20 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"postgres", "grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql new file mode 100644 index 000000000..24fa69019 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql new file mode 100644 index 000000000..231d5ae9e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/alter_column_remove_length.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_remove_length.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_char.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_int.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/create_column_numeric.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json similarity index 90% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json index 545aa3706..dad747fe1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json @@ -51,6 +51,20 @@ "expected_sql_file": "alter_column_int.sql", "expected_msql_file": "alter_column_int.msql" }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"postgres", "grantor":"postgres","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, { "type": "delete", "name": "Drop Column (Integer/Numeric type)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..7f5387c51 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..ecae7324d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql new file mode 100644 index 000000000..0d70893d5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql new file mode 100644 index 000000000..335d4b88e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql new file mode 100644 index 000000000..78b103c06 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..6749d14e5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql new file mode 100644 index 000000000..4184c8168 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..e4828088b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql new file mode 100644 index 000000000..8a8e36b24 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql new file mode 100644 index 000000000..7d78c948d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql new file mode 100644 index 000000000..7a46497d9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql @@ -0,0 +1,8 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_5_$%{}[]()&*^!@""'`\/#" TO "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 2 SET MINVALUE 1 SET MAXVALUE 200 SET CACHE 2; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..560d2b978 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql new file mode 100644 index 000000000..6eede13ba --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 3 RESTART SET START 3 SET MINVALUE 3 SET MAXVALUE 30 SET CACHE 3; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql new file mode 100644 index 000000000..5aecdbec8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 3 START 3 MINVALUE 3 MAXVALUE 30 CACHE 3 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..402c270cf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET GENERATED ALWAYS SET NO CYCLE RESTART SET START 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..79cba6ad2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 2 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql new file mode 100644 index 000000000..adc24fd74 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql new file mode 100644 index 000000000..515f2cdc0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql new file mode 100644 index 000000000..c9362ce46 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql new file mode 100644 index 000000000..95817ad62 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql new file mode 100644 index 000000000..d4caec80e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql new file mode 100644 index 000000000..5506f2974 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql new file mode 100644 index 000000000..d0592b96b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql new file mode 100644 index 000000000..0f7e099f9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..4a39d912a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..987bd6106 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql new file mode 100644 index 000000000..9314e01b8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql new file mode 100644 index 000000000..61e7b4452 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql new file mode 100644 index 000000000..ad0bbd759 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql new file mode 100644 index 000000000..063b3c675 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql new file mode 100644 index 000000000..7bd916040 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..1aa62031e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql new file mode 100644 index 000000000..b80516f26 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql new file mode 100644 index 000000000..487567ade --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_4_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json new file mode 100644 index 000000000..968c0b551 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json @@ -0,0 +1,531 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.10+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_2_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "defval": "1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype": "real", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enteprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", + "attacl": { + "changed": [ + { + "grantee": "enterprisedb", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": "50", + "attprecision": null, + "attoptions": [], + "seclabels": [], + "defval": null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype": "character", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "attidentity": "a", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "99999", + "seqcache": "10", + "seqcycle": true, + "colconstype": "i" + }, + "expected_sql_file": "create_column_int_identity.sql", + "expected_msql_file": "create_column_int_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_identity.sql", + "expected_msql_file": "alter_column_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql", + "expected_msql_file": "alter_column_drop_identity.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val": 0, + "max_val": 1000, + "cltype": "numeric", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": "10", + "attprecision": "5", + "attidentity": "a", + "attoptions": [ + { + "name": "n_distinct", + "value": "1" + } + ], + "seclabels": [] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "attnum": 4, + "attlen": "15", + "attprecision": "6", + "description": "Comment for alter", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen": "" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype": "bigint", + "attacl": [], + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attoptions": [], + "seclabels": [], + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "99999", + "seqcache": "10", + "seqcycle": true, + "colconstype": "i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql", + "expected_msql_file": "create_column_int_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 5, + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement": "2", + "seqmax": "200", + "seqcache": "2", + "seqcycle": true, + "seqmin": "1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql", + "expected_msql_file": "alter_column_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 5, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql", + "expected_msql_file": "alter_column_drop_identity_by_default.msql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#", + "cltype": "bigint", + "attacl": [], + "description": "demo comments", + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "10", + "seqcache": "1", + "seqcycle": true, + "colconstype": "i", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_identity_for_restart_seq.sql", + "expected_msql_file": "create_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnotnull": true, + "attidentity": "a", + "seqstart": 2, + "seqcycle": false + }, + "expected_sql_file": "alter_column_identity_for_restart_seq.sql", + "expected_msql_file": "alter_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (ALWAYS) for combination of identity options & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "attidentity": "a", + "seqincrement": "3", + "seqstart": "3", + "seqmin": "3", + "seqmax": "30", + "seqcache": "3", + "seqcycle": true + }, + "expected_sql_file": "alter_column_identity_for_comb_start_seq.sql", + "expected_msql_file": "alter_column_identity_for_comb_start_seq.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql new file mode 100644 index 000000000..09425ce5c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql new file mode 100644 index 000000000..e6007db13 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql new file mode 100644 index 000000000..1ac157462 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql new file mode 100644 index 000000000..e55b117dc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql new file mode 100644 index 000000000..c345ba0a6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql new file mode 100644 index 000000000..ccd89d803 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql new file mode 100644 index 000000000..ade6c7e9f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" DROP IDENTITY; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql new file mode 100644 index 000000000..c23442003 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_drop_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql new file mode 100644 index 000000000..41086ab1e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_4_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_4_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql new file mode 100644 index 000000000..e49bebfaf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_4_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_4_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_4_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql new file mode 100644 index 000000000..6b76b70de --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_8_$%{}[]()&*^!@""'`\/#" TO "new_col_8_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_8_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_8_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_8_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql new file mode 100644 index 000000000..4f96cd527 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_generated_with_existing_columns.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_8_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_8_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_8_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql new file mode 100644 index 000000000..119556dc4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.msql @@ -0,0 +1,7 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql new file mode 100644 index 000000000..e0fbb91c9 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_3_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_3_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql new file mode 100644 index 000000000..6c00ace62 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.msql @@ -0,0 +1,8 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_9_$%{}[]()&*^!@""'`\/#" TO "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 2 SET MINVALUE 1 SET MAXVALUE 200 SET CACHE 2; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql new file mode 100644 index 000000000..a16cc8721 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 200 CACHE 2 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql new file mode 100644 index 000000000..ad78f916e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET CYCLE SET INCREMENT 3 RESTART SET START 3 SET MINVALUE 3 SET MAXVALUE 30 SET CACHE 3; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql new file mode 100644 index 000000000..55c46ed20 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_comb_start_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 3 START 3 MINVALUE 3 MAXVALUE 30 CACHE 3 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..603dcec8e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_6_$%{}[]()&*^!@""'`\/#" SET GENERATED ALWAYS SET NO CYCLE RESTART SET START 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..75589761f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 2 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql new file mode 100644 index 000000000..0f2c754bc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql new file mode 100644 index 000000000..e7e818ef1 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql new file mode 100644 index 000000000..49aa6e672 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + RENAME "col_5_$%{}[]()&*^!@""'`\/#" TO "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql new file mode 100644 index 000000000..c34bfc7fc --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql new file mode 100644 index 000000000..41cb2a646 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql new file mode 100644 index 000000000..686ebf3c3 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."new_col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_5_$%{}[]()&*^!@""'`\/#") ON testschema."table_3_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql new file mode 100644 index 000000000..11ad3f86b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql new file mode 100644 index 000000000..5b4cd4a4d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql new file mode 100644 index 000000000..897636899 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql new file mode 100644 index 000000000..6c827598b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_identity_for_restart_seq.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_6_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_6_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 10 CACHE 1 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_6_$%{}[]()&*^!@""'`\/#" + IS 'demo comments'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql new file mode 100644 index 000000000..925ea8c8f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql new file mode 100644 index 000000000..39e8868da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql new file mode 100644 index 000000000..22cee135b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" bigint(None, None) GENERATED ALWAYS AS (1 + 2 + 3) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql new file mode 100644 index 000000000..e06070efb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_4_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_4_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS (((1 + 2) + 3)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql new file mode 100644 index 000000000..95ab88727 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_8_$%{}[]()&*^!@""'`\/#" bigint(None, None) GENERATED ALWAYS AS (dummy1 + dummy2) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql new file mode 100644 index 000000000..ae40c07c4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_generated_with_existing_columns.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_8_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_8_$%{}[]()&*^!@""'`\/#" bigint GENERATED ALWAYS AS ((dummy1 + dummy2)) STORED; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_8_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql new file mode 100644 index 000000000..34581f0a5 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql new file mode 100644 index 000000000..da3867660 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql new file mode 100644 index 000000000..dcc5e7879 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_9_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql new file mode 100644 index 000000000..bdc3795da --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_int_identity_by_default.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_9_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_9_$%{}[]()&*^!@""'`\/#" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( CYCLE INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 99999 CACHE 10 ); + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_9_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql new file mode 100644 index 000000000..0f7944bc0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql new file mode 100644 index 000000000..73f49eebf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_5_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_5_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_3_$%{}[]()&*^!@""'`\/#"."col_5_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_3_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_5_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json new file mode 100644 index 000000000..69983090e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/12_plus/test.json @@ -0,0 +1,539 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (v.12+)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_3_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"enterprisedb", "grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"a", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity.sql", + "expected_msql_file": "create_column_int_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_identity.sql", + "expected_msql_file": "alter_column_identity.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) drop identity", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity.sql", + "expected_msql_file": "alter_column_drop_identity.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"1 + 2 + 3", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated.sql", + "expected_msql_file": "create_column_int_generated.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 4, + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated.sql", + "expected_msql_file": "alter_column_generated.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_5_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#", + "attnum": 5, + "attlen":"15", + "attprecision":"6", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen":"" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_5_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "dummy1", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Dummy Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "dummy2", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + } + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_8_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":null, + "attprecision":null, + "attidentity":"a", + "colconstype":"g", + "genexpr":"dummy1 + dummy2", + "attoptions":[], + "seclabels":[] + }, + "expected_sql_file": "create_column_int_generated_with_existing_columns.sql", + "expected_msql_file": "create_column_int_generated_with_existing_columns.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 8, + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#", + "genexpr":"dummy1 - dummy2", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_generated_with_existing_columns.sql", + "expected_msql_file": "alter_column_generated_with_existing_columns.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type) with Generated feature with columns", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_8_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column with identity (Generated by default)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "attidentity":"d", + "seqincrement":"1", + "seqstart":"1", + "seqmin":"1", + "seqmax":"99999", + "seqcache":"10", + "seqcycle":true, + "colconstype":"i" + }, + "expected_sql_file": "create_column_int_identity_by_default.sql", + "expected_msql_file": "create_column_int_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "seqincrement":"2", + "seqmax":"200", + "seqcache":"2", + "seqcycle":true, + "seqmin":"1" + }, + "expected_sql_file": "alter_column_identity_by_default.sql", + "expected_msql_file": "alter_column_identity_by_default.msql" + }, + { + "type": "alter", + "name": "Alter Column with drop identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "colconstype": "n" + }, + "expected_sql_file": "alter_column_drop_identity_by_default.sql", + "expected_msql_file": "alter_column_drop_identity_by_default.msql" + }, + { + "type": "delete", + "name": "Drop Column Column with identity (Generated by default)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_9_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with identity (BY DEFAULT) for combination of identity options & initiate START", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#", + "cltype": "bigint", + "attacl": [], + "description": "demo comments", + "is_primary_key": false, + "attnotnull": true, + "attlen": null, + "attprecision": null, + "attidentity": "d", + "seqincrement": "1", + "seqstart": "1", + "seqmin": "1", + "seqmax": "10", + "seqcache": "1", + "seqcycle": true, + "colconstype": "i", + "attoptions": [], + "seclabels": [] + }, + "expected_sql_file": "create_column_identity_for_restart_seq.sql", + "expected_msql_file": "create_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (BY DEFAULT) to ALWAYS & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnotnull": true, + "attidentity": "a", + "seqstart": 2, + "seqcycle": false + }, + "expected_sql_file": "alter_column_identity_for_restart_seq.sql", + "expected_msql_file": "alter_column_identity_for_restart_seq.msql" + }, + { + "type": "alter", + "name": "Alter identity Column (ALWAYS) for combination of identity options & Update START", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 9, + "attidentity": "a", + "seqincrement": "3", + "seqstart": "3", + "seqmin": "3", + "seqmax": "30", + "seqcache": "3", + "seqcycle": true + }, + "expected_sql_file": "alter_column_identity_for_comb_start_seq.sql", + "expected_msql_file": "alter_column_identity_for_comb_start_seq.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col_6_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql new file mode 100644 index 000000000..08de11032 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.msql @@ -0,0 +1,2 @@ +REVOKE ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql new file mode 100644 index 000000000..c3bf26b83 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_alt_privilege.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql new file mode 100644 index 000000000..7496276fb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql @@ -0,0 +1,15 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql new file mode 100644 index 000000000..30a97ca40 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql @@ -0,0 +1,17 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; + +GRANT INSERT("new_col_2_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_2_$%{}[]()&*^!@""'`\/#"), REFERENCES("new_col_2_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql new file mode 100644 index 000000000..bfd079ae8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql new file mode 100644 index 000000000..d96d1a1d0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql @@ -0,0 +1,11 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql new file mode 100644 index 000000000..d1313822b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql new file mode 100644 index 000000000..f115459d4 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql new file mode 100644 index 000000000..07891245e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.msql @@ -0,0 +1,2 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql new file mode 100644 index 000000000..7a7445b66 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_remove_length.sql @@ -0,0 +1,15 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for alter'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); + +GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql new file mode 100644 index 000000000..f43e84a8e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50, None) COLLATE pg_catalog."C" DEFAULT None; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql new file mode 100644 index 000000000..c5c3e10bf --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_2_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql new file mode 100644 index 000000000..bde4012ff --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.msql @@ -0,0 +1,5 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint(None, None) NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql new file mode 100644 index 000000000..b7c693539 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql @@ -0,0 +1,9 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_1_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql new file mode 100644 index 000000000..b5eb2cfcd --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.msql @@ -0,0 +1,9 @@ +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql new file mode 100644 index 000000000..68c7fb52a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql @@ -0,0 +1,13 @@ +-- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + +-- ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN "col_3_$%{}[]()&*^!@""'`\/#"; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ADD COLUMN "col_3_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; + +COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" + IS 'Comment for create'; + +ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" + SET (n_distinct=1); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json new file mode 100644 index 000000000..1cced1226 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json @@ -0,0 +1,193 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create Table for testing column node (Ver.default)", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "data": { + "name": "table_1_$%{}[]()&*^!@\"'`\\/#", + "is_partitioned": false, + "columns": [], + "schema": "testschema" + }, + "store_object_id": true + }, + { + "type": "create", + "name": "Create Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"bigint", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":null, + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":"1" + }, + "expected_sql_file": "create_column_int.sql", + "expected_msql_file": "create_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for alter", + "cltype":"real", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_int.sql", + "expected_msql_file": "alter_column_int.msql" + }, + { + "type": "alter", + "name": "Alter Column (Privilege change)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 1, + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "attacl":{"changed":[{"grantee":"enterprisedb", "grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_alt_privilege.sql", + "expected_msql_file": "alter_column_alt_privilege.msql" + }, + { + "type": "delete", + "name": "Drop Column (Integer/Numeric type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column (Character type)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_2_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "cltype":"character varying", + "collspcname": "pg_catalog.\"C\"", + "attacl":[], + "is_primary_key":false, + "attnotnull":false, + "attlen":"50", + "attprecision":null, + "attoptions":[], + "seclabels":[], + "defval":null + }, + "expected_sql_file": "create_column_char.sql", + "expected_msql_file": "create_column_char.msql" + }, + { + "type": "alter", + "name": "Alter Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 2, + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#", + "attlen": null, + "attstattarget": "5", + "attstorage": "p", + "description": "Comment for alter", + "cltype":"character", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_char.sql", + "expected_msql_file": "alter_column_char.msql" + }, + { + "type": "delete", + "name": "Drop Column (Character type)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_2_$%{}[]()&*^!@\"'`\\/#" + } + }, + + { + "type": "create", + "name": "Create Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col_3_$%{}[]()&*^!@\"'`\\/#", + "description": "Comment for create", + "min_val":0, + "max_val":1000, + "cltype":"numeric", + "attacl":[], + "is_primary_key":false, + "attnotnull":true, + "attlen":"10", + "attprecision":"5", + "attidentity":"a", + "attoptions":[{"name":"n_distinct","value":"1"}], + "seclabels":[] + }, + "expected_sql_file": "create_column_numeric.sql", + "expected_msql_file": "create_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", + "attnum": 3, + "attlen":"15", + "attprecision":"6", + "description": "Comment for alter", + "attacl":{"added":[{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"a","privilege":true,"with_grant":false},{"privilege_type":"r","privilege":true,"with_grant":false},{"privilege_type":"w","privilege":true,"with_grant":false},{"privilege_type":"x","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_column_numeric.sql", + "expected_msql_file": "alter_column_numeric.msql" + }, + { + "type": "alter", + "name": "Alter Column (Remove Length)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "attnum": 3, + "attlen":"" + }, + "expected_sql_file": "alter_column_remove_length.sql", + "expected_msql_file": "alter_column_remove_length.msql" + }, + { + "type": "delete", + "name": "Drop Column (Numeric type with Length Precision & Variables)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql index 259a2ca9d..e698ed3b8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql @@ -147,11 +147,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql index d39f8b6b9..8ca34d2cb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql @@ -107,11 +107,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql index 5d99eb66d..05702cc57 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/update.sql @@ -104,11 +104,20 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% if 'changed' in data.attacl %} {% for priv in data.attacl.changed %} +{% set is_grantee_changed = (priv.grantee != priv.old_grantee) %} {% if data.name %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% else %} +{% if is_grantee_changed %} +{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.old_grantee) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endif %} {% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql index 35d769269..e9f7c6211 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/11_plus/update.sql @@ -247,7 +247,11 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql index c2e61535f..c0da37b11 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/update.sql @@ -240,7 +240,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql index 28f25e925..49a8aa3b3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql @@ -236,7 +236,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql index ef0ec4e23..9c4b576ee 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/update.sql @@ -224,7 +224,11 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% endif %} {% if 'changed' in data.relacl %} {% for priv in data.relacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql index 47f6e1346..5bb1cdf02 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql @@ -28,7 +28,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -51,7 +55,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in acl %} {% for priv in acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql index 64baa0358..495aaa538 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/update.sql @@ -28,7 +28,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -51,7 +55,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in acl %} {% for priv in acl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql index 9f0a849c5..2535732fe 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql @@ -50,7 +50,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -70,7 +74,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.deftblacl %} {% for priv in data.deftblacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql index a324937bb..55b8afbca 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql @@ -50,7 +50,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.nspacl %} {% for priv in data.nspacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.old_grantee, data.name) }} +{% else %} {{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} +{% endif %} {{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} @@ -70,7 +74,11 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {% endif %} {% if 'changed' in data.deftblacl %} {% for priv in data.deftblacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.old_grantee) }} +{% else %} {{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee) }} +{% endif %} {{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql index f9cee50b8..e42962c22 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql @@ -8,7 +8,7 @@ CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" -GRANT SELECT, UPDATE ON TABLES TO PUBLIC; +GRANT SELECT ON TABLES TO PUBLIC; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT EXECUTE ON FUNCTIONS TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql new file mode 100644 index 000000000..c8fc71a74 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql @@ -0,0 +1,22 @@ +-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/# + +-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ; + +CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + AUTHORIZATION postgres; + +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO postgres; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT EXECUTE ON FUNCTIONS TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT USAGE ON TYPES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql new file mode 100644 index 000000000..5f67cc02a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql @@ -0,0 +1,12 @@ +REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC; +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON TABLES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON SEQUENCES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json index 62fb3c771..85c0d6af1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json @@ -213,6 +213,49 @@ }, "expected_sql_file": "alter_schema_add_priv.sql", "expected_msql_file": "alter_schema_add_priv_msql.sql" + }, { + "type": "alter", + "name": "Alert Schema Update Privileges", + "endpoint": "NODE-schema.obj_id", + "sql_endpoint": "NODE-schema.sql_id", + "msql_endpoint": "NODE-schema.msql_id", + "data": { + "nspacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "U", + "privilege": true, + "with_grant": false + }] + }] + }, + "deftblacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + }, + "defseqacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [{ + "privilege_type": "w", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_schema_update_priv.sql", + "expected_msql_file": "alter_schema_update_priv_msql.sql" }, { "type": "alter", "name": "Alert Schema Drop Privileges", @@ -260,7 +303,8 @@ }, "expected_sql_file": "alter_schema_drop_priv.sql", "expected_msql_file": "alter_schema_drop_priv_msql.sql" - }, { + }, + { "type": "delete", "name": "Drop Schema", "endpoint": "NODE-schema.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql index 4dbbf07e6..a18430f2b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql @@ -8,7 +8,7 @@ CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" -GRANT SELECT, UPDATE ON TABLES TO PUBLIC; +GRANT SELECT ON TABLES TO PUBLIC; ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" GRANT EXECUTE ON FUNCTIONS TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql new file mode 100644 index 000000000..e200bff39 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql @@ -0,0 +1,22 @@ +-- SCHEMA: test_schema_$%{}[]()&*^!@""'`\/# + +-- DROP SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" ; + +CREATE SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + AUTHORIZATION enterprisedb; + +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + +GRANT ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO enterprisedb; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT EXECUTE ON FUNCTIONS TO PUBLIC; + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT USAGE ON TYPES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql new file mode 100644 index 000000000..bbc594d03 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql @@ -0,0 +1,14 @@ +REVOKE ALL ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" FROM PUBLIC; +GRANT USAGE ON SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" TO PUBLIC; + + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON TABLES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT SELECT ON TABLES TO PUBLIC; + + +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" + REVOKE ALL ON SEQUENCES FROM PUBLIC; +ALTER DEFAULT PRIVILEGES IN SCHEMA "test_schema_$%{}[]()&*^!@""""'`\/#" +GRANT UPDATE ON SEQUENCES TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json index b3d23b60f..4d4a3d925 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json @@ -213,6 +213,49 @@ }, "expected_sql_file": "alter_schema_add_priv.sql", "expected_msql_file": "alter_schema_add_priv_msql.sql" + }, { + "type": "alter", + "name": "Alert Schema Update Privileges", + "endpoint": "NODE-schema.obj_id", + "sql_endpoint": "NODE-schema.sql_id", + "msql_endpoint": "NODE-schema.msql_id", + "data": { + "nspacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "U", + "privilege": true, + "with_grant": false + }] + }] + }, + "deftblacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "r", + "privilege": true, + "with_grant": false + }] + }] + }, + "defseqacl": { + "changed": [{ + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [{ + "privilege_type": "w", + "privilege": true, + "with_grant": false + }] + }] + } + }, + "expected_sql_file": "alter_schema_update_priv.sql", + "expected_msql_file": "alter_schema_update_priv_msql.sql" }, { "type": "alter", "name": "Alert Schema Drop Privileges", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql index bd589f378..036ea2a11 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/types/sql/default/update.sql @@ -129,7 +129,11 @@ ALTER TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }} {% endif %} {% if 'changed' in data.typacl %} {% for priv in data.typacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.old_grantee, o_data.name, o_data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TYPE', priv.grantee, o_data.name, o_data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TYPE', priv.grantee, o_data.name, priv.without_grant, priv.with_grant, o_data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql new file mode 100644 index 000000000..5977dd022 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change.sql @@ -0,0 +1,17 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql new file mode 100644 index 000000000..17587974f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_acl_grantee_change_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" FROM <OWNER>; +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_add_member.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_add_member.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_composite_type_remove_member.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_composite_type_remove_member.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_enum_type_label.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_enum_type_label.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_range_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_range_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/alter_shell_type_acl_description.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/alter_shell_type_acl_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type_one_field.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type_one_field.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_composite_type_one_field.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_composite_type_one_field.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_enum_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_enum_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_range_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_range_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/create_shell_type.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/create_shell_type.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json similarity index 84% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json index 8b19e9024..f44f970d3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/default/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/pg/default/tests.json @@ -222,6 +222,57 @@ "expected_sql_file": "alter_range_type_acl_description.sql", "expected_msql_file": "alter_range_type_acl_description.msql" }, + { + "type": "alter", + "name": "alter ACL (Remove privilege)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "alter ACL (change grantee)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_acl_grantee_change.sql", + "expected_msql_file": "alter_acl_grantee_change_msql.sql" + }, { "type": "delete", "name": "Drop RANGE type", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql new file mode 100644 index 000000000..f3a429ea2 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change.sql @@ -0,0 +1,17 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql new file mode 100644 index 000000000..4e21680e0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_acl_grantee_change_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql new file mode 100644 index 000000000..32b0f674e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql new file mode 100644 index 000000000..4769bf1db --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_acl_description.sql @@ -0,0 +1,20 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql new file mode 100644 index 000000000..6e6946f18 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + ADD ATTRIBUTE mname4 bigint; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql new file mode 100644 index 000000000..b864240c0 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_add_member.sql @@ -0,0 +1,14 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql new file mode 100644 index 000000000..aafc63f4b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + DROP ATTRIBUTE mname1; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql new file mode 100644 index 000000000..013245dac --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_composite_type_remove_member.sql @@ -0,0 +1,13 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C", + mname4 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql new file mode 100644 index 000000000..4c7de8707 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql new file mode 100644 index 000000000..e114d0cfa --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_acl_description.sql @@ -0,0 +1,16 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c', 'd'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql new file mode 100644 index 000000000..97949e79c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.msql @@ -0,0 +1,2 @@ +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + ADD VALUE 'd' AFTER 'c'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql new file mode 100644 index 000000000..1a7a15307 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_enum_type_label.sql @@ -0,0 +1,9 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c', 'd'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql new file mode 100644 index 000000000..c58b5eabb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.msql @@ -0,0 +1,4 @@ +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql new file mode 100644 index 000000000..496f8422f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_range_type_acl_description.sql @@ -0,0 +1,19 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + +GRANT USAGE ON TYPE public."range_type_$%{}[]()&*^!@""'`\/#" TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql new file mode 100644 index 000000000..851cb6116 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.msql @@ -0,0 +1,2 @@ +COMMENT ON TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql new file mode 100644 index 000000000..3f78bfd29 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/alter_shell_type_acl_description.sql @@ -0,0 +1,11 @@ +-- Type: shell_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +ALTER TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; + +COMMENT ON TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + IS 'this is test'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql new file mode 100644 index 000000000..089682b76 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.msql @@ -0,0 +1,6 @@ +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C" +); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql new file mode 100644 index 000000000..d48f7053d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type.sql @@ -0,0 +1,13 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint, + mname2 character varying(50) COLLATE pg_catalog."C", + mname3 text[] COLLATE pg_catalog."C" +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql new file mode 100644 index 000000000..16d5758bb --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_composite_type_one_field.sql @@ -0,0 +1,11 @@ +-- Type: composite_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS +( + mname1 bigint +); + +ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql new file mode 100644 index 000000000..ecf7a2f6d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.msql @@ -0,0 +1,2 @@ +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c'); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql new file mode 100644 index 000000000..ebccea875 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_enum_type.sql @@ -0,0 +1,9 @@ +-- Type: enum_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."enum_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" AS ENUM + ('a', 'b', 'c'); + +ALTER TYPE public."enum_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql new file mode 100644 index 000000000..e8a2d71fd --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.msql @@ -0,0 +1,4 @@ +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool +); \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql new file mode 100644 index 000000000..be9c1a752 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_range_type.sql @@ -0,0 +1,12 @@ +-- Type: range_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."range_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."range_type_$%{}[]()&*^!@""'`\/#" AS RANGE +( + SUBTYPE=bool, + SUBTYPE_OPCLASS = bool_ops +); + +ALTER TYPE public."range_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql new file mode 100644 index 000000000..bfab7af85 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.msql @@ -0,0 +1 @@ +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql new file mode 100644 index 000000000..126f2b7ff --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/create_shell_type.sql @@ -0,0 +1,8 @@ +-- Type: shell_type_$%{}[]()&*^!@"'`\/# + +-- DROP TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +CREATE TYPE public."shell_type_$%{}[]()&*^!@""'`\/#"; + +ALTER TYPE public."shell_type_$%{}[]()&*^!@""'`\/#" + OWNER TO <OWNER>; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json new file mode 100644 index 000000000..cc662721e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/tests/ppas/default/tests.json @@ -0,0 +1,284 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create ENUM type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "enum_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"e", + "schema":"public", + "composite":[], + "enum":[{"label":"a"},{"label":"b"},{"label":"c"}], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_enum_type.sql", + "expected_msql_file": "create_enum_type.msql" + }, + { + "type": "alter", + "name": "alter ENUM type and add new label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "enum": {"added": [{"label": "d"}]} + }, + "expected_sql_file": "alter_enum_type_label.sql", + "expected_msql_file": "alter_enum_type_label.msql" + }, + { + "type": "alter", + "name": "alter ENUM type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_enum_type_acl_description.sql", + "expected_msql_file": "alter_enum_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop ENUM type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + + { + "type": "create", + "name": "Create Composite type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "composite_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"c", + "schema":"public", + "composite":[ + {"member_name":"mname1","type":"bigint","is_tlength":false,"is_precision":false}, + {"member_name":"mname2","type":"character varying","tlength":50,"is_tlength":true,"is_precision":false,"collation":"pg_catalog.\"C\"","min_val":1,"max_val":2147483647,"collspcname":""}, + {"member_name":"mname3","type":"text[]","is_tlength":false,"is_precision":false,"collation":"pg_catalog.\"C\"","collspcname":""} + ], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_composite_type.sql", + "expected_msql_file": "create_composite_type.msql" + }, + { + "type": "alter", + "name": "alter Composite type and add new label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "composite": {"added": [{"member_name":"mname4","type":"bigint","is_tlength":false,"is_precision":false}]} + }, + "expected_sql_file": "alter_composite_type_add_member.sql", + "expected_msql_file": "alter_composite_type_add_member.msql" + }, + { + "type": "alter", + "name": "alter Composite type and delete label", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "composite": {"deleted":[{"attnum":1,"member_name":"mname1","type":"bigint","tlength":null,"is_tlength":false,"precision":null,"is_precision":false,"collation":"","cltype":"bigint","hasSqrBracket":false,"fulltype":"bigint"}]} + }, + "expected_sql_file": "alter_composite_type_remove_member.sql", + "expected_msql_file": "alter_composite_type_remove_member.msql" + }, + { + "type": "alter", + "name": "alter Composite type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_composite_type_acl_description.sql", + "expected_msql_file": "alter_composite_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop Composite type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + { + "type": "create", + "name": "Create Composite type - one field", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "data": { + "name": "composite_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"c", + "schema":"public", + "composite":[ + {"member_name":"mname1","type":"bigint","is_tlength":false,"is_precision":false} + ], + "typacl":[], + "seclabels":[], + "description":"" + }, + "expected_sql_file": "create_composite_type_one_field.sql" + }, + { + "type": "delete", + "name": "Drop Composite type - one field", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + { + "type": "create", + "name": "Create SHELL type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "shell_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"p", + "schema":"public", + "composite":[], + "enum":[], + "typacl":[], + "seclabels":[] + }, + "expected_sql_file": "create_shell_type.sql", + "expected_msql_file": "create_shell_type.msql" + }, + { + "type": "alter", + "name": "alter SHELL type and add description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test" + }, + "expected_sql_file": "alter_shell_type_acl_description.sql", + "expected_msql_file": "alter_shell_type_acl_description.msql" + }, + { + "type": "delete", + "name": "Drop SHELL type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + }, + + + { + "type": "create", + "name": "Create RANGE type", + "endpoint": "NODE-type.obj", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql", + "data": { + "name": "range_type_$%{}[]()&*^!@\"'`\\/#", + "is_sys_type":false, + "typtype":"r", + "schema":"public", + "composite":[], + "enum":[], + "typacl":[], + "seclabels":[], + "typname":"bool" + }, + "expected_sql_file": "create_range_type.sql", + "expected_msql_file": "create_range_type.msql" + }, + { + "type": "alter", + "name": "alter RANGE type and add ACL, description", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "description":"this is test", + "typacl": {"added": [{"grantee":"PUBLIC","grantor":"enterprisedb","privileges":[{"privilege_type":"U","privilege":true,"with_grant":false}]}]} + }, + "expected_sql_file": "alter_range_type_acl_description.sql", + "expected_msql_file": "alter_range_type_acl_description.msql" + }, + { + "type": "alter", + "name": "alter ACL (Remove privilege)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "deleted": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "alter ACL (change grantee)", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "msql_endpoint": "NODE-type.msql_id", + "data": { + "typacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "U", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_acl_grantee_change.sql", + "expected_msql_file": "alter_acl_grantee_change_msql.sql" + }, + { + "type": "delete", + "name": "Drop RANGE type", + "endpoint": "NODE-type.obj_id", + "sql_endpoint": "NODE-type.sql_id", + "data": {} + } + ] +} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql index dc752a2ec..48f3cfe44 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql @@ -163,7 +163,11 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed -%} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {%- endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql index 291b7760a..ee8072484 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql @@ -35,7 +35,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql index d49f7fb9f..00a1329f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql index d49f7fb9f..00a1329f2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql index 17c3a5f68..c3558a6fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql @@ -60,7 +60,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql index 38606cc0b..429919f9a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql @@ -43,7 +43,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql index 17c3a5f68..c3558a6fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql @@ -60,7 +60,11 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} {% endif %} {% if 'changed' in data.datacl %} {% for priv in data.datacl.changed %} +{% if priv.grantee != priv.old_grantee %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.old_grantee, data.name, data.schema) }} +{% else %} {{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} +{% endif %} {{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql new file mode 100644 index 000000000..d15b0e6b6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql @@ -0,0 +1,17 @@ +-- View: public.testmview_$%{}[]()&*^!/@`# + +-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"; + +CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" +TABLESPACE pg_default +AS + SELECT 1 +WITH NO DATA; + +ALTER TABLE public."testmview_$%{}[]()&*^!/@`#" + OWNER TO postgres; + +COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" + IS 'comment1'; + +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql new file mode 100644 index 000000000..7e7a5ae53 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" FROM postgres; +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql index b3b83cd0d..09f1e9dfb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql @@ -15,4 +15,3 @@ ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" IS 'Testcomment-updated'; -GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..8165dd5a8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO postgres; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql new file mode 100644 index 000000000..53d6a9071 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" FROM postgres; +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json index 29ff3e27f..fea2f469b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json @@ -131,6 +131,63 @@ "expected_sql_file": "alter_mview_drop_all_priv.sql", "expected_msql_file": "alter_mview_drop_all_priv_msql.sql" }, + { + "type": "alter", + "name": "Alter Materialised Views (change grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "old_grantee": "postgres", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "d", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "D", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "t", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_mview_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_priv_msql.sql" + }, { "type": "alter", "name": "Alter Materialised Views (change definition)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json index 14e121653..fb185dfe3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json @@ -32,7 +32,7 @@ "check_option": "local", "security_barrier": false, "comment":"Testcomment", - "datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, + "datacl":[{"grantee":"postgres", "old_grantee": "postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, "with_grant":false}]}] }, "expected_sql_file": "create_view.sql", @@ -51,7 +51,7 @@ "check_option": "cascaded", "security_barrier": true, "comment":"Testcomment-updated", - "datacl":[{"grantee":"postgres", "grantor":"postgres", "privileges":[{"privilege_type": "a", "privilege": true, + "datacl":[{"grantee":"postgres", "grantor":"postgres", "old_grantee": "postgres", "privileges":[{"privilege_type": "a", "privilege": true, "with_grant":false}]}] }, "expected_sql_file": "alter_view.sql", @@ -101,7 +101,72 @@ "expected_sql_file": "alter_view_add_some_priv.sql", "expected_msql_file": "alter_view_add_some_priv_msql.sql" }, - { + { + "type": "alter", + "name": "Alter View (deleting privileges (PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (postgres to PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "postgres", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"postgres", + "old_grantee": "postgres", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_priv_msql.sql" + }, + { "type": "alter", "name": "Alter View (deleting privileges)", "endpoint": "NODE-view.obj_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql new file mode 100644 index 000000000..b55277594 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql @@ -0,0 +1,17 @@ +-- View: public.testmview_$%{}[]()&*^!/@`# + +-- DROP MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#"; + +CREATE MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" +TABLESPACE pg_default +AS + SELECT 1 +WITH NO DATA; + +ALTER TABLE public."testmview_$%{}[]()&*^!/@`#" + OWNER TO enterprisedb; + +COMMENT ON MATERIALIZED VIEW public."testmview_$%{}[]()&*^!/@`#" + IS 'comment1'; + +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql new file mode 100644 index 000000000..af097c577 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" FROM enterprisedb; +GRANT ALL ON TABLE public."testmview_$%{}[]()&*^!/@`#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql index d267e529c..fbd46ee55 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql @@ -14,5 +14,3 @@ ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" OWNER TO enterprisedb; COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" IS 'Testcomment-updated'; - -GRANT ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql new file mode 100644 index 000000000..3db18ba28 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql @@ -0,0 +1,19 @@ +-- View: public.testview_$%{}[]()&*^!@"'`\/# + +-- DROP VIEW public."testview_$%{}[]()&*^!@""'`\/#"; + +CREATE OR REPLACE VIEW public."testview_$%{}[]()&*^!@""'`\/#" +WITH ( + check_option=cascaded, + security_barrier=true +) AS + SELECT test_view_table.col1 + FROM test_view_table; + +ALTER TABLE public."testview_$%{}[]()&*^!@""'`\/#" + OWNER TO enterprisedb; +COMMENT ON VIEW public."testview_$%{}[]()&*^!@""'`\/#" + IS 'Testcomment-updated'; + +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; + diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql new file mode 100644 index 000000000..be69754a6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql @@ -0,0 +1,2 @@ +REVOKE ALL ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; +GRANT SELECT ON TABLE public."testview_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json index 33d0f9ba7..d0586836c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json @@ -131,6 +131,63 @@ "expected_sql_file": "alter_mview_drop_all_priv.sql", "expected_msql_file": "alter_mview_drop_all_priv_msql.sql" }, + { + "type": "alter", + "name": "Alter Materialised Views (change grantee in privileges)", + "endpoint": "NODE-mview.obj_id", + "sql_endpoint": "NODE-mview.sql_id", + "msql_endpoint": "NODE-mview.msql_id", + "data": { + "datacl": { + "changed": [ + { + "grantee": "PUBLIC", + "grantor": "enterprisedb", + "old_grantee": "enterprisedb", + "privileges": [ + { + "privilege_type": "a", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "w", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "d", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "D", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "x", + "privilege": true, + "with_grant": false + }, + { + "privilege_type": "t", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_mview_change_grantee_priv.sql", + "expected_msql_file": "alter_mview_change_grantee_priv_msql.sql" + }, { "type": "alter", "name": "Alter Materialised Views (change definition)", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json index f76190c2b..7e311ed96 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json @@ -82,6 +82,71 @@ }, "expected_sql_file": "alter_view_add_some_priv.sql", "expected_msql_file": "alter_view_add_some_priv_msql.sql" + }, + { + "type": "alter", + "name": "Alter View (deleting privileges (PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "enterprisedb", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "deleted":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + } + }, + { + "type": "alter", + "name": "Alter View (changing privileges (enterprisedb to PUBLIC))", + "endpoint": "NODE-view.obj_id", + "sql_endpoint": "NODE-view.sql_id", + "msql_endpoint": "NODE-view.msql_id", + "data": { + "name": "testview_$%{}[]()&*^!@\"'`\\/#", + "owner": "enterprisedb", + "schema": "public", + "check_option": "cascaded", + "security_barrier": true, + "comment":"Testcomment-updated", + "datacl": + { + "changed":[ + { + "grantee":"PUBLIC", + "grantor":"enterprisedb", + "old_grantee": "enterprisedb", + "privileges":[ + { + "privilege_type":"r", + "privilege":true, + "with_grant":false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_view_update_priv.sql", + "expected_msql_file": "alter_view_update_priv_msql.sql" }, { "type": "alter", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json index 413c284dc..9dace550b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/view_test_data.json @@ -999,6 +999,7 @@ { "grantee": "PUBLIC", "grantor": "postgres", + "old_grantee": "postgres", "privileges": [ { "privilege_type": "a", diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js index 9a0e419e6..bc1ad7e82 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js @@ -503,8 +503,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', */ collection.each(function(m) { m.set( - {'privilege': allPrivilege, 'with_grant': allWithGrant}, - {silent: true} + {'privilege': allPrivilege, 'with_grant': allWithGrant} ); }); } else { @@ -539,7 +538,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', } else if (!checked) { $allGrants.prop('checked', false); } - collection.get(privilege_type).set(attrs, {silent: true}); + collection.get(privilege_type).set(attrs); if (checked) { $allPrivileges = $tbl.find( diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py index 6eb5f0eaa..e074ea735 100644 --- a/web/pgadmin/browser/server_groups/servers/utils.py +++ b/web/pgadmin/browser/server_groups/servers/utils.py @@ -125,12 +125,20 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]): priv_with_grant = ['ALL'] if len(priv_without_grant) == allowed_acls_len > 1: priv_without_grant = ['ALL'] + + grantee = driver.qtIdent(None, priv['grantee']) \ + if priv['grantee'] != 'PUBLIC' else 'PUBLIC' + + old_grantee = driver.qtIdent(None, priv['old_grantee']) \ + if 'old_grantee' in priv and priv['old_grantee'] != 'PUBLIC' \ + else grantee + # Appending and returning all ACL privileges.append({ - 'grantee': driver.qtIdent(None, priv['grantee']) - if priv['grantee'] != 'PUBLIC' else 'PUBLIC', + 'grantee': grantee, 'with_grant': priv_with_grant, - 'without_grant': priv_without_grant + 'without_grant': priv_without_grant, + 'old_grantee': old_grantee }) return privileges ^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: [pgAdmin] RM6117 Unable to update column level privileges from security tab. @ 2021-02-10 12:26 Akshay Joshi <[email protected]> parent: Rahul Shirsat <[email protected]> 0 siblings, 0 replies; 7+ messages in thread From: Akshay Joshi @ 2021-02-10 12:26 UTC (permalink / raw) To: Rahul Shirsat <[email protected]>; +Cc: Nikhil Mohite <[email protected]>; Aditya Toshniwal <[email protected]>; pgadmin-hackers Thanks, patch applied. On Wed, Feb 10, 2021 at 3:13 PM Rahul Shirsat < [email protected]> wrote: > Hi Team, > > The above observation is fixed. Please find the updated patch below. > > On Wed, Feb 10, 2021 at 12:57 PM Nikhil Mohite < > [email protected]> wrote: > >> Hi Rahul, >> >> While reviewing the patch, found one observation with update privileges. >> 1. While creating a table add any privileges for any user and save. (e.g: >> Add Insert to user1) >> 2. Open table properties and update privileges for the same user by >> editing the privilege (e.g: Now Add Update to user1), check "Save" button >> is enabled.(Don't save the new privileges ) >> 3. Now if we retore the privilege to older values "Save" button remains >> enabled. (e.g: Deselect "Update" from privilege.) >> 4. SQL is also getting generated after restoring the privilege to older >> values. >> [image: image.png] >> >> >> Regards, >> Nikhil Mohite. >> >> >> >> On Tue, Feb 9, 2021 at 4:45 PM Akshay Joshi < >> [email protected]> wrote: >> >>> Hi Nikhil >>> >>> Can you please review the patch thoroughly? >>> >>> On Mon, Feb 8, 2021 at 3:28 PM Rahul Shirsat < >>> [email protected]> wrote: >>> >>>> Akshay, >>>> >>>> Removed some whitespace warnings. While this new patch is applied there >>>> are still 2 unknown whitespace warnings which are pointing to the wrong >>>> location. >>>> >>>> Could you please let me know if this works? >>>> >>>> On Mon, Feb 8, 2021 at 9:53 AM Aditya Toshniwal < >>>> [email protected]> wrote: >>>> >>>>> Hi Rahul, >>>>> >>>>> On Sat, Feb 6, 2021 at 1:25 AM Rahul Shirsat < >>>>> [email protected]> wrote: >>>>> >>>>>> Hi Hackers, >>>>>> >>>>>> Please find the attached patch which resolves the issue of unable to >>>>>> update column level privileges in the security tab. >>>>>> >>>>>> Additionally, when the user tries to change grantee, the sql wasn't >>>>>> generating, this too issue is resolved. >>>>>> >>>>>> This security privilege issue is resolved for the following nodes: >>>>>> >>>>>> 1.) Tables (test cases are skipped as there are no resql test cases >>>>>> based on pg & ppas) >>>>>> 2.) Columns >>>>>> 3.) Views >>>>>> 4.) MViews >>>>>> 5.) Types >>>>>> 6.) Functions >>>>>> 7.) Procedures >>>>>> 8.) Trigger functions >>>>>> 9.) Sequences >>>>>> 10.) Schema >>>>>> >>>>>> P.S for committer : Warning of whitespaces after applying patch >>>>>> should be ignored as it is a part of resql test case results. >>>>>> >>>>> Probably change the SQL generation logic to avoid the trailing >>>>> whitespaces ? >>>>> >>>>>> >>>>>> -- >>>>>> *Rahul Shirsat* >>>>>> Senior Software Engineer | EnterpriseDB Corporation. >>>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks, >>>>> Aditya Toshniwal >>>>> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com* >>>>> <http://edbpostgres.com; >>>>> "Don't Complain about Heat, Plant a TREE" >>>>> >>>> >>>> >>>> -- >>>> *Rahul Shirsat* >>>> Senior Software Engineer | EnterpriseDB Corporation. >>>> >>> >>> >>> -- >>> *Thanks & Regards* >>> *Akshay Joshi* >>> *pgAdmin Hacker | Principal Software Architect* >>> *EDB Postgres <http://edbpostgres.com>* >>> >>> *Mobile: +91 976-788-8246* >>> >> > > -- > *Rahul Shirsat* > Senior Software Engineer | EnterpriseDB Corporation. > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Principal Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* Attachments: [image/png] image.png (40.2K, 3-image.png) download | view image ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2021-02-10 12:26 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-02-05 19:54 [pgAdmin] RM6117 Unable to update column level privileges from security tab. Rahul Shirsat <[email protected]> 2021-02-08 04:23 ` Aditya Toshniwal <[email protected]> 2021-02-08 09:58 ` Rahul Shirsat <[email protected]> 2021-02-09 11:15 ` Akshay Joshi <[email protected]> 2021-02-10 07:27 ` Nikhil Mohite <[email protected]> 2021-02-10 09:42 ` Rahul Shirsat <[email protected]> 2021-02-10 12:26 ` Akshay Joshi <[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