diff --git a/docs/en_US/release_notes_6_13.rst b/docs/en_US/release_notes_6_13.rst index f07ce1cf5..6a67ab217 100644 --- a/docs/en_US/release_notes_6_13.rst +++ b/docs/en_US/release_notes_6_13.rst @@ -15,6 +15,7 @@ Housekeeping ************ | `Issue #7344 `_ - Port Role Reassign dialog to React. + | `Issue #7462 `_ - Remove the SQL files for the unsupported versions of the database server. | `Issue #7567 `_ - Port About dialog to React. | `Issue #7590 `_ - Port change ownership dialog to React. | `Issue #7595 `_ - Update the container base image to Alpine 3.16 (with Python 3.10.5). @@ -23,5 +24,6 @@ Bug fixes ********* | `Issue #7497 `_ - Fixed an issue with the error message being displayed at the right place for Azure deployments. + | `Issue #7527 `_ - Fixed API test cases for Postgres 14.4. | `Issue #7563 `_ - Fixed an issue where autocomplete is not working after clearing the query editor. | `Issue #7573 `_ - Ensure that autocomplete does not appear when navigating code using arrow keys. diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py index fc16bb248..3bc8f2fa3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py @@ -194,7 +194,8 @@ class EventTriggerView(PGChildNodeView, SchemaDiffObjectCompare): PG_DEFAULT_DRIVER ).connection_manager(kwargs['sid']) self.conn = self.manager.connection(did=kwargs['did']) - self.template_path = 'event_triggers/sql/9.3_plus' + self.template_path = 'event_triggers/sql/#{0}#'.format( + self.manager.version) self.datistemplate = False if ( diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/delete.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/delete.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/delete.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/eventfunctions.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/eventfunctions.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/eventfunctions.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/eventfunctions.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/get_db.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/get_db.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/get_db.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/get_db.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/get_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/get_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/get_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/grant.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/grant.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/grant.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/properties.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/update.sql rename to web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/default/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/alter_extension_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/alter_extension_schema.sql deleted file mode 100644 index a10200dbb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/alter_extension_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Extension: sslinfo - --- DROP EXTENSION sslinfo; - -CREATE EXTENSION IF NOT EXISTS sslinfo - SCHEMA public - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/alter_extension_version.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/alter_extension_version.sql deleted file mode 100644 index eb160b99d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/alter_extension_version.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Extension: citext - --- DROP EXTENSION citext; - -CREATE EXTENSION IF NOT EXISTS citext - SCHEMA public - VERSION "1.1"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/create_extension_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/create_extension_with_all_options.sql deleted file mode 100644 index 93acdedf5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/create_extension_with_all_options.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Extension: sslinfo - --- DROP EXTENSION sslinfo; - -CREATE EXTENSION IF NOT EXISTS sslinfo - SCHEMA test_extension_schema - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/create_extension_with_default_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/create_extension_with_default_schema.sql deleted file mode 100644 index 30f3adea7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/create_extension_with_default_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Extension: citext - --- DROP EXTENSION citext; - -CREATE EXTENSION IF NOT EXISTS citext - SCHEMA public - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_alter_extension_version.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_alter_extension_version.sql deleted file mode 100644 index e7cdd682b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_alter_extension_version.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER EXTENSION citext - UPDATE TO "1.1"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_create_extension_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_create_extension_with_all_options.sql deleted file mode 100644 index 108c1e110..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_create_extension_with_all_options.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE EXTENSION sslinfo - SCHEMA test_extension_schema - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_create_extension_with_default_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_create_extension_with_default_schema.sql deleted file mode 100644 index 970822669..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_create_extension_with_default_schema.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE EXTENSION citext - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/tests.json deleted file mode 100644 index c411799d1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/tests.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Extension with all options", - "endpoint": "NODE-extension.obj", - "sql_endpoint": "NODE-extension.sql_id", - "msql_endpoint": "NODE-extension.msql", - "data": { - "name": "sslinfo", - "schema": "test_extension_schema", - "version": "1.0" - }, - "expected_sql_file": "create_extension_with_all_options.sql", - "expected_msql_file": "msql_create_extension_with_all_options.sql", - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';" - }, - { - "type": "alter", - "name": "Alter Extension schema", - "endpoint": "NODE-extension.obj_id", - "sql_endpoint": "NODE-extension.sql_id", - "msql_endpoint": "NODE-extension.msql_id", - "data": { - "schema": "public" - }, - "expected_sql_file": "alter_extension_schema.sql", - "expected_msql_file": "msql_alter_extension_schema.sql", - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';" - }, - { - "type": "delete", - "name": "Drop Extension with all options", - "endpoint": "NODE-extension.obj_id", - "data": {}, - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';" - }, - { - "type": "create", - "name": "Create Extension with default schema", - "endpoint": "NODE-extension.obj", - "sql_endpoint": "NODE-extension.sql_id", - "msql_endpoint": "NODE-extension.msql", - "data": { - "name": "citext", - "version": "1.0" - }, - "expected_sql_file": "create_extension_with_default_schema.sql", - "expected_msql_file": "msql_create_extension_with_default_schema.sql", - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='citext' and e2.version='1.0';" - }, - { - "type": "alter", - "name": "Alter Extension version", - "endpoint": "NODE-extension.obj_id", - "sql_endpoint": "NODE-extension.sql_id", - "msql_endpoint": "NODE-extension.msql_id", - "data": { - "version": "1.1" - }, - "expected_sql_file": "alter_extension_version.sql", - "expected_msql_file": "msql_alter_extension_version.sql", - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='citext' and e2.version='1.1';" - }, - { - "type": "delete", - "name": "Drop Extension default schema", - "endpoint": "NODE-extension.obj_id", - "data": {}, - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='citext' and e2.version='1.1';" - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/alter_extension_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/alter_extension_schema.sql deleted file mode 100644 index a10200dbb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/alter_extension_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Extension: sslinfo - --- DROP EXTENSION sslinfo; - -CREATE EXTENSION IF NOT EXISTS sslinfo - SCHEMA public - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/create_extension_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/create_extension_with_all_options.sql deleted file mode 100644 index 93acdedf5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/create_extension_with_all_options.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Extension: sslinfo - --- DROP EXTENSION sslinfo; - -CREATE EXTENSION IF NOT EXISTS sslinfo - SCHEMA test_extension_schema - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/msql_alter_extension_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/msql_alter_extension_schema.sql deleted file mode 100644 index 11cb0a221..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/msql_alter_extension_schema.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER EXTENSION sslinfo - SET SCHEMA public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/msql_create_extension_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/msql_create_extension_with_all_options.sql deleted file mode 100644 index 108c1e110..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/msql_create_extension_with_all_options.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE EXTENSION sslinfo - SCHEMA test_extension_schema - VERSION "1.0"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/tests.json deleted file mode 100644 index b530049bd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.5_plus/tests.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Extension with all options", - "endpoint": "NODE-extension.obj", - "sql_endpoint": "NODE-extension.sql_id", - "msql_endpoint": "NODE-extension.msql", - "data": { - "name": "sslinfo", - "schema": "test_extension_schema", - "version": "1.0" - }, - "expected_sql_file": "create_extension_with_all_options.sql", - "expected_msql_file": "msql_create_extension_with_all_options.sql", - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';" - }, - { - "type": "alter", - "name": "Alter Extension schema", - "endpoint": "NODE-extension.obj_id", - "sql_endpoint": "NODE-extension.sql_id", - "msql_endpoint": "NODE-extension.msql_id", - "data": { - "schema": "public" - }, - "expected_sql_file": "alter_extension_schema.sql", - "expected_msql_file": "msql_alter_extension_schema.sql", - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';" - }, - { - "type": "delete", - "name": "Drop Extension with all options", - "endpoint": "NODE-extension.obj_id", - "data": {}, - "precondition_sql": "select count(e1.name) \nfrom pg_available_extensions e1, pg_available_extension_versions e2\nwhere e1.name = e2.name and e1.name='sslinfo' and e2.version='1.0';" - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_alter_extension_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_alter_extension_schema.sql deleted file mode 100644 index 11cb0a221..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_alter_extension_schema.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER EXTENSION sslinfo - SET SCHEMA public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/alter_extension_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/alter_extension_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/alter_extension_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/alter_extension_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/alter_extension_version.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/alter_extension_version.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/alter_extension_version.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/alter_extension_version.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/create_extension_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/create_extension_with_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/create_extension_with_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/create_extension_with_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/create_extension_with_default_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/create_extension_with_default_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/create_extension_with_default_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/create_extension_with_default_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_alter_extension_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_alter_extension_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.4_plus/msql_alter_extension_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_alter_extension_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_alter_extension_version.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_alter_extension_version.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_alter_extension_version.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_alter_extension_version.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_create_extension_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_create_extension_with_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_create_extension_with_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_create_extension_with_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_create_extension_with_default_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_create_extension_with_default_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/msql_create_extension_with_default_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/msql_create_extension_with_default_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/tests.json b/web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/tests.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/extensions/tests/9.6_plus/tests.json rename to web/pgadmin/browser/server_groups/servers/databases/extensions/tests/default/tests.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/acl.sql deleted file mode 100644 index 71735320c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/acl.sql +++ /dev/null @@ -1,22 +0,0 @@ -SELECT 'fsrvacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT srvacl FROM pg_catalog.pg_foreign_server fsrv - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - fsrv.oid=descr.objoid AND descr.classoid='pg_foreign_server'::regclass) -{% if fsid %} - WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID -{% endif %} - ) acl, - pg_catalog.aclexplode(srvacl) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname -ORDER BY grantee diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/create.sql deleted file mode 100644 index d2e63d83d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/create.sql +++ /dev/null @@ -1,33 +0,0 @@ -{# ============= Create foreign server ============= #} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% if data.name %} -CREATE SERVER {{ conn|qtIdent(data.name) }}{% if data.fsrvtype %} - - TYPE {{ data.fsrvtype|qtLiteral }}{% endif %}{% if data.fsrvversion %} - - VERSION {{ data.fsrvversion|qtLiteral }}{%-endif %}{% if fdwdata %} - - FOREIGN DATA WRAPPER {{ conn|qtIdent(fdwdata.name) }}{% endif %}{% if data.fsrvoptions %} - -{% if is_valid_options %} - OPTIONS ({% for variable in data.fsrvoptions %}{% if loop.index != 1 %}, {% endif %} -{{ conn|qtIdent(variable.fsrvoption) }} {{ variable.fsrvvalue|qtLiteral }}{% endfor %}){% endif %}{% endif %}; - -{# ============= Set the owner for foreign server ============= #} -{% if data.fsrvowner %} -ALTER SERVER {{ conn|qtIdent(data.name) }} - OWNER TO {{ conn|qtIdent(data.fsrvowner) }}; -{% endif %} -{# ============= Set the comment for foreign server ============= #} -{% if data.description %} - -COMMENT ON SERVER {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; - -{% endif %} -{# ============= Set the ACL for foreign server ============= #} -{% if data.fsrvacl %} -{% for priv in data.fsrvacl %} -{{ PRIVILEGE.APPLY(conn, 'FOREIGN SERVER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/properties.sql deleted file mode 100644 index 3fd87ac1e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/9.3_plus/properties.sql +++ /dev/null @@ -1,30 +0,0 @@ -{# ============= Give all the properties of foreign server ============= #} -{% if fdwid %} -SELECT fdw.oid as fdwoid, fdwname as name -FROM pg_catalog.pg_foreign_data_wrapper fdw -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass) -WHERE fdw.oid={{fdwid}}::oid -{% else %} -SELECT srv.oid, srvname as name, srvfdw as fdwid, srvtype as fsrvtype, srvversion as fsrvversion, -fdw.fdwname as fdwname, description, srvoptions AS fsrvoptions, -pg_catalog.pg_get_userbyid(srvowner) as fsrvowner, pg_catalog.array_to_string(srvacl::text[], ', ') as acl -FROM pg_catalog.pg_foreign_server srv -LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=srv.oid AND des.objsubid=0 AND des.classoid='pg_foreign_server'::regclass) -{% if data and fdwdata %} -WHERE fdw.fdwname = {{ fdwdata.name|qtLiteral }}::text and srvname = {{ data.name|qtLiteral }}::text -{% elif fdwdata %} -WHERE fdw.fdwname = {{fdwdata.name|qtLiteral}}::text -{% endif %} -{% if fid %} -WHERE srvfdw={{fid}}::oid -{% endif %} -{% if fsid %} -WHERE srv.oid={{fsid}}::oid -{% endif %} -{% if schema_diff %} -WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = srv.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY srvname; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/acl.sql index 76a519352..71735320c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/acl.sql @@ -11,17 +11,12 @@ FROM LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( fsrv.oid=descr.objoid AND descr.classoid='pg_foreign_server'::regclass) {% if fsid %} - WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID + WHERE fsrv.oid = {{ fsid|qtLiteral }}::OID {% endif %} ) acl, - (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM (SELECT pg_catalog.aclexplode(srvacl) as d FROM pg_catalog.pg_foreign_server fsrv1 - {% if fsid %} - WHERE fsrv1.oid = {{ fsid|qtLiteral }}::OID ) a - {% endif %} + pg_catalog.aclexplode(srvacl) d ) d - ) d LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) GROUP BY g.rolname, gt.rolname +ORDER BY grantee diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql index 1c664e971..d2e63d83d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/create.sql @@ -1,6 +1,6 @@ {# ============= Create foreign server ============= #} {% import 'macros/privilege.macros' as PRIVILEGE %} -{% if data %} +{% if data.name %} CREATE SERVER {{ conn|qtIdent(data.name) }}{% if data.fsrvtype %} TYPE {{ data.fsrvtype|qtLiteral }}{% endif %}{% if data.fsrvversion %} @@ -15,7 +15,6 @@ CREATE SERVER {{ conn|qtIdent(data.name) }}{% if data.fsrvtype %} {# ============= Set the owner for foreign server ============= #} {% if data.fsrvowner %} - ALTER SERVER {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.fsrvowner) }}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/properties.sql index 03e0a6689..3fd87ac1e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/templates/foreign_servers/sql/default/properties.sql @@ -1,13 +1,12 @@ {# ============= Give all the properties of foreign server ============= #} {% if fdwid %} -SELECT fdw.oid as fdwoid, - fdwname as name +SELECT fdw.oid as fdwoid, fdwname as name FROM pg_catalog.pg_foreign_data_wrapper fdw LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass) WHERE fdw.oid={{fdwid}}::oid {% else %} -SELECT srv.oid, srvname as name, srvtype as fsrvtype, srvversion as fsrvversion, fdw.fdwname as fdwname, description, -srvoptions AS fsrvoptions, +SELECT srv.oid, srvname as name, srvfdw as fdwid, srvtype as fsrvtype, srvversion as fsrvversion, +fdw.fdwname as fdwname, description, srvoptions AS fsrvoptions, pg_catalog.pg_get_userbyid(srvowner) as fsrvowner, pg_catalog.array_to_string(srvacl::text[], ', ') as acl FROM pg_catalog.pg_foreign_server srv LEFT OUTER JOIN pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid=srvfdw @@ -23,5 +22,9 @@ WHERE srvfdw={{fid}}::oid {% if fsid %} WHERE srv.oid={{fsid}}::oid {% endif %} +{% if schema_diff %} +WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = srv.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END +{% endif %} ORDER BY srvname; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_comment_version.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_comment_version.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_comment_version_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_comment_version_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_comment_version_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_options_privileges.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_options_privileges.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_options_privileges_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_options_privileges_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_options_privileges_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_remove_options_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_remove_options_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_remove_options_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/alter_remove_options_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/alter_remove_options_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/create_fs_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/create_fs_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/create_fs_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/create_fs_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/create_fs_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/test_foreign_servers.json b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/test_foreign_servers.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/9.3_plus/test_foreign_servers.json rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/pg/default/test_foreign_servers.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_comment_version.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_comment_version.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_comment_version_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_comment_version_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_comment_version_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_options_privileges.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_options_privileges.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_options_privileges_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_options_privileges_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_options_privileges_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_remove_options_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_remove_options_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_remove_options_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/alter_remove_options_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/alter_remove_options_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/create_fs_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/create_fs_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/create_fs_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/create_fs_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/create_fs_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/test_foreign_servers.json b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/test_foreign_servers.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/9.3_plus/test_foreign_servers.json rename to web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/tests/ppas/default/test_foreign_servers.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/acl.sql deleted file mode 100644 index c4fc13910..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/acl.sql +++ /dev/null @@ -1,22 +0,0 @@ -SELECT 'fdwacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT fdwacl FROM pg_catalog.pg_foreign_data_wrapper fdw - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - fdw.oid=descr.objoid AND descr.classoid='pg_foreign_data_wrapper'::regclass) -{% if fid %} - WHERE fdw.oid = {{ fid|qtLiteral }}::OID -{% endif %} - ) acl, - pg_catalog.aclexplode(fdwacl) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname -ORDER BY grantee diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/create.sql deleted file mode 100644 index a29fd75b1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/create.sql +++ /dev/null @@ -1,31 +0,0 @@ -{# ============= Create foreign data wrapper ============= #} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% if data.name %} -CREATE FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}{% if data.fdwvalue %} - - VALIDATOR {{ data.fdwvalue }}{%endif%}{% if data.fdwhan %} - - HANDLER {{ data.fdwhan }}{% endif %}{% if data.fdwoptions %} - -{% if is_valid_options %} - OPTIONS ({% for variable in data.fdwoptions %}{% if loop.index != 1 %}, {% endif %} -{{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% endfor %}){% endif %}{% endif %}; - -{# ============= Set the owner for foreign data wrapper ============= #} -{% if data.fdwowner %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - OWNER TO {{ conn|qtIdent(data.fdwowner) }}; - -{% endif %} -{# ============= Comment on of foreign data wrapper object ============= #} -{% if data.description %} -COMMENT ON FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; - -{% endif %} -{# ============= Create ACL for foreign data wrapper ============= #} -{% if data.fdwacl %} -{% for priv in data.fdwacl %} -{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/properties.sql deleted file mode 100644 index 1c21a5583..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/properties.sql +++ /dev/null @@ -1,30 +0,0 @@ -{# ============= Get all the properties of foreign data wrapper ============= #} -SELECT fdw.oid, fdwname as name, fdwhandler, fdwvalidator, description, - fdwoptions AS fdwoptions, pg_catalog.pg_get_userbyid(fdwowner) as fdwowner, pg_catalog.array_to_string(fdwacl::text[], ', ') as acl, - CASE - -- EPAS in redwood mode, concatenation of a string with NULL results as the original string - WHEN vp.proname IS NULL THEN NULL - ELSE pg_catalog.quote_ident(vp_nsp.nspname)||'.'||pg_catalog.quote_ident(vp.proname) - END fdwvalue, - CASE - -- EPAS in redwood mode, concatenation of a string with NULL results as the original string - WHEN vh.proname IS NULL THEN NULL - ELSE pg_catalog.quote_ident(vh_nsp.nspname)||'.'||pg_catalog.quote_ident(vh.proname) - END fdwhan -FROM pg_catalog.pg_foreign_data_wrapper fdw - LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler - LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator - LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace - LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass) -{% if fid %} -WHERE fdw.oid={{fid}}::oid -{% endif %} -{% if fname %} -WHERE fdw.fdwname={{ fname|qtLiteral }}::text -{% endif %} -{% if schema_diff %} -WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = fdw.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY fdwname diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/update.sql deleted file mode 100644 index aeae3f79d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/9.3_plus/update.sql +++ /dev/null @@ -1,86 +0,0 @@ -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% if data %} -{# ============= Update foreign data wrapper name ============= #} -{% if data.name != o_data.name %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; - -{% endif %} -{# ============= Update foreign data wrapper owner ============= #} -{% if data.fdwowner and data.fdwowner != o_data.fdwowner %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - OWNER TO {{ conn|qtIdent(data.fdwowner) }}; - -{% endif %} -{# ============= Update foreign data wrapper validator ============= #} -{% if data.fdwvalue and data.fdwvalue != o_data.fdwvalue %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - VALIDATOR {{ data.fdwvalue }}; - -{% endif %} -{% if (data.fdwvalue == '' or data.fdwvalue == None) and data.fdwvalue != o_data.fdwvalue %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - NO VALIDATOR; - -{% endif %} -{# ============= Update foreign data wrapper handler ============= #} -{% if data.fdwhan and data.fdwhan != o_data.fdwhan %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - HANDLER {{ data.fdwhan }}; - -{% endif %} -{% if (data.fdwhan == '' or data.fdwhan == None) and data.fdwhan != o_data.fdwhan %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - NO HANDLER; - -{% endif %} -{# ============= Update foreign data wrapper comments ============= #} -{% if data.description is defined and data.description != o_data.description %} -COMMENT ON FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; - -{% endif %} -{# ============= Update foreign data wrapper options and values ============= #} -{% if data.fdwoptions and data.fdwoptions.deleted and data.fdwoptions.deleted|length > 0 %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - OPTIONS ({% for variable in data.fdwoptions.deleted %}{% if loop.index != 1 %}, {% endif %} -DROP {{ conn|qtIdent(variable.fdwoption) }}{% endfor %} -); - -{% endif %} -{% if data.fdwoptions and data.fdwoptions.added %} -{% if is_valid_added_options %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - OPTIONS ({% for variable in data.fdwoptions.added %}{% if loop.index != 1 %}, {% endif %} -ADD {{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% endfor %} -); - -{% endif %} -{% endif %} -{% if data.fdwoptions and data.fdwoptions.changed %} -{% if is_valid_changed_options %} -ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} - OPTIONS ({% for variable in data.fdwoptions.changed %}{% if loop.index != 1 %}, {% endif %} -SET {{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% endfor %} -); - -{% endif %} -{% endif %} -{# Change the privileges #} -{% if data.fdwacl %} -{% if 'deleted' in data.fdwacl %} -{% for priv in data.fdwacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.fdwacl %} -{% for priv in data.fdwacl.changed %} -{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }} -{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} -{% endif %} -{% if 'added' in data.fdwacl %} -{% for priv in data.fdwacl.added %} -{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/acl.sql index 505c32f02..c4fc13910 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/acl.sql @@ -14,14 +14,8 @@ FROM WHERE fdw.oid = {{ fid|qtLiteral }}::OID {% endif %} ) acl, - (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM (SELECT pg_catalog.aclexplode(fdwacl) as d FROM pg_catalog.pg_foreign_data_wrapper fdw1 - {% if fid %} - WHERE fdw1.oid = {{ fid|qtLiteral }}::OID ) a - {% endif %} - ) d - ) d + pg_catalog.aclexplode(fdwacl) d + ) d LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) GROUP BY g.rolname, gt.rolname diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/create.sql index 5805807a6..a29fd75b1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/create.sql @@ -26,7 +26,6 @@ COMMENT ON FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }} {# ============= Create ACL for foreign data wrapper ============= #} {% if data.fdwacl %} {% for priv in data.fdwacl %} -{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} +{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} {% endif %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/properties.sql index da4105966..1c21a5583 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/properties.sql @@ -12,15 +12,19 @@ SELECT fdw.oid, fdwname as name, fdwhandler, fdwvalidator, description, ELSE pg_catalog.quote_ident(vh_nsp.nspname)||'.'||pg_catalog.quote_ident(vh.proname) END fdwhan FROM pg_catalog.pg_foreign_data_wrapper fdw -LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler -LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator -LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace -LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass) + LEFT OUTER JOIN pg_catalog.pg_proc vh on vh.oid=fdwhandler + LEFT OUTER JOIN pg_catalog.pg_proc vp on vp.oid=fdwvalidator + LEFT OUTER JOIN pg_catalog.pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace + LEFT OUTER JOIN pg_catalog.pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace + LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass) {% if fid %} WHERE fdw.oid={{fid}}::oid {% endif %} {% if fname %} WHERE fdw.fdwname={{ fname|qtLiteral }}::text {% endif %} +{% if schema_diff %} +WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = fdw.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END +{% endif %} ORDER BY fdwname diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/update.sql index 21b26e301..aeae3f79d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/templates/foreign_data_wrappers/sql/default/update.sql @@ -70,12 +70,13 @@ SET {{ conn|qtIdent(variable.fdwoption) }} {{ variable.fdwvalue|qtLiteral }}{% e {% if data.fdwacl %} {% if 'deleted' in data.fdwacl %} {% for priv in data.fdwacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }}{% endfor %} +{{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }} +{% endfor %} {% endif %} {% if 'changed' in data.fdwacl %} {% for priv in data.fdwacl.changed %} {{ PRIVILEGE.RESETALL(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name) }} -{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} +{{ PRIVILEGE.APPLY(conn, 'FOREIGN DATA WRAPPER', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} {% if 'added' in data.fdwacl %} {% for priv in data.fdwacl.added %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/acl.sql deleted file mode 100644 index 219165e06..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/acl.sql +++ /dev/null @@ -1,20 +0,0 @@ -SELECT 'lanacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT lanacl FROM pg_catalog.pg_language lan - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass) - WHERE lan.oid = {{ lid|qtLiteral }}::OID - ) acl, - pg_catalog.aclexplode(lanacl) d - ) d -LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname -ORDER BY grantee diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/sqlpane.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/sqlpane.sql deleted file mode 100644 index 363578974..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/sqlpane.sql +++ /dev/null @@ -1,42 +0,0 @@ -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/security.macros' as SECLABEL %} --- Language: {{data.name}} - --- DROP LANGUAGE IF EXISTS {{ conn|qtIdent(data.name) }} - -{# ============= CREATE LANGUAGE Query ============= #} -CREATE{% if add_replace_clause %} OR REPLACE{% endif %}{% if data.trusted %} TRUSTED{% endif %} PROCEDURAL LANGUAGE {{ conn|qtIdent(data.name) }} -{% if data.lanproc %} - HANDLER {{ conn|qtIdent(data.lanproc) }} -{% endif %} -{% if data.laninl %} - INLINE {{ conn|qtIdent(data.laninl) }} -{% endif %} -{% if data.lanval %} - VALIDATOR {{ conn|qtIdent(data.lanval) }}{% endif %}; -{# ============= ALTER LANGUAGE Query ============= #} -{% if data.lanowner %} - -ALTER LANGUAGE {{ conn|qtIdent(data.name) }} - OWNER TO {{ conn|qtIdent(data.lanowner) }}; -{% endif %} -{# ============= Comment on LANGUAGE Query ============= #} -{% if data.description %} - -COMMENT ON LANGUAGE {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif %} -{# ============= PRIVILEGES on LANGUAGE ============= #} -{% if data.lanacl and data.lanacl|length > 0 %} - -{% for priv in data.lanacl %} -{{ PRIVILEGE.APPLY(conn, 'LANGUAGE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{# ============= PRIVILEGES on LANGUAGE ============= #} -{% if data.seclabels and data.seclabels|length > 0 %} - -{% for r in data.seclabels %} -{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/acl.sql index 0ce02cc2a..219165e06 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/default/acl.sql @@ -12,11 +12,7 @@ FROM LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass) WHERE lan.oid = {{ lid|qtLiteral }}::OID ) acl, - (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM (SELECT pg_catalog.aclexplode(lanacl) as d FROM pg_catalog.pg_language lan1 - WHERE lan1.oid = {{ lid|qtLiteral }}::OID ) a - ) d + pg_catalog.aclexplode(lanacl) d ) d LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication_event.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication_event.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication_event.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication_event.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication_event_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication_event_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication_event_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication_event_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/alter_publication_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/alter_publication_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication_update.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication_update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication_update.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication_update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication_update_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication_update_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/create_publication_update_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/create_publication_update_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/test.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/publications/tests/10_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/publications/tests/default/test.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/10_plus/create.sql deleted file mode 100644 index 8d29fcb67..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/10_plus/create.sql +++ /dev/null @@ -1,25 +0,0 @@ -{% if data %} -CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }} -{# if user has provided lc_collate & lc_type #} -{% if data.lc_collate and data.lc_type %} - (LC_COLLATE = {{ data.lc_collate|qtLiteral }}, LC_CTYPE = {{ data.lc_type|qtLiteral }}); -{% endif %} -{# if user has provided locale only #} -{% if data.locale %} - (LOCALE = {{ data.locale|qtLiteral }}); -{% endif %} -{# if user has choosed to copy from existing collation #} -{% if data.copy_collation %} - FROM {{ data.copy_collation }}; -{% endif %} -{% if data.owner %} - -ALTER COLLATION {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.description %} - -COMMENT ON COLLATION {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/default/create.sql index a924bda30..8d29fcb67 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/templates/collations/sql/default/create.sql @@ -1,10 +1,5 @@ {% if data %} -{% if not data.lc_collate and not data.lc_type and not data.locale and not data.copy_collation %} CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }} - FROM pg_catalog."default"; -{% else %} -CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }} -{% endif %} {# if user has provided lc_collate & lc_type #} {% if data.lc_collate and data.lc_type %} (LC_COLLATE = {{ data.lc_collate|qtLiteral }}, LC_CTYPE = {{ data.lc_type|qtLiteral }}); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/templates/domain_constraints/sql/default/get_type_category.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/templates/domain_constraints/sql/default/get_type_category.sql new file mode 100644 index 000000000..3d92443f1 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/templates/domain_constraints/sql/default/get_type_category.sql @@ -0,0 +1,5 @@ +SELECT + typcategory +FROM + pg_catalog.pg_type +WHERE typname = {{datatype}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/create.sql deleted file mode 100644 index c8cc08313..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/create.sql +++ /dev/null @@ -1,41 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% if data %} -CREATE DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} - AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname and data.collname != "pg_catalog.\"default\"" %} - - COLLATE {{ data.collname }}{% endif %}{% if data.typdefault %} - - DEFAULT {{ data.typdefault }}{% endif %}{% if data.typnotnull %} - - NOT NULL{% endif %}; - -{% if data.owner %} -ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} OWNER TO {{ conn|qtIdent(data.owner) }};{% endif %} - -{% if data.constraints %} -{% for c in data.constraints %}{% if c.conname and c.consrc %} - -ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} - ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% endif -%}; -{% if c.description %} - -COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} - IS '{{ c.description }}'; -{% endif %} -{% endfor -%} -{% endif %} - -{% if data.description %} -COMMENT ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} - IS '{{ data.description }}';{% endif -%} - -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - - -{{ SECLABEL.SET(conn, 'DOMAIN', data.name, r.provider, r.label, data.basensp) }}{% endif -%} -{% endfor -%} -{% endif -%} - -{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/get_collations.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/get_collations.sql deleted file mode 100644 index ec6f83b5b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/get_collations.sql +++ /dev/null @@ -1,10 +0,0 @@ -SELECT --nspname, collname, - CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN - pg_catalog.concat(nspname, '."', collname,'"') - ELSE '' END AS copy_collation -FROM - pg_catalog.pg_collation c, pg_catalog.pg_namespace n -WHERE - c.collnamespace=n.oid -ORDER BY - nspname, collname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/get_constraints.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/get_constraints.sql deleted file mode 100644 index e813a2c91..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/get_constraints.sql +++ /dev/null @@ -1,15 +0,0 @@ -SELECT - 'DOMAIN' AS objectkind, c.oid as conoid, conname, typname as relname, nspname, description, - pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as consrc, connoinherit, convalidated -FROM - pg_catalog.pg_constraint c -JOIN - pg_catalog.pg_type t ON t.oid=contypid -JOIN - pg_catalog.pg_namespace nl ON nl.oid=typnamespace -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass) -WHERE - contype = 'c' AND contypid = {{doid}}::oid -ORDER BY - conname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/node.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/node.sql deleted file mode 100644 index 0ae54e860..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/node.sql +++ /dev/null @@ -1,21 +0,0 @@ -SELECT - d.oid, d.typname as name, pg_catalog.pg_get_userbyid(d.typowner) as owner, - bn.nspname as basensp -FROM - pg_catalog.pg_type d -JOIN - pg_catalog.pg_type b ON b.oid = d.typbasetype -JOIN - pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace -{% if scid is defined %} -WHERE - d.typnamespace = {{scid}}::oid -{% elif doid %} -WHERE d.oid = {{doid}}::oid -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = d.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - d.typname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/properties.sql deleted file mode 100644 index 8201ad622..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,34 +0,0 @@ -SELECT - d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype, pg_catalog.pg_get_userbyid(d.typowner) as owner, - c.oid AS colloid, pg_catalog.format_type(b.oid, d.typtypmod) AS fulltype, - CASE WHEN length(cn.nspname::text) > 0 AND length(c.collname::text) > 0 THEN - pg_catalog.concat(cn.nspname, '."', c.collname,'"') - ELSE '' END AS collname, - d.typtypmod, d.typnotnull, d.typdefault, d.typndims, d.typdelim, bn.nspname as basensp, - description, (SELECT COUNT(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=d.typname) > 1 AS domisdup, - (SELECT COUNT(1) FROM pg_catalog.pg_type t3 WHERE t3.typname=b.typname) > 1 AS baseisdup, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=d.oid) AS seclabels -FROM - pg_catalog.pg_type d -JOIN - pg_catalog.pg_type b ON b.oid = d.typbasetype -JOIN - pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=d.oid AND des.classoid='pg_type'::regclass) -LEFT OUTER JOIN - pg_catalog.pg_collation c ON d.typcollation=c.oid -LEFT OUTER JOIN - pg_catalog.pg_namespace cn ON c.collnamespace=cn.oid -WHERE - d.typnamespace = {{scid}}::oid -{% if doid %} - AND d.oid={{doid}}::oid -{% endif %} -ORDER BY - d.typname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/update.sql deleted file mode 100644 index acd093da7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/update.sql +++ /dev/null @@ -1,100 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% if data %} -{% set name = o_data.name %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.typnotnull and not o_data.typnotnull %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - SET NOT NULL; -{% elif 'typnotnull' in data and not data.typnotnull and o_data.typnotnull%} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - DROP NOT NULL; -{% endif -%}{% if data.typdefault %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - SET DEFAULT {{ data.typdefault }}; -{% elif (data.typdefault == '' or data.typdefault == None) and data.typdefault != o_data.typdefault %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - DROP DEFAULT; -{% endif -%}{% if data.owner %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif -%}{% if data.constraints %} -{% for c in data.constraints.deleted %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - DROP CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }}; -{% endfor -%} -{% if data.is_schema_diff is defined and data.is_schema_diff %} -{% for c in data.constraints.changed %} -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - DROP CONSTRAINT {{ conn|qtIdent(c.conname) }}; - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%}; - -{% if c.description is defined and c.description != '' %} -COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - IS {{ c.description|qtLiteral }};{% endif %} -{% endfor -%} -{% else %} -{% for c in data.constraints.changed %} -{% if c.conname and c.conname !=o_data['constraints'][c.conoid]['conname'] %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - RENAME CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }} TO {{ conn|qtIdent(c.conname) }}; -{% endif %} -{% if c.convalidated and not o_data['constraints'][c.conoid]['convalidated'] %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }}; -{% endif %} -{% endfor -%} -{% endif %} -{% for c in data.constraints.added %} -{% if c.conname and c.consrc %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%};{% endif -%} - -{% if c.description %} - -COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - IS '{{ c.description }}'; -{% endif %} -{% endfor -%}{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }} - -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }} -{% endfor %} -{% endif -%}{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }} -{% endfor %} -{% endif -%}{% if data.description is defined and data.description != o_data.description %} - -COMMENT ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - IS {{ data.description|qtLiteral }}; -{% endif -%}{% if data.basensp %} - -ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - SET SCHEMA {{ conn|qtIdent(data.basensp) }};{% endif -%} -{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/create.sql index e0cfe9a42..c8cc08313 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/create.sql @@ -1,24 +1,35 @@ {% import 'macros/schemas/security.macros' as SECLABEL %} {% if data %} CREATE DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} - AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname %} + AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname and data.collname != "pg_catalog.\"default\"" %} COLLATE {{ data.collname }}{% endif %}{% if data.typdefault %} DEFAULT {{ data.typdefault }}{% endif %}{% if data.typnotnull %} - NOT NULL{% endif %}{% if data.constraints %}{% for c in data.constraints %}{% if c.conname and c.consrc %} - - CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% endif -%} -{% endfor -%} -{% endif -%}; + NOT NULL{% endif %}; {% if data.owner %} -ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} OWNER TO {{ conn|qtIdent(data.owner) }};{% endif %}{% if data.description %} +ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} OWNER TO {{ conn|qtIdent(data.owner) }};{% endif %} +{% if data.constraints %} +{% for c in data.constraints %}{% if c.conname and c.consrc %} +ALTER DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} + ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% endif -%}; +{% if c.description %} + +COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} + IS '{{ c.description }}'; +{% endif %} +{% endfor -%} +{% endif %} + +{% if data.description %} COMMENT ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }} - IS '{{ data.description }}';{% endif -%}{% if data.seclabels %} + IS '{{ data.description }}';{% endif -%} + +{% if data.seclabels %} {% for r in data.seclabels %} {% if r.label and r.provider %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/domain_schema_diff.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/domain_schema_diff.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/domain_schema_diff.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/domain_schema_diff.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_collations.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_collations.sql index 214683b97..ec6f83b5b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_collations.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_collations.sql @@ -1,5 +1,5 @@ SELECT --nspname, collname, - CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN + CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN pg_catalog.concat(nspname, '."', collname,'"') ELSE '' END AS copy_collation FROM diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_constraints.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_constraints.sql index bf432ec26..e813a2c91 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_constraints.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/get_constraints.sql @@ -1,6 +1,6 @@ SELECT 'DOMAIN' AS objectkind, c.oid as conoid, conname, typname as relname, nspname, description, - pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as cons + pg_catalog.regexp_replace(pg_catalog.pg_get_constraintdef(c.oid, true), E'CHECK \\((.*)\\).*', E'\\1') as consrc, connoinherit, convalidated FROM pg_catalog.pg_constraint c JOIN @@ -10,6 +10,6 @@ JOIN LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_constraint'::regclass) WHERE - contype = 'c' - AND contypid = {{doid}}::oid -ORDER BY conname; + contype = 'c' AND contypid = {{doid}}::oid +ORDER BY + conname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/node.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/node.sql index 1e089211d..0ae54e860 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/node.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/node.sql @@ -7,11 +7,15 @@ JOIN pg_catalog.pg_type b ON b.oid = d.typbasetype JOIN pg_catalog.pg_namespace bn ON bn.oid=d.typnamespace -{% if scid %} +{% if scid is defined %} WHERE d.typnamespace = {{scid}}::oid {% elif doid %} WHERE d.oid = {{doid}}::oid {% endif %} +{% if schema_diff %} + AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = d.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END +{% endif %} ORDER BY d.typname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql index 7148bf761..8201ad622 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/properties.sql @@ -1,6 +1,5 @@ SELECT - d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype, - pg_catalog.pg_get_userbyid(d.typowner) as owner, + d.oid, d.typname as name, d.typbasetype, pg_catalog.format_type(b.oid,NULL) as basetype, pg_catalog.pg_get_userbyid(d.typowner) as owner, c.oid AS colloid, pg_catalog.format_type(b.oid, d.typtypmod) AS fulltype, CASE WHEN length(cn.nspname::text) > 0 AND length(c.collname::text) > 0 THEN pg_catalog.concat(cn.nspname, '."', c.collname,'"') @@ -28,8 +27,8 @@ LEFT OUTER JOIN pg_catalog.pg_namespace cn ON c.collnamespace=cn.oid WHERE d.typnamespace = {{scid}}::oid - {% if doid %} - AND d.oid={{doid}}::oid - {% endif %} +{% if doid %} + AND d.oid={{doid}}::oid +{% endif %} ORDER BY d.typname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/update.sql index 9cbe6248d..acd093da7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/default/update.sql @@ -3,7 +3,7 @@ {% set name = o_data.name %} {% if data.name %} {% if data.name != o_data.name %} -ALTER TYPE {{ conn|qtIdent(o_data.basensp, o_data.name) }} +ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, o_data.name) }} RENAME TO {{ conn|qtIdent(data.name) }}; {% set name = data.name %} {% endif %} @@ -20,7 +20,7 @@ ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} SET DEFAULT {{ data.typdefault }}; -{% elif data.typdefault == '' and o_data.typdefault %} +{% elif (data.typdefault == '' or data.typdefault == None) and data.typdefault != o_data.typdefault %} ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} DROP DEFAULT; @@ -32,32 +32,63 @@ ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} {% for c in data.constraints.deleted %} ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - DROP CONSTRAINT {{ conn|qtIdent(c.conname) }}; + DROP CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }}; {% endfor -%} +{% if data.is_schema_diff is defined and data.is_schema_diff %} +{% for c in data.constraints.changed %} +ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} + DROP CONSTRAINT {{ conn|qtIdent(c.conname) }}; + +ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} + ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%}; + +{% if c.description is defined and c.description != '' %} +COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} + IS {{ c.description|qtLiteral }};{% endif %} +{% endfor -%} +{% else %} +{% for c in data.constraints.changed %} +{% if c.conname and c.conname !=o_data['constraints'][c.conoid]['conname'] %} + +ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} + RENAME CONSTRAINT {{ conn|qtIdent(o_data['constraints'][c.conoid]['conname']) }} TO {{ conn|qtIdent(c.conname) }}; +{% endif %} +{% if c.convalidated and not o_data['constraints'][c.conoid]['convalidated'] %} + +ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} + VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }}; +{% endif %} +{% endfor -%} +{% endif %} {% for c in data.constraints.added %} {% if c.conname and c.consrc %} ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} - ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }} );{% endif -%} + ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif -%};{% endif -%} + +{% if c.description %} + +COMMENT ON CONSTRAINT {{ conn|qtIdent(c.conname) }} ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} + IS '{{ c.description }}'; +{% endif %} {% endfor -%}{% endif -%} {% set seclabels = data.seclabels %} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} {{ SECLABEL.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }} -{% endfor -%} -{% endif %} +{% endfor %} +{% endif -%} {% if 'added' in seclabels and seclabels.added|length > 0 %} {% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }} -{% endfor -%} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} +{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }} +{% endfor %} +{% endif -%}{% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }} -{% endfor -%} +{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }} +{% endfor %} {% endif -%}{% if data.description is defined and data.description != o_data.description %} COMMENT ON DOMAIN {{ conn|qtIdent(o_data.basensp, name) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql deleted file mode 100644 index 0cd8fd9b4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql +++ /dev/null @@ -1,47 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}( -{% if data.columns %} -{% for c in data.columns %} - {{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} -{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} -{% endfor %}{% endif %}{% if c.attnotnull %} - NOT NULL{% else %} NULL{% endif %}{% if c.typdefault is defined and c.typdefault is not none %} - DEFAULT {{c.typdefault}}{% endif %}{% if c.collname %} - COLLATE {{c.collname}}{% endif %} -{% if not loop.last %}, -{% endif %}{% endfor -%}{% endif %} - -) - SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if data.ftoptions %} - -{% for o in data.ftoptions %} -{% if o.option is defined and o.value is defined %} -{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} -{% endfor %}{% endif %}; -{% if data.owner %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif -%} -{% if data.description %} - -COMMENT ON FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} - IS '{{ data.description }}'; -{% endif -%} -{% if data.acl %} - -{% for priv in data.acl %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.basensp) }} -{% endfor -%} -{% endif -%} -{% if data.seclabels %} - -{% for r in data.seclabels %}{% if r.label and r.provider %} -{{ SECLABEL.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/delete.sql deleted file mode 100644 index 8b0af2dc6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/delete.sql +++ /dev/null @@ -1,17 +0,0 @@ -{% if scid and foid %} -SELECT - c.relname AS name, nspname as basensp -FROM - pg_catalog.pg_class c -LEFT OUTER JOIN - pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace) -WHERE - c.relnamespace = {{scid}}::oid -AND - c.oid = {{foid}}::oid; -{% endif %} - - -{% if name %} -DROP FOREIGN TABLE IF EXISTS {{ conn|qtIdent(basensp, name) }}{% if cascade%} CASCADE{% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_collations.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_collations.sql deleted file mode 100644 index 9656bb033..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_collations.sql +++ /dev/null @@ -1,9 +0,0 @@ -SELECT --nspname, collname, - CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN - pg_catalog.concat(nspname, '."', collname,'"') - ELSE '' END AS copy_collation -FROM - pg_catalog.pg_collation c, pg_catalog.pg_namespace n -WHERE - c.collnamespace=n.oid -ORDER BY nspname, collname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_columns.sql deleted file mode 100644 index fe9112175..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_columns.sql +++ /dev/null @@ -1,25 +0,0 @@ -SELECT - attname, attndims, atttypmod, attoptions, attfdwoptions, pg_catalog.format_type(t.oid,NULL) AS datatype, - attnotnull, attstattarget, attnum, pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype, - CASE WHEN length(cn.nspname::text) > 0 AND length(cl.collname::text) > 0 THEN - pg_catalog.concat(cn.nspname, '."', cl.collname,'"') ELSE '' END AS collname, - (SELECT COUNT(1) from pg_catalog.pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup, - pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS typdefault -FROM - pg_catalog.pg_attribute att -JOIN - pg_catalog.pg_type t ON t.oid=atttypid -JOIN - pg_catalog.pg_namespace nsp ON t.typnamespace=nsp.oid -LEFT OUTER JOIN - pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum -LEFT OUTER JOIN - pg_catalog.pg_type b ON t.typelem=b.oid -LEFT OUTER JOIN - pg_catalog.pg_collation cl ON att.attcollation=cl.oid -LEFT OUTER JOIN - pg_catalog.pg_namespace cn ON cl.collnamespace=cn.oid -WHERE - att.attrelid={{foid}}::oid - AND attnum>0 -ORDER by attnum; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_constraints.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_constraints.sql deleted file mode 100644 index 4d4c2c04f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_constraints.sql +++ /dev/null @@ -1,7 +0,0 @@ -SELECT - conname, contype, consrc, conislocal -FROM - pg_catalog.pg_constraint -WHERE - conrelid={{foid}}::oid -ORDER by conname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_foreign_servers.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_foreign_servers.sql deleted file mode 100644 index 0964591df..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/get_foreign_servers.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT - srvname -FROM - pg_catalog.pg_foreign_server -ORDER BY - srvname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/properties.sql deleted file mode 100644 index 92e823b73..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,27 +0,0 @@ -SELECT - c.oid, c.relname AS name, c.relacl, pg_catalog.pg_get_userbyid(relowner) AS owner, - ftoptions, srvname AS ftsrvname, description, nspname as basensp, consrc, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=c.oid) AS seclabels -FROM - pg_catalog.pg_class c -JOIN - pg_catalog.pg_foreign_table ft ON c.oid=ft.ftrelid -LEFT OUTER JOIN - pg_catalog.pg_foreign_server fs ON ft.ftserver=fs.oid -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass) -LEFT OUTER JOIN - pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace) -LEFT OUTER JOIN - pg_catalog.pg_constraint cn ON (cn.conrelid=c.oid) -WHERE - c.relnamespace = {{scid}}::oid - {% if foid %} - AND c.oid = {{foid}}::oid - {% endif %} -ORDER BY c.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql deleted file mode 100644 index a8deaa634..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql +++ /dev/null @@ -1,172 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set name = o_data.name %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; - -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.owner %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; - -{% endif -%} -{% if data.columns %} -{% for c in data.columns.deleted %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - DROP COLUMN {{conn|qtIdent(c.attname)}}; - -{% endfor -%} -{% for c in data.columns.added %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %} -{% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} -{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} -{% endfor %}{% endif %} -{% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} -{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %} -{% if c.collname %} COLLATE {{c.collname}}{% endif %}; - -{% endfor -%} -{% for c in data.columns.changed %} -{% set col_name = o_data['columns'][c.attnum]['attname'] %} -{% if c.attname != o_data['columns'][c.attnum]['attname'] %} -{% set col_name = c.attname %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - RENAME COLUMN {{conn|qtIdent(o_data['columns'][c.attnum]['attname'])}} TO {{conn|qtIdent(c.attname)}}; - -{% endif %} -{% if c.attnotnull != o_data['columns'][c.attnum]['attnotnull'] %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.attnotnull %} SET{% else %} DROP{% endif %} NOT NULL; - -{% endif %} -{% if c.datatype != o_data['columns'][c.attnum]['datatype'] or c.typlen != o_data['columns'][c.attnum]['typlen'] or -c.precision != o_data['columns'][c.attnum]['precision'] %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}; - -{% endif %} -{% if c.typdefault is defined and c.typdefault != o_data['columns'][c.attnum]['typdefault'] %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %}; - -{% endif %} -{% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} SET STATISTICS {% if c.attstattarget %}{{c.attstattarget}}{% else %}-1{% endif %}; - -{% endif %} -{% if c.coloptions_updated %} -{% for o in c.coloptions_updated.deleted %} -{% if o.option %} -{% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (DROP {% endif %}{% if not loop.first %}, {% endif %}{{o.option}}{% if loop.last %}){% endif %}; -{% endif %} -{% endfor %} -{% for o in c.coloptions_updated.added %} -{% if o.option is defined and o.value is defined %} -{% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (ADD {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} -{% endif %} -{% endfor %} -{% for o in c.coloptions_updated.changed %} -{% if o.option is defined and o.value is defined %} -{% if loop.first %}ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (SET {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} -{% endif %} -{% endfor %} -{% endif -%} -{% endfor %} -{% endif -%} -{% if data.constraints %} -{% for c in data.constraints.deleted %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - DROP CONSTRAINT {{conn|qtIdent(c.conname)}}; - -{% endfor %} -{% for c in data.constraints.added %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ADD CONSTRAINT {{conn|qtIdent(c.conname)}} {% if c.consrc %} CHECK ({{c.consrc}}){% endif %} {% if c.connoinherit %} NO INHERIT{% endif %}; - -{% endfor %} -{% endif -%} -{% if data.ftoptions %} -{% for o in data.ftoptions.deleted %} -{% if o.option is defined and o.value is defined %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - OPTIONS ( DROP {{o.option}}); - -{% endif %} -{% endfor %} -{% for o in data.ftoptions.added %} -{% if o.option is defined and o.value is defined %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); - -{% endif %} -{% endfor %} -{% for o in data.ftoptions.changed %} -{% if o.option is defined and o.value is defined %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - OPTIONS (SET {{o.option}} {{o.value|qtLiteral}}); - -{% endif %} -{% endfor %} -{% endif -%} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} - -{% endfor %} -{% endif -%} -{% if 'changed' in data.acl %} -{% for priv in data.acl.changed %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} - -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} - -{% endfor %} -{% endif -%} -{% if 'added' in data.acl %} -{% for priv in data.acl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} - -{% endfor %} -{% endif %} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} -COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - IS {{ data.description|qtLiteral }}; - -{% endif -%} -{% if data.basensp %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - SET SCHEMA {{ conn|qtIdent(data.basensp) }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql deleted file mode 100644 index 6cbaafb5b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql +++ /dev/null @@ -1,64 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% set is_columns = [] %} -{% if data %} -CREATE FOREIGN TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.basensp, data.name) }}( -{% if data.columns %} -{% for c in data.columns %} -{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} -{% if is_columns.append('1') %}{% endif %} - {{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} -{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} -{% endfor %}{% endif %} -{% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} -{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %} -{% if c.collname %} COLLATE {{c.collname}}{% endif %} -{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -) -{% if data.inherits %} - INHERITS ({% for i in data.inherits %}{% if i %}{{i}}{% if not loop.last %}, {% endif %}{% endif %}{% endfor %}) -{% endif %} - SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if data.ftoptions %} - -{% for o in data.ftoptions %} -{% if o.option is defined and o.value is defined %} -{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} -{% endfor %}{% endif %}; -{% if data.owner %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif -%} -{% if data.constraints %} -{% for c in data.constraints %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} - ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %}; -{% endfor %} -{% endif %} -{% if data.description %} - -COMMENT ON FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} - IS '{{ data.description }}'; -{% endif -%} -{% if data.acl %} - -{% for priv in data.acl %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.basensp) }} -{% endfor -%} -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_columns.sql deleted file mode 100644 index c75513422..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_columns.sql +++ /dev/null @@ -1,43 +0,0 @@ -WITH INH_TABLES AS - (SELECT - distinct on (at.attname) attname, ph.inhparent AS inheritedid, ph.inhseqno, - pg_catalog.concat(nmsp_parent.nspname, '.',parent.relname ) AS inheritedfrom - FROM - pg_catalog.pg_attribute at - JOIN - pg_catalog.pg_inherits ph ON ph.inhparent = at.attrelid AND ph.inhrelid = {{foid}}::oid - JOIN - pg_catalog.pg_class parent ON ph.inhparent = parent.oid - JOIN - pg_catalog.pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace - GROUP BY at.attname, ph.inhparent, ph.inhseqno, inheritedfrom - ORDER BY at.attname, ph.inhparent, ph.inhseqno, inheritedfrom - ) -SELECT INH.inheritedfrom, INH.inheritedid, att.attoptions, attfdwoptions, - att.attname, att.attndims, att.atttypmod, pg_catalog.format_type(t.oid,NULL) AS datatype, - att.attnotnull, att.attstattarget, att.attnum, pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype, - CASE WHEN length(cn.nspname::text) > 0 AND length(cl.collname::text) > 0 THEN - pg_catalog.concat(cn.nspname, '."', cl.collname,'"') - ELSE '' END AS collname, - pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS typdefault, - (SELECT COUNT(1) from pg_catalog.pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup -FROM - pg_catalog.pg_attribute att -LEFT JOIN - INH_TABLES as INH ON att.attname = INH.attname -JOIN - pg_catalog.pg_type t ON t.oid=atttypid -JOIN - pg_catalog.pg_namespace nsp ON t.typnamespace=nsp.oid -LEFT OUTER JOIN - pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum -LEFT OUTER JOIN - pg_catalog.pg_type b ON t.typelem=b.oid -LEFT OUTER JOIN - pg_catalog.pg_collation cl ON att.attcollation=cl.oid -LEFT OUTER JOIN - pg_catalog.pg_namespace cn ON cl.collnamespace=cn.oid -WHERE - att.attrelid={{foid}}::oid - AND att.attnum>0 - ORDER BY att.attnum; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_constraints.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_constraints.sql deleted file mode 100644 index 4a21fcfe3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_constraints.sql +++ /dev/null @@ -1,7 +0,0 @@ -SELECT - oid as conoid, conname, contype, consrc, connoinherit, convalidated, conislocal -FROM - pg_catalog.pg_constraint -WHERE - conrelid={{foid}}::oid -ORDER by conname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_foreign_servers.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_foreign_servers.sql deleted file mode 100644 index 0e56aa7a2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_foreign_servers.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT - srvname -FROM - pg_catalog.pg_foreign_server -ORDER - BY srvname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/properties.sql deleted file mode 100644 index 116963e33..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/properties.sql +++ /dev/null @@ -1,31 +0,0 @@ -SELECT - c.oid, c.relname AS name, c.relacl, pg_catalog.pg_get_userbyid(relowner) AS owner, - ftoptions, srvname AS ftsrvname, description, nspname AS basensp, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=c.oid) AS seclabels - {% if foid %}, - (SELECT - pg_catalog.array_agg(i.inhparent) FROM pg_catalog.pg_inherits i - WHERE - i.inhrelid = {{foid}}::oid GROUP BY i.inhrelid) AS inherits - {% endif %} -FROM - pg_catalog.pg_class c -JOIN - pg_catalog.pg_foreign_table ft ON c.oid=ft.ftrelid -LEFT OUTER JOIN - pg_catalog.pg_foreign_server fs ON ft.ftserver=fs.oid -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_class'::regclass) -LEFT OUTER JOIN - pg_catalog.pg_namespace nsp ON (nsp.oid=c.relnamespace) -WHERE - c.relnamespace = {{scid}}::oid - {% if foid %} - AND c.oid = {{foid}}::oid - {% endif %} -ORDER BY c.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql deleted file mode 100644 index e78766d20..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql +++ /dev/null @@ -1,216 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set name = o_data.name %} -{% if data.name %}{% if data.name != o_data.name %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; - -{% set name = data.name %} -{% endif %}{% endif %} -{% if data.owner %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; - -{% endif %} -{% if data.columns %} -{% for c in data.columns.deleted %} -{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - DROP COLUMN {{conn|qtIdent(c.attname)}}; - -{% endif %} -{% endfor -%} -{% for c in data.columns.added %} -{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %} -{% if c.coloptions %} -{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} -{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} -{% endfor %}{% endif %} -{% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} -{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %} -{% if c.collname %} COLLATE {{c.collname}}{% endif %}; - -{% endif %} -{% endfor -%} -{% for c in data.columns.changed %} -{% set col_name = o_data['columns'][c.attnum]['attname'] %} -{% if c.attname != o_data['columns'][c.attnum]['attname'] %} -{% set col_name = c.attname %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - RENAME COLUMN {{conn|qtIdent(o_data['columns'][c.attnum]['attname'])}} TO {{conn|qtIdent(c.attname)}}; - -{% endif %} -{% if c.attnotnull != o_data['columns'][c.attnum]['attnotnull'] %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.attnotnull %} SET{% else %} DROP{% endif %} NOT NULL; - -{% endif %} -{% if c.datatype != o_data['columns'][c.attnum]['datatype'] or c.typlen != o_data['columns'][c.attnum]['typlen'] or -c.precision != o_data['columns'][c.attnum]['precision'] %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}; - -{% endif %} -{% if c.typdefault is defined and c.typdefault != o_data['columns'][c.attnum]['typdefault'] %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %}; - -{% endif %} -{% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} SET STATISTICS {% if c.attstattarget %}{{c.attstattarget}}{% else %}-1{% endif %}; - -{% endif %} -{% if c.coloptions_updated %} -{% for o in c.coloptions_updated.deleted %} -{% if o.option %} -{% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (DROP {% endif %}{% if not loop.first %}, {% endif %}{{o.option}}{% if loop.last %}){% endif %}; -{% endif %} -{% endfor %} -{% for o in c.coloptions_updated.added %} -{% if o.option is defined and o.value is defined %} -{% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (ADD {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} -{% endif %} -{% endfor %} -{% for o in c.coloptions_updated.changed %} -{% if o.option is defined and o.value is defined %} -{% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (SET {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} -{% endif %} -{% endfor %} -{% endif -%} -{% endfor %} -{% endif %} -{% if data.inherits and data.inherits|length > 0%} -{% if o_data.inherits == None or o_data.inherits == 'None' %} -{% set inherits = '' %} -{% else %} -{% set inherits = o_data.inherits %} -{% endif %} -{% for i in data.inherits %} -{% if i not in inherits %}{% if i %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} INHERIT {{i}}; -{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{% if o_data.inherits and 'inherits' in data %} -{% if data.inherits == None or data.inherits == 'None' %} -{% set inherits = '' %} -{% else %} -{% set inherits = data.inherits %} -{% endif %} -{% for i in o_data.inherits %}{% if i not in inherits %}{% if i %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} NO INHERIT {{i}};{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{% if data.constraints %} -{% for c in data.constraints.deleted %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - DROP CONSTRAINT {{conn|qtIdent(c.conname)}}; - -{% endfor -%} -{% for c in data.constraints.added %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %}; - -{% endfor %} -{% if data.is_schema_diff is defined and data.is_schema_diff %} -{% for c in data.constraints.changed %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - DROP CONSTRAINT {{conn|qtIdent(c.conname)}}; - -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %}; - -{% endfor %} -{% else %} -{% for c in data.constraints.changed %} -{% if c.convalidated %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }}; - -{% endif %} -{% endfor %} -{% endif %} -{% endif %} -{% if data.ftoptions %} -{% for o in data.ftoptions.deleted %} -{% if o.option is defined and o.value is defined %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - OPTIONS ( DROP {{o.option}}); - -{% endif %} -{% endfor %} -{% for o in data.ftoptions.added %} -{% if o.option is defined and o.value is defined %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); - -{% endif %} -{% endfor %} -{% for o in data.ftoptions.changed %} -{% if o.option is defined and o.value is defined %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - OPTIONS (SET {{o.option}} {{o.value|qtLiteral}}); - -{% endif %} -{% endfor %} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} -COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - IS {{ data.description|qtLiteral }}; - -{% endif -%} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} - -{% endfor %} -{% endif -%} -{% if 'changed' in data.acl %} -{% for priv in data.acl.changed %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} - -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} - -{% endfor %} -{% endif -%} -{% if 'added' in data.acl %} -{% for priv in data.acl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} - -{% endfor %} -{% endif %} -{% endif -%} -{% if data.basensp %} -ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} - SET SCHEMA {{ conn|qtIdent(data.basensp) }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql index 20af14492..6cbaafb5b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/create.sql @@ -1,30 +1,58 @@ {% import 'macros/schemas/security.macros' as SECLABEL %} +{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} +{% set is_columns = [] %} {% if data %} CREATE FOREIGN TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.basensp, data.name) }}( {% if data.columns %} {% for c in data.columns %} - {{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{ c.datatype }}{% if c.typlen %}({{c.typlen}} {% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.attnotnull %} - NOT NULL{% else %} NULL{% endif %} +{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} +{% if is_columns.append('1') %}{% endif %} + {{conn|qtIdent(c.attname)}} {% if is_sql %}{{ c.fulltype }}{% else %}{{c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}{% endif %}{% if c.coloptions %} +{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} +{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} +{% endfor %}{% endif %} +{% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} +{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %} +{% if c.collname %} COLLATE {{c.collname}}{% endif %} {% if not loop.last %}, -{% endif %}{% endfor -%}{% endif %} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} ) +{% if data.inherits %} + INHERITS ({% for i in data.inherits %}{% if i %}{{i}}{% if not loop.last %}, {% endif %}{% endif %}{% endfor %}) +{% endif %} SERVER {{ conn|qtIdent(data.ftsrvname) }}{% if data.ftoptions %} {% for o in data.ftoptions %} {% if o.option is defined and o.value is defined %} {% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} -{% endfor %}{% endif -%}; +{% endfor %}{% endif %}; {% if data.owner %} ALTER FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} OWNER TO {{ conn|qtIdent(data.owner) }}; {% endif -%} +{% if data.constraints %} +{% for c in data.constraints %} + +ALTER FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} + ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %}; +{% endfor %} +{% endif %} {% if data.description %} COMMENT ON FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }} IS '{{ data.description }}'; {% endif -%} +{% if data.acl %} + +{% for priv in data.acl %} +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.basensp) }} +{% endfor -%} +{% endif -%} {% if data.seclabels %} {% for r in data.seclabels %} {% if r.label and r.provider %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/foreign_table_schema_diff.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/foreign_table_schema_diff.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/foreign_table_schema_diff.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/foreign_table_schema_diff.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_columns.sql index 493fbad5d..c75513422 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_columns.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_columns.sql @@ -1,16 +1,43 @@ -SELECT - attname, attndims, atttypmod, pg_catalog.format_type(t.oid,NULL) AS datatype, - pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype, attnotnull, attnum, +WITH INH_TABLES AS + (SELECT + distinct on (at.attname) attname, ph.inhparent AS inheritedid, ph.inhseqno, + pg_catalog.concat(nmsp_parent.nspname, '.',parent.relname ) AS inheritedfrom + FROM + pg_catalog.pg_attribute at + JOIN + pg_catalog.pg_inherits ph ON ph.inhparent = at.attrelid AND ph.inhrelid = {{foid}}::oid + JOIN + pg_catalog.pg_class parent ON ph.inhparent = parent.oid + JOIN + pg_catalog.pg_namespace nmsp_parent ON nmsp_parent.oid = parent.relnamespace + GROUP BY at.attname, ph.inhparent, ph.inhseqno, inheritedfrom + ORDER BY at.attname, ph.inhparent, ph.inhseqno, inheritedfrom + ) +SELECT INH.inheritedfrom, INH.inheritedid, att.attoptions, attfdwoptions, + att.attname, att.attndims, att.atttypmod, pg_catalog.format_type(t.oid,NULL) AS datatype, + att.attnotnull, att.attstattarget, att.attnum, pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype, + CASE WHEN length(cn.nspname::text) > 0 AND length(cl.collname::text) > 0 THEN + pg_catalog.concat(cn.nspname, '."', cl.collname,'"') + ELSE '' END AS collname, + pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS typdefault, (SELECT COUNT(1) from pg_catalog.pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup FROM pg_catalog.pg_attribute att +LEFT JOIN + INH_TABLES as INH ON att.attname = INH.attname JOIN pg_catalog.pg_type t ON t.oid=atttypid JOIN pg_catalog.pg_namespace nsp ON t.typnamespace=nsp.oid +LEFT OUTER JOIN + pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum LEFT OUTER JOIN pg_catalog.pg_type b ON t.typelem=b.oid +LEFT OUTER JOIN + pg_catalog.pg_collation cl ON att.attcollation=cl.oid +LEFT OUTER JOIN + pg_catalog.pg_namespace cn ON cl.collnamespace=cn.oid WHERE att.attrelid={{foid}}::oid - AND attnum>0 -ORDER by attnum; + AND att.attnum>0 + ORDER BY att.attnum; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_constraints.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_constraints.sql index 0ab546d7f..4a21fcfe3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_constraints.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_constraints.sql @@ -1,5 +1,5 @@ SELECT - conname, contype, consrc + oid as conoid, conname, contype, consrc, connoinherit, convalidated, conislocal FROM pg_catalog.pg_constraint WHERE diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_foreign_servers.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_foreign_servers.sql index 6ce5a2962..0e56aa7a2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_foreign_servers.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_foreign_servers.sql @@ -2,4 +2,5 @@ SELECT srvname FROM pg_catalog.pg_foreign_server -ORDER BY srvname; +ORDER + BY srvname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_table_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_table_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_table_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_table_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_tables.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/get_tables.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/properties.sql index c2686f7fc..116963e33 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/properties.sql @@ -1,12 +1,18 @@ SELECT - c.oid, c.relname AS name, pg_catalog.pg_get_userbyid(relowner) AS owner, - ftoptions, srvname AS ftsrvname, description, nspname as basensp, + c.oid, c.relname AS name, c.relacl, pg_catalog.pg_get_userbyid(relowner) AS owner, + ftoptions, srvname AS ftsrvname, description, nspname AS basensp, (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabel sl1 WHERE sl1.objoid=c.oid) AS seclabels + {% if foid %}, + (SELECT + pg_catalog.array_agg(i.inhparent) FROM pg_catalog.pg_inherits i + WHERE + i.inhrelid = {{foid}}::oid GROUP BY i.inhrelid) AS inherits + {% endif %} FROM pg_catalog.pg_class c JOIN diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql index 6539fb151..e78766d20 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/default/update.sql @@ -1,95 +1,181 @@ {% import 'macros/schemas/security.macros' as SECLABEL %} +{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} {% if data %} {% set name = o_data.name %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, o_data.name) }} +{% if data.name %}{% if data.name != o_data.name %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, o_data.name) }} RENAME TO {{ conn|qtIdent(data.name) }}; + {% set name = data.name %} -{% endif %} -{% endif -%} - +{% endif %}{% endif %} {% if data.owner %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif -%} +{% endif %} {% if data.columns %} {% for c in data.columns.deleted %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} DROP COLUMN {{conn|qtIdent(c.attname)}}; + +{% endif %} {% endfor -%} {% for c in data.columns.added %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +{% if (not c.inheritedfrom or c.inheritedfrom =='' or c.inheritedfrom == None or c.inheritedfrom == 'None' ) %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} ADD COLUMN {{conn|qtIdent(c.attname)}} {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %} +{% if c.coloptions %} +{% for o in c.coloptions %}{% if o.option is defined and o.value is defined %} +{% if loop.first %} OPTIONS ({% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %}){% endif %}{% endif %} +{% endfor %}{% endif %} {% if c.attnotnull %} NOT NULL{% else %} NULL{% endif %} -{% if c.typdefault %} DEFAULT {{c.typdefault}}{% endif %} +{% if c.typdefault is defined and c.typdefault is not none %} DEFAULT {{c.typdefault}}{% endif %} {% if c.collname %} COLLATE {{c.collname}}{% endif %}; + +{% endif %} {% endfor -%} {% for c in data.columns.changed %} {% set col_name = o_data['columns'][c.attnum]['attname'] %} {% if c.attname != o_data['columns'][c.attnum]['attname'] %} {% set col_name = c.attname %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} RENAME COLUMN {{conn|qtIdent(o_data['columns'][c.attnum]['attname'])}} TO {{conn|qtIdent(c.attname)}}; + {% endif %} {% if c.attnotnull != o_data['columns'][c.attnum]['attnotnull'] %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.attnotnull %} SET{% else %} DROP{% endif %} NOT NULL; + {% endif %} {% if c.datatype != o_data['columns'][c.attnum]['datatype'] or c.typlen != o_data['columns'][c.attnum]['typlen'] or c.precision != o_data['columns'][c.attnum]['precision'] %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} ALTER COLUMN {{conn|qtIdent(col_name)}} TYPE {{ c.datatype }}{% if c.typlen %}({{c.typlen}}{% if c.precision %}, {{c.precision}}{% endif %}){% endif %}{% if c.isArrayType %}[]{% endif %}; -{% endif %} -{% if c.typdefault != o_data['columns'][c.attnum]['typdefault'] %} +{% endif %} +{% if c.typdefault is defined and c.typdefault != o_data['columns'][c.attnum]['typdefault'] %} ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %}; + ALTER COLUMN {{conn|qtIdent(col_name)}}{% if c.typdefault is defined and c.typdefault != '' %} SET DEFAULT {{c.typdefault}}{% else %} DROP DEFAULT{% endif %}; + +{% endif %} +{% if c.attstattarget != o_data['columns'][c.attnum]['attstattarget'] %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + ALTER COLUMN {{conn|qtIdent(col_name)}} SET STATISTICS {% if c.attstattarget %}{{c.attstattarget}}{% else %}-1{% endif %}; + +{% endif %} +{% if c.coloptions_updated %} +{% for o in c.coloptions_updated.deleted %} +{% if o.option %} +{% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (DROP {% endif %}{% if not loop.first %}, {% endif %}{{o.option}}{% if loop.last %}){% endif %}; +{% endif %} +{% endfor %} +{% for o in c.coloptions_updated.added %} +{% if o.option is defined and o.value is defined %} +{% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (ADD {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} +{% endif %} +{% endfor %} +{% for o in c.coloptions_updated.changed %} +{% if o.option is defined and o.value is defined %} +{% if loop.first %}ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + ALTER COLUMN {{conn|qtIdent(col_name)}} OPTIONS (SET {% endif %}{% if not loop.first %}, {% endif %}{{o.option}} {{o.value|qtLiteral}}{% if loop.last %});{% endif %} {% endif %} {% endfor %} {% endif -%} +{% endfor %} +{% endif %} +{% if data.inherits and data.inherits|length > 0%} +{% if o_data.inherits == None or o_data.inherits == 'None' %} +{% set inherits = '' %} +{% else %} +{% set inherits = o_data.inherits %} +{% endif %} +{% for i in data.inherits %} +{% if i not in inherits %}{% if i %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} INHERIT {{i}}; +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{% if o_data.inherits and 'inherits' in data %} +{% if data.inherits == None or data.inherits == 'None' %} +{% set inherits = '' %} +{% else %} +{% set inherits = data.inherits %} +{% endif %} +{% for i in o_data.inherits %}{% if i not in inherits %}{% if i %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} NO INHERIT {{i}};{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{% if data.constraints %} +{% for c in data.constraints.deleted %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + DROP CONSTRAINT {{conn|qtIdent(c.conname)}}; + +{% endfor -%} +{% for c in data.constraints.added %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %}; + +{% endfor %} +{% if data.is_schema_diff is defined and data.is_schema_diff %} +{% for c in data.constraints.changed %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + DROP CONSTRAINT {{conn|qtIdent(c.conname)}}; + +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + ADD CONSTRAINT {{ conn|qtIdent(c.conname) }} CHECK ({{ c.consrc }}){% if not c.convalidated %} NOT VALID{% endif %}{% if c.connoinherit %} NO INHERIT{% endif %}; + +{% endfor %} +{% else %} +{% for c in data.constraints.changed %} +{% if c.convalidated %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + VALIDATE CONSTRAINT {{ conn|qtIdent(c.conname) }}; + +{% endif %} +{% endfor %} +{% endif %} +{% endif %} {% if data.ftoptions %} {% for o in data.ftoptions.deleted %} {% if o.option is defined and o.value is defined %} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} + OPTIONS ( DROP {{o.option}}); -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} - OPTIONS (DROP {{o.option}}); {% endif %} {% endfor %} {% for o in data.ftoptions.added %} {% if o.option is defined and o.value is defined %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (ADD {{o.option}} {{o.value|qtLiteral}}); + {% endif %} {% endfor %} {% for o in data.ftoptions.changed %} {% if o.option is defined and o.value is defined %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} OPTIONS (SET {{o.option}} {{o.value|qtLiteral}}); + {% endif %} {% endfor %} {% endif -%} {% set seclabels = data.seclabels %} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} + {{ SECLABEL.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }} {% endfor %} -{% endif -%} +{% endif %} {% if 'added' in seclabels and seclabels.added|length > 0 %} {% for r in seclabels.added %} {{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }} {% endfor %} -{% endif -%} +{% endif %} {% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} @@ -97,13 +183,34 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} {% endfor %} {% endif -%} {% if data.description is defined and data.description != o_data.description%} - COMMENT ON FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} IS {{ data.description|qtLiteral }}; + +{% endif -%} +{% if data.acl %} +{% if 'deleted' in data.acl %} +{% for priv in data.acl.deleted %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} + +{% endfor %} +{% endif -%} +{% if 'changed' in data.acl %} +{% for priv in data.acl.changed %} +{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, name, o_data.basensp) }} + +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} + +{% endfor %} +{% endif -%} +{% if 'added' in data.acl %} +{% for priv in data.acl.added %} +{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.basensp) }} + +{% endfor %} +{% endif %} {% endif -%} {% if data.basensp %} - -ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }} +ALTER FOREIGN TABLE IF EXISTS {{ conn|qtIdent(o_data.basensp, name) }} SET SCHEMA {{ conn|qtIdent(data.basensp) }}; {% endif %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_opts.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_opts.sql deleted file mode 100644 index 3bdab4ec9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_opts.sql +++ /dev/null @@ -1,16 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table - OPTIONS (schema_name 'public', table_name 'test_table'); - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO postgres; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_opts_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_opts_msql.sql deleted file mode 100644 index 135e51c3d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_opts_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OPTIONS (ADD schema_name 'public'); - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OPTIONS (ADD table_name 'test_table'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_priv.sql deleted file mode 100644 index 5302f5825..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_priv.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table - OPTIONS (schema_name 'public', table_name 'test_table'); - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO postgres; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_col_opts.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_col_opts.sql deleted file mode 100644 index c0b92879d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_col_opts.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 integer NULL -) - SERVER test_fs_for_foreign_table - OPTIONS (schema_name 'test_public', table_name 'test_table'); - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO postgres; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_col_opts_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_col_opts_msql.sql deleted file mode 100644 index cdb8a27dd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_col_opts_msql.sql +++ /dev/null @@ -1,14 +0,0 @@ -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - DROP COLUMN col2; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col1 DROP NOT NULL; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col1 TYPE integer; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col1 SET STATISTICS -1; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OPTIONS (SET schema_name 'test_public'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_comment_add_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_comment_add_columns.sql deleted file mode 100644 index c7c481cdc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_comment_add_columns.sql +++ /dev/null @@ -1,15 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO postgres; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_comment_add_columns_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_comment_add_columns_msql.sql deleted file mode 100644 index 9041626b6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_comment_add_columns_msql.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN col1 bigint NULL; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN col2 text NULL; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_remove_opts_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_remove_opts_priv.sql deleted file mode 100644 index e12559b23..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_remove_opts_priv.sql +++ /dev/null @@ -1,17 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 integer NULL -) - SERVER test_fs_for_foreign_table - OPTIONS (table_name 'test_table'); - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO postgres; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_remove_opts_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_remove_opts_priv_msql.sql deleted file mode 100644 index 56653c630..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_remove_opts_priv_msql.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OPTIONS ( DROP schema_name); - -REVOKE ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" FROM PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/create_foreign_table_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/create_foreign_table_with_all_options.sql deleted file mode 100644 index 93d7bf899..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/create_foreign_table_with_all_options.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE IF NOT EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table - OPTIONS (schema_name 'public', table_name 'test_table'); - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO postgres; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/create_foreign_table_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/create_foreign_table_with_all_options_msql.sql deleted file mode 100644 index cb3977c0e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/create_foreign_table_with_all_options_msql.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL -) - SERVER test_fs_for_foreign_table - OPTIONS (schema_name 'public', table_name 'test_table'); - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO postgres; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/test_foreign_table.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/test_foreign_table.json deleted file mode 100644 index a30693753..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/test_foreign_table.json +++ /dev/null @@ -1,238 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create FDW for foreign table", - "endpoint": "NODE-foreign_data_wrapper.obj", - "sql_endpoint": "NODE-foreign_data_wrapper.sql_id", - "data": { - "name": "test_fdw_for_foreign_table", - "fdwacl": [], - "fdwoptions": [] - }, - "store_object_id": "True" - }, { - "type": "create", - "name": "Create foreign server for foreign table", - "endpoint": "NODE-foreign_server.obj", - "sql_endpoint": "NODE-foreign_server.sql_id", - "data": { - "name":"test_fs_for_foreign_table" - }, - "store_object_id": "True" - }, { - "type": "create", - "name": "Create Foreign Table with all options", - "endpoint": "NODE-foreign_table.obj", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql", - "data": { - "name": "FT1_$%{}[]()&*^!@\"'`\\/#", - "owner":"postgres", - "schema": "public", - "basensp":"public", - "description":"Test Comment", - "ftsrvname":"test_fs_for_foreign_table", - "columns":[{ - "attname":"col1", - "datatype":"bigint", - "coloptions":[] - },{ - "attname":"col2", - "datatype":"text", - "coloptions":[] - }], - "ftoptions":[{ - "option":"schema_name", - "value":"public" - },{ - "option":"table_name", - "value":"test_table" - }], - "acl":[{ - "grantee":"PUBLIC", - "grantor":"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":"x", - "privilege":true, - "with_grant":false - }] - }] - }, - "expected_sql_file": "create_foreign_table_with_all_options.sql", - "expected_msql_file": "create_foreign_table_with_all_options_msql.sql" - }, { - "type": "delete", - "name": "Drop foreign table", - "endpoint": "NODE-foreign_table.delete_id" - }, - { - "type": "create", - "name": "Create Foreign Table", - "endpoint": "NODE-foreign_table.obj", - "sql_endpoint": "NODE-foreign_table.sql_id", - "data": { - "name": "FT1_$%{}[]()&*^!@\"'`\\/#", - "owner": "postgres", - "schema": "public", - "basensp": "public", - "ftsrvname": "test_fs_for_foreign_table", - "columns": [] - } - }, { - "type": "alter", - "name": "Alter Foreign Table comment and add columns", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "description":"Test Comment", - "columns": { - "added": [{ - "attname":"col1", - "datatype":"bigint", - "coloptions":[] - },{ - "attname":"col2", - "datatype":"text", - "coloptions":[] - }] - } - }, - "expected_sql_file": "alter_comment_add_columns.sql", - "expected_msql_file": "alter_comment_add_columns_msql.sql" - },{ - "type": "alter", - "name": "Alter Foreign Table add options", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "ftoptions": { - "added": [{ - "option":"schema_name", - "value":"public" - },{ - "option":"table_name", - "value":"test_table" - }] - } - }, - "expected_sql_file": "alter_add_opts.sql", - "expected_msql_file": "alter_add_opts_msql.sql" - }, { - "type": "alter", - "name": "Alter Foreign Table add privileges", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "acl":{ - "added": [{ - "grantee":"PUBLIC", - "grantor":"postgres", - "privileges":[{ - "privilege_type":"r", - "privilege":true, - "with_grant":false - }] - }] - } - }, - "expected_sql_file": "alter_add_priv.sql", - "expected_msql_file": "alter_add_priv_msql.sql" - }, { - "type": "alter", - "name": "Alter Foreign Table change option and column", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "ftoptions": { - "changed": [{ - "option":"schema_name", - "value":"test_public" - }] - }, - "columns": { - "changed": [{ - "attname": "col1", - "attnum": 1, - "attoptions": null, - "collname": "", - "coloptions": [], - "datatype": "integer", - "fulltype": "bigint" - }], - "deleted": [{ - "attname":"col2", - "datatype":"text" - }] - } - }, - "expected_sql_file": "alter_col_opts.sql", - "expected_msql_file": "alter_col_opts_msql.sql" - }, { - "type": "alter", - "name": "Alter Foreign Table remove option, privileges", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "acl":{ - "deleted": [{ - "grantee":"PUBLIC", - "grantor":"postgres", - "privileges":[{ - "privilege_type":"a", - "privilege":true, - "with_grant":false - },{ - "privilege_type":"r", - "privilege":true, - "with_grant":false - }] - }] - }, - "ftoptions": { - "deleted": [{ - "option":"schema_name", - "value":"public" - }] - } - }, - "expected_sql_file": "alter_remove_opts_priv.sql", - "expected_msql_file": "alter_remove_opts_priv_msql.sql" - }, { - "type": "delete", - "name": "Drop foreign table", - "endpoint": "NODE-foreign_table.delete_id" - }, { - "type": "delete", - "name": "Drop foreign server", - "endpoint": "NODE-foreign_server.delete_id", - "data": { - "name": "test_fs_for_foreign_table" - } - }, { - "type": "delete", - "name": "Drop FDW", - "endpoint": "NODE-foreign_data_wrapper.delete_id", - "data": { - "name": "test_fdw_for_foreign_table" - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_cons_opts.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_cons_opts.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_cons_opts.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_cons_opts.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_cons_opts_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_cons_opts_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_cons_opts_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_cons_opts_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.2_plus/alter_add_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_add_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_col_opts.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_col_opts.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_col_opts.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_col_opts.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_col_opts_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_col_opts_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_col_opts_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_col_opts_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_comment_add_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_comment_add_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_comment_add_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_comment_add_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_comment_add_columns_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_comment_add_columns_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_comment_add_columns_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_comment_add_columns_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_remove_opts_priv_cons.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_remove_opts_priv_cons.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_remove_opts_priv_cons.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_remove_opts_priv_cons.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_remove_opts_priv_cons_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_remove_opts_priv_cons_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_remove_opts_priv_cons_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/alter_remove_opts_priv_cons_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/create_foreign_table_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/create_foreign_table_with_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/create_foreign_table_with_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/create_foreign_table_with_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/create_foreign_table_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/create_foreign_table_with_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/create_foreign_table_with_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/create_foreign_table_with_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/test_foreign_table.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/test_foreign_table.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/test_foreign_table.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/default/test_foreign_table.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_add_priv.sql deleted file mode 100644 index 944809bd3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_add_priv.sql +++ /dev/null @@ -1,21 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE IF NOT EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL COLLATE pg_catalog."default", - col3 bigint NULL, - col4 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_add_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_add_priv_msql.sql deleted file mode 100644 index 20e9b4847..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_add_priv_msql.sql +++ /dev/null @@ -1 +0,0 @@ -GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_column.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_column.sql deleted file mode 100644 index c32e8dff5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_column.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 integer NULL, - col3 bigint NULL, - col4 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_column_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_column_msql.sql deleted file mode 100644 index a5def018d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_column_msql.sql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - DROP COLUMN col2; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col1 DROP NOT NULL; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col1 TYPE integer; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN col1 SET STATISTICS -1; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_comment_add_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_comment_add_columns.sql deleted file mode 100644 index 32060d40b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_comment_add_columns.sql +++ /dev/null @@ -1,17 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE IF NOT EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL COLLATE pg_catalog."default", - col3 bigint NULL, - col4 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_comment_add_columns_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_comment_add_columns_msql.sql deleted file mode 100644 index 9c0680603..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_comment_add_columns_msql.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN col3 bigint NULL; - -ALTER FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN col4 text NULL; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_remove_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_remove_priv.sql deleted file mode 100644 index 8c0555376..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_remove_priv.sql +++ /dev/null @@ -1,18 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 integer NULL, - col3 bigint NULL, - col4 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_remove_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_remove_priv_msql.sql deleted file mode 100644 index 116553086..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/alter_remove_priv_msql.sql +++ /dev/null @@ -1 +0,0 @@ -REVOKE ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" FROM PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/create_foreign_table_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/create_foreign_table_with_all_options.sql deleted file mode 100644 index 1682bb19c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/create_foreign_table_with_all_options.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FOREIGN TABLE: public.FT1_$%{}[]()&*^!@"'`\/# - --- DROP FOREIGN TABLE IF EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"; - -CREATE FOREIGN TABLE IF NOT EXISTS public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL COLLATE pg_catalog."default" -) - SERVER test_fs_for_foreign_table; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/create_foreign_table_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/create_foreign_table_with_all_options_msql.sql deleted file mode 100644 index 20409f9bf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/create_foreign_table_with_all_options_msql.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#"( - col1 bigint NULL, - col2 text NULL -) - SERVER test_fs_for_foreign_table; - -ALTER FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON FOREIGN TABLE public."FT1_$%{}[]()&*^!@""'`\/#" - IS 'Test Comment'; - -GRANT ALL ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/test_foreign_table.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/test_foreign_table.json deleted file mode 100644 index e917cfa34..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.2_plus/test_foreign_table.json +++ /dev/null @@ -1,225 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create FDW for foreign table", - "endpoint": "NODE-foreign_data_wrapper.obj", - "sql_endpoint": "NODE-foreign_data_wrapper.sql_id", - "data": { - "name": "test_fdw_for_foreign_table", - "fdwhan": "pg_catalog.libpq_fdw_handler", - "fdwvalue": "pg_catalog.postgresql_fdw_validator", - "fdwacl": [], - "fdwoptions": [] - }, - "store_object_id": "True" - }, { - "type": "create", - "name": "Create foreign server for foreign table", - "endpoint": "NODE-foreign_server.obj", - "sql_endpoint": "NODE-foreign_server.sql_id", - "data": { - "name":"test_fs_for_foreign_table", - "fsrvoptions":[{ - "fsrvoption": "dbname", - "fsrvvalue": "$$||current_database()||$$" - },{ - "fsrvoption": "port", - "fsrvvalue": "$$||current_setting('port')||$$" - }] - }, - "store_object_id": "True" - }, { - "type": "create", - "name": "Create User Mapping", - "endpoint": "NODE-user_mapping.obj", - "sql_endpoint": "NODE-user_mapping.sql_id", - "data": { - "name": "enterprisedb" - } - }, { - "type": "create", - "name": "Create Foreign Table with all options", - "endpoint": "NODE-foreign_table.obj", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql", - "data": { - "name": "FT1_$%{}[]()&*^!@\"'`\\/#", - "owner":"enterprisedb", - "schema": "public", - "basensp":"public", - "description":"Test Comment", - "ftsrvname":"test_fs_for_foreign_table", - "columns":[{ - "attname":"col1", - "datatype":"bigint", - "coloptions":[] - },{ - "attname":"col2", - "datatype":"text", - "coloptions":[] - }], - "acl":[{ - "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": "create_foreign_table_with_all_options.sql", - "expected_msql_file": "create_foreign_table_with_all_options_msql.sql" - }, { - "type": "delete", - "name": "Drop foreign table", - "endpoint": "NODE-foreign_table.delete_id" - }, - { - "type": "create", - "name": "Create Foreign Table", - "endpoint": "NODE-foreign_table.obj", - "sql_endpoint": "NODE-foreign_table.sql_id", - "data": { - "name": "FT1_$%{}[]()&*^!@\"'`\\/#", - "owner": "enterprisedb", - "schema": "public", - "basensp": "public", - "ftsrvname": "test_fs_for_foreign_table", - "columns":[{ - "attname":"col1", - "datatype":"bigint", - "coloptions":[] - },{ - "attname":"col2", - "datatype":"text", - "coloptions":[] - }] - } - }, { - "type": "alter", - "name": "Alter Foreign Table comment and add columns", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "description":"Test Comment", - "columns": { - "added": [{ - "attname":"col3", - "datatype":"bigint", - "coloptions":[] - },{ - "attname":"col4", - "datatype":"text", - "coloptions":[] - }] - } - }, - "expected_sql_file": "alter_comment_add_columns.sql", - "expected_msql_file": "alter_comment_add_columns_msql.sql" - }, { - "type": "alter", - "name": "Alter Foreign Table add privileges", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "acl":{ - "added": [{ - "grantee":"PUBLIC", - "grantor":"enterprisedb", - "privileges":[{ - "privilege_type":"r", - "privilege":true, - "with_grant":false - }] - }] - } - }, - "expected_sql_file": "alter_add_priv.sql", - "expected_msql_file": "alter_add_priv_msql.sql" - }, { - "type": "alter", - "name": "Alter Foreign Table change column", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "columns": { - "changed": [{ - "attname": "col1", - "attnum": 1, - "attoptions": null, - "collname": "", - "coloptions": [], - "datatype": "integer", - "fulltype": "bigint" - }], - "deleted": [{ - "attname":"col2", - "datatype":"text" - }] - } - }, - "expected_sql_file": "alter_column.sql", - "expected_msql_file": "alter_column_msql.sql" - }, { - "type": "alter", - "name": "Alter Foreign Table remove option, privileges", - "endpoint": "NODE-foreign_table.obj_id", - "sql_endpoint": "NODE-foreign_table.sql_id", - "msql_endpoint": "NODE-foreign_table.msql_id", - "data": { - "acl":{ - "deleted": [{ - "grantee":"PUBLIC", - "grantor":"enterprisedb", - "privileges":[{ - "privilege_type":"a", - "privilege":true, - "with_grant":false - },{ - "privilege_type":"r", - "privilege":true, - "with_grant":false - }] - }] - } - }, - "expected_sql_file": "alter_remove_priv.sql", - "expected_msql_file": "alter_remove_priv_msql.sql" - }, { - "type": "delete", - "name": "Drop foreign table", - "endpoint": "NODE-foreign_table.delete_id" - }, { - "type": "delete", - "name": "Drop foreign server", - "endpoint": "NODE-foreign_server.delete_id", - "data": { - "name": "test_fs_for_foreign_table" - } - }, { - "type": "delete", - "name": "Drop FDW", - "endpoint": "NODE-foreign_data_wrapper.delete_id", - "data": { - "name": "test_fdw_for_foreign_table" - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_priv_msql.sql deleted file mode 100644 index 20e9b4847..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_priv_msql.sql +++ /dev/null @@ -1 +0,0 @@ -GRANT SELECT ON TABLE public."FT1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_cons_opts.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_cons_opts.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_cons_opts.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_cons_opts.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_cons_opts_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_cons_opts_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_cons_opts_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_cons_opts_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_add_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/pg/9.6_plus/alter_add_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_add_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_col_opts.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_col_opts.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_col_opts.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_col_opts.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_col_opts_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_col_opts_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_col_opts_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_col_opts_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_comment_add_columns.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_comment_add_columns.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_comment_add_columns.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_comment_add_columns.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_comment_add_columns_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_comment_add_columns_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_comment_add_columns_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_comment_add_columns_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_remove_opts_priv_cons.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_remove_opts_priv_cons.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_remove_opts_priv_cons.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_remove_opts_priv_cons.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_remove_opts_priv_cons_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_remove_opts_priv_cons_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/alter_remove_opts_priv_cons_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/alter_remove_opts_priv_cons_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/create_foreign_table_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/create_foreign_table_with_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/create_foreign_table_with_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/create_foreign_table_with_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/create_foreign_table_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/create_foreign_table_with_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/create_foreign_table_with_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/create_foreign_table_with_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/test_foreign_table.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/test_foreign_table.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/9.6_plus/test_foreign_table.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/tests/ppas/default/test_foreign_table.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/create.sql deleted file mode 100644 index 348c510e3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/create.sql +++ /dev/null @@ -1,67 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} -{% else %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} -{% endfor %} -{% endif -%} -) -{% endif -%} - RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER {% endif %} -{% if data.proiswindow %}WINDOW{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor -%} -{% endif -%} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/properties.sql deleted file mode 100644 index ce707101f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT - pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, - pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, - pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, - pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, - typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, - pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals, - pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=pr.oid) AS seclabels -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0) -WHERE - proisagg = FALSE - AND typname NOT IN ('trigger', 'event_trigger') -{% if fnid %} - AND pr.oid = {{fnid}}::oid -{% else %} - AND pronamespace = {{scid}}::oid -{% endif %} -ORDER BY - proname; 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 deleted file mode 100644 index 745877342..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.2_plus/update.sql +++ /dev/null @@ -1,120 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -{% endif -%} -) - RETURNS {% if 'prorettypename' in data %}{{ data.prorettypename }}{% else %}{{ o_data.prorettypename }}{% endif %} - -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} - -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif %} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/create.sql deleted file mode 100644 index 3e6f97f79..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/create.sql +++ /dev/null @@ -1,66 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} -{% else %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -{% endif -%} -) -{% endif %} - RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER {% endif %} -{% if data.proiswindow %}WINDOW{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/properties.sql deleted file mode 100644 index 723bf9684..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/properties.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT - pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, - pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, - pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, - pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, - typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, - pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals, - pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=pr.oid) AS seclabels -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0) -WHERE - proisagg = FALSE -{% if fnid %} - AND pr.oid = {{fnid}}::oid -{% else %} - AND pronamespace = {{scid}}::oid -{% endif %} - AND typname NOT IN ('trigger', 'event_trigger') -ORDER BY - proname; 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 deleted file mode 100644 index ac13a7525..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.5_plus/update.sql +++ /dev/null @@ -1,120 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ -o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} -{% endfor %} -{% endif -%} -) - RETURNS {% if 'prorettypename' in data %}{{ data.prorettypename }}{% else %}{{ o_data.prorettypename }}{% endif %} - -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} - -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/create.sql deleted file mode 100644 index f9cbda510..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/create.sql +++ /dev/null @@ -1,70 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} -{% else %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -{% endif -%} -) -{% endif %} - RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER {% endif %} -{% if data.proiswindow %}WINDOW {% endif %} -{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %} -{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}} -{% endif %} -{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/delete.sql deleted file mode 100644 index 6d0ce90fc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/delete.sql +++ /dev/null @@ -1,21 +0,0 @@ -{% if scid and fnid %} -SELECT - pr.proname as name, '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as func_args, - nspname -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace -WHERE - proisagg = FALSE - AND pronamespace = {{scid}}::oid - AND typname NOT IN ('trigger', 'event_trigger') - AND pr.oid = {{fnid}}; -{% endif %} - -{% if name %} -DROP FUNCTION IF EXISTS {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/properties.sql deleted file mode 100644 index 5c6883761..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/properties.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT - pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, - pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, pr.proparallel, - pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, - pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, - typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, - pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals, - pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=pr.oid) AS seclabels -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0) -WHERE - proisagg = FALSE - AND typname NOT IN ('trigger', 'event_trigger') -{% if fnid %} - AND pr.oid = {{fnid}}::oid -{% else %} - AND pronamespace = {{scid}}::oid -{% endif %} -ORDER BY - proname; 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 deleted file mode 100644 index 916347e13..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/9.6_plus/update.sql +++ /dev/null @@ -1,122 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ -o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} -{% endfor %} -{% endif -%} -) - RETURNS {% if 'prorettypename' in data %}{{ data.prorettypename }}{% else %}{{ o_data.prorettypename }}{% endif %} - -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if 'proparallel' in data and data.proparallel %}PARALLEL {{ data.proparallel }}{% elif 'proparallel' not in data and o_data.proparallel %}PARALLEL {{ o_data.proparallel }}{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} - -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/create.sql index 9556f09c1..f9cbda510 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/create.sql @@ -8,21 +8,29 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} {% else %} CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}}{% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} +{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} +{% if not loop.last %}, {% endif %} {% endfor %} {% endif -%} ) -{% endif -%} +{% endif %} RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} LANGUAGE {{ data.lanname|qtLiteral }} {% if data.procost %} COST {{data.procost}} {% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proisstrict %}STRICT {% endif %}{% if data.prosecdef %}SECURITY DEFINER {% endif %}{% if data.proiswindow %}WINDOW{% endif -%} + {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} +{% if data.proisstrict %}STRICT {% endif %} +{% if data.prosecdef %}SECURITY DEFINER {% endif %} +{% if data.proiswindow %}WINDOW {% endif %} +{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %} +{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %} {% if data.prorows and (data.prorows | int) > 0 %} - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} + + ROWS {{data.prorows}} +{% endif %} +{% if data.variables %}{% for v in data.variables %} SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} {% endif %} @@ -30,12 +38,12 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con AS {% if data.lanname == 'c' %} {{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} {% else %} -$BODY${{ data.prosrc }}$BODY${% endif %}; +$BODY${{ data.prosrc }}$BODY${% endif -%}; {% if data.funcowner %} ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif %} +{% endif -%} {% if data.acl %} {% for p in data.acl %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/delete.sql index 440e36e47..6d0ce90fc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/delete.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/delete.sql @@ -17,5 +17,5 @@ WHERE {% endif %} {% if name %} -DROP FUNCTION {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; +DROP FUNCTION IF EXISTS {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/properties.sql index ce707101f..5c6883761 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/properties.sql @@ -1,7 +1,7 @@ SELECT pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, + pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, pr.proparallel, pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, 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 0122a4f51..916347e13 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 @@ -5,7 +5,8 @@ {% set exclude_quoting = ['search_path'] %} {% if data.name %} {% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ +o_data.proargtypenames }}) RENAME TO {{ conn|qtIdent(data.name) }}; {% set name = data.name %} {% endif %} @@ -14,7 +15,7 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ o_data.pr CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} {% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} +{% if not loop.last %},{% endif %} {% endfor %} {% endif -%} ) @@ -24,13 +25,16 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d LANGUAGE {{ data.lanname|qtLiteral }} {% else %} LANGUAGE {{ o_data.lanname|qtLiteral }} {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} +{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} {% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} {% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} {% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} + {% if 'proparallel' in data and data.proparallel %}PARALLEL {{ data.proparallel }}{% elif 'proparallel' not in data and o_data.proparallel %}PARALLEL {{ o_data.proparallel }}{% endif %} + {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - ROWS {{data.prorows}}{% elif o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} + ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} {% endif %} @@ -43,46 +47,52 @@ $BODY${{ o_data.prosrc }}$BODY${% endif -%}; {% endif -%} {% if data.funcowner %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; {% endif -%} {# The SQL generated below will change priviledges #} {% if data.acl %} {% if 'deleted' in data.acl %} {% for priv in data.acl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% 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 %} +{% endfor %} +{% endif -%} {% if 'added' in data.acl %} {% for priv in data.acl.added %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %}{% endif %} +{% endfor %}{% endif -%} +{% endif -%} {% if data.change_func == False %} {% if data.variables %} {% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} +{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} {% endif -%} {% if 'merged_variables' in data and data.merged_variables|length > 0 %} -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif %} -{% endif %}{% endif %} +{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} +{% endif -%} +{% endif -%} +{% endif -%} {% set seclabels = data.seclabels %} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} +{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} {% if 'added' in seclabels and seclabels.added|length > 0 %} @@ -93,13 +103,16 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endif -%} {% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} + {{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} +{% endfor %} +{% endif -%} {% if data.description is defined and data.description != o_data.description%} COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) IS {{ data.description|qtLiteral }}; {% endif -%} + {% if data.pronamespace %} ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/create.sql deleted file mode 100644 index b87af72e0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/create.sql +++ /dev/null @@ -1,67 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} -{% else %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} -{% endfor %} -{% endif -%} -) -{% endif -%} - RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %} LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER {% endif %} -{% if data.proiswindow %}WINDOW{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_withouts)}} -{% endfor -%} -{% endif -%} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args_withouts) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/delete.sql deleted file mode 100644 index df58941b2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/delete.sql +++ /dev/null @@ -1,22 +0,0 @@ -{% if scid and fnid %} -SELECT - pr.proname as name, '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as func_args, - nspname -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace -WHERE - proisagg = FALSE - AND pronamespace = {{scid}}::oid - AND typname NOT IN ('trigger', 'event_trigger') - AND pr.oid = {{fnid}}; -{% endif %} - -{% if name %} -DROP FUNCTION {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade%} CASCADE{% -endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/get_oid.sql deleted file mode 100644 index 39c785f39..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/get_oid.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - pr.oid, pr.proname || '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as name, - lanname, pg_catalog.pg_get_userbyid(proowner) as funcowner, pr.pronamespace AS nsp -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace - AND nsp.nspname={{ nspname|qtLiteral }} -WHERE - proisagg = FALSE - AND typname NOT IN ('trigger', 'event_trigger') - AND pr.proname = {{ name|qtLiteral }}; 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 deleted file mode 100644 index 56ff2ad4b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.2_plus/update.sql +++ /dev/null @@ -1,120 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -{% endif -%} -) - RETURNS {% if 'prorettypename' in data %}{{ data.prorettypename }}{% else %}{{ o_data.prorettypename }}{% endif %} - -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} - -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif %} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/create.sql deleted file mode 100644 index d79183996..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/create.sql +++ /dev/null @@ -1,64 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} -{% else %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} -{% endfor %} -{% endif -%} - ) -{% endif -%} - RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER {% endif %} -{% if data.proiswindow %}WINDOW{% endif %}{% if data.procost %} - - COST {{data.procost}}{% endif %}{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/delete.sql deleted file mode 100644 index 440e36e47..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/delete.sql +++ /dev/null @@ -1,21 +0,0 @@ -{% if scid and fnid %} -SELECT - pr.proname as name, '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as func_args, - nspname -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace -WHERE - proisagg = FALSE - AND pronamespace = {{scid}}::oid - AND typname NOT IN ('trigger', 'event_trigger') - AND pr.oid = {{fnid}}; -{% endif %} - -{% if name %} -DROP FUNCTION {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; -{% endif %} 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 deleted file mode 100644 index ac13a7525..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.5_plus/update.sql +++ /dev/null @@ -1,120 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ -o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} -{% endfor %} -{% endif -%} -) - RETURNS {% if 'prorettypename' in data %}{{ data.prorettypename }}{% else %}{{ o_data.prorettypename }}{% endif %} - -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} - -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/create.sql deleted file mode 100644 index f9cbda510..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/create.sql +++ /dev/null @@ -1,70 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} -{% else %} -CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -{% endif -%} -) -{% endif %} - RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER {% endif %} -{% if data.proiswindow %}WINDOW {% endif %} -{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %} -{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}} -{% endif %} -{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/delete.sql deleted file mode 100644 index 6d0ce90fc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/delete.sql +++ /dev/null @@ -1,21 +0,0 @@ -{% if scid and fnid %} -SELECT - pr.proname as name, '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as func_args, - nspname -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace -WHERE - proisagg = FALSE - AND pronamespace = {{scid}}::oid - AND typname NOT IN ('trigger', 'event_trigger') - AND pr.oid = {{fnid}}; -{% endif %} - -{% if name %} -DROP FUNCTION IF EXISTS {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/properties.sql deleted file mode 100644 index 5c6883761..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/properties.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT - pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, - pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, pr.proparallel, - pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, - pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, - typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, - pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals, - pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=pr.oid) AS seclabels -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0) -WHERE - proisagg = FALSE - AND typname NOT IN ('trigger', 'event_trigger') -{% if fnid %} - AND pr.oid = {{fnid}}::oid -{% else %} - AND pronamespace = {{scid}}::oid -{% endif %} -ORDER BY - proname; 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 deleted file mode 100644 index 916347e13..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/9.6_plus/update.sql +++ /dev/null @@ -1,122 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ -o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} -{% endfor %} -{% endif -%} -) - RETURNS {% if 'prorettypename' in data %}{{ data.prorettypename }}{% else %}{{ o_data.prorettypename }}{% endif %} - -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if 'proparallel' in data and data.proparallel %}PARALLEL {{ data.proparallel }}{% elif 'proparallel' not in data and o_data.proparallel %}PARALLEL {{ o_data.proparallel }}{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} - -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/create.sql index 223abff76..f9cbda510 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/create.sql @@ -8,21 +8,29 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{func_def}} {% else %} CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %},{% endif %} +{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} +{% if not loop.last %}, {% endif %} {% endfor %} {% endif -%} ) -{% endif -%} +{% endif %} RETURNS{% if data.proretset and (data.prorettypename.startswith('SETOF ') or data.prorettypename.startswith('TABLE')) %} {{ data.prorettypename }} {% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} LANGUAGE {{ data.lanname|qtLiteral }} {% if data.procost %} COST {{data.procost}} {% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proisstrict %}STRICT {% endif %}{% if data.prosecdef %}SECURITY DEFINER {% endif %}{% if data.proiswindow %}WINDOW{% endif -%} + {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} +{% if data.proisstrict %}STRICT {% endif %} +{% if data.prosecdef %}SECURITY DEFINER {% endif %} +{% if data.proiswindow %}WINDOW {% endif %} +{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %} +{% if data.proparallel == 'r' %}PARALLEL RESTRICTED {% elif data.proparallel == 's' %}PARALLEL SAFE {% elif data.proparallel == 'u' %}PARALLEL UNSAFE{% endif %}{% endif %} {% if data.prorows and (data.prorows | int) > 0 %} - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} + + ROWS {{data.prorows}} +{% endif %} +{% if data.variables %}{% for v in data.variables %} SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} {% endif %} @@ -30,12 +38,12 @@ CREATE{% if query_type is defined %}{{' OR REPLACE'}}{% endif %} FUNCTION {{ con AS {% if data.lanname == 'c' %} {{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} {% else %} -$BODY${{ data.prosrc }}$BODY${% endif %}; +$BODY${{ data.prosrc }}$BODY${% endif -%}; {% if data.funcowner %} ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif %} +{% endif -%} {% if data.acl %} {% for p in data.acl %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/delete.sql index 440e36e47..6d0ce90fc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/delete.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/delete.sql @@ -17,5 +17,5 @@ WHERE {% endif %} {% if name %} -DROP FUNCTION {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; +DROP FUNCTION IF EXISTS {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/properties.sql index ce707101f..5c6883761 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/properties.sql @@ -1,7 +1,7 @@ SELECT pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, + pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, pr.proparallel, pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/update.sql index 2564b5d5b..916347e13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/update.sql @@ -5,7 +5,8 @@ {% set exclude_quoting = ['search_path'] %} {% if data.name %} {% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ +o_data.proargtypenames }}) RENAME TO {{ conn|qtIdent(data.name) }}; {% set name = data.name %} {% endif %} @@ -13,8 +14,8 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.pro {% if data.change_func %} CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if data.arguments %} -{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{p.argtype}}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} +{% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} +{% if not loop.last %},{% endif %} {% endfor %} {% endif -%} ) @@ -24,13 +25,16 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({% if d LANGUAGE {{ data.lanname|qtLiteral }} {% else %} LANGUAGE {{ o_data.lanname|qtLiteral }} {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} +{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} {% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} {% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} {% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} + {% if 'proparallel' in data and data.proparallel %}PARALLEL {{ data.proparallel }}{% elif 'proparallel' not in data and o_data.proparallel %}PARALLEL {{ o_data.proparallel }}{% endif %} + {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows and data.prorows != '0' %} - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} + ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} {% endif %} @@ -43,44 +47,52 @@ $BODY${{ o_data.prosrc }}$BODY${% endif -%}; {% endif -%} {% if data.funcowner %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; {% endif -%} {# The SQL generated below will change priviledges #} {% if data.acl %} {% if 'deleted' in data.acl %} {% for priv in data.acl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% 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 %} +{% endfor %} +{% endif -%} {% if 'added' in data.acl %} {% for priv in data.acl.added %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %}{% endif %} +{% endfor %}{% endif -%} +{% endif -%} {% if data.change_func == False %} {% if data.variables %} {% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} +{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} {% endif -%} {% if 'merged_variables' in data and data.merged_variables|length > 0 %} -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif %} -{% endif %}{% endif %} +{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} +{% endif -%} +{% endif -%} +{% endif -%} {% set seclabels = data.seclabels %} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} +{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} {% if 'added' in seclabels and seclabels.added|length > 0 %} @@ -91,13 +103,16 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endif -%} {% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} + {{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} +{% endfor %} +{% endif -%} {% if data.description is defined and data.description != o_data.description%} COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) IS {{ data.description|qtLiteral }}; {% endif -%} + {% if data.pronamespace %} ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.2_plus/create.sql deleted file mode 100644 index 9a4452d63..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.2_plus/create.sql +++ /dev/null @@ -1,42 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE OR REPLACE PROCEDURE {{func_def}} -{% else %} -CREATE{% if add_replace_clause %} OR REPLACE{% endif %} PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}{% if data.arguments is defined %} -({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} - {% if not loop.last %}, {% endif %} -{% endfor -%} -{% endif %} -) -{% endif %} - -AS {{ data.prosrc }}; -{% if data.acl and not is_sql %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "PROCEDURE", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "PROCEDURE", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.2_plus/update.sql deleted file mode 100644 index 866cd9b14..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.2_plus/update.sql +++ /dev/null @@ -1,78 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %}{% if data %} -{% set name = o_data.name %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if data.arguments %}({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -) -{% endif %} -AS {% if data.prosrc %}{{ data.prosrc }}{% else %}{{ o_data.prosrc }}{% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %} - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in data.acl %} -{% for priv in data.acl.changed %} - -{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} - -{{ PRIVILEGE.SET(conn, 'PROCEDURE', 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 %} - -{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif %} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'PROCEDURE', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }} - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.pronamespace %} - -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }} - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/create.sql deleted file mode 100644 index 76162208e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/create.sql +++ /dev/null @@ -1,52 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE OR REPLACE PROCEDURE {{func_def}} -{% else %} -CREATE{% if add_replace_clause %} OR REPLACE{% endif %} PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}{% if data.arguments is defined %} -({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor -%} -){% endif %} - -{% endif %} - {{ data.provolatile }} {% if data.proleakproof %}LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER{% endif %}{% if data.procost %} - - COST {{data.procost}}{% endif %}{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} -{% endif %} - -AS {{ data.prosrc }}; -{% if data.acl and not is_sql %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "PROCEDURE", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "PROCEDURE", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} 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 deleted file mode 100644 index 0b4ed30d0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.5_plus/update.sql +++ /dev/null @@ -1,106 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} -CREATE OR REPLACE PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if data.arguments %}({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -) -{% endif %} - {{ data.provolatile }} {% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %}LEAKPROOF{% else %}NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} -{% endif %} - -AS {% if data.prosrc %}{{ data.prosrc }}{% else %}{{ o_data.prosrc }}{% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %} - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% 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 %} -{% endif -%} -{% if 'added' in data.acl %} -{% for priv in data.acl.added %} - -{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif %} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'PROCEDURE', name, data.variables.deleted, o_data.pronamespace) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'PROCEDURE', name, data.merged_variables, o_data.pronamespace) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'PROCEDURE', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }} - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.pronamespace %} - -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }} - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/create.sql deleted file mode 100644 index 32ab6d1f8..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/create.sql +++ /dev/null @@ -1,60 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -{% if query_for == 'sql_panel' and func_def is defined %} -CREATE OR REPLACE PROCEDURE {{func_def}} -{% else %} -CREATE{% if add_replace_clause %} OR REPLACE{% endif %} PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}{% if data.arguments is defined %} -({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor -%} -){% endif %} - -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} -{% if data.proisstrict %}STRICT {% endif %} -{% if data.prosecdef %}SECURITY DEFINER{% endif %} -{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %} -{% if data.proparallel == 'r' %} PARALLEL RESTRICTED{% elif data.proparallel == 's' %} PARALLEL SAFE {% elif data.proparallel == 'u' %} PARALLEL UNSAFE{% endif %}{% endif %}{% if data.procost %} - - COST {{data.procost}}{% endif %}{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} -{% endif %} - -AS {{ data.prosrc }}; - -{% if data.funcowner %} -ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }} - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} - -{% if data.acl and not is_sql %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "PROCEDURE", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args_without)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "PROCEDURE", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', data.name, r.provider, r.label, data.pronamespace, data.func_args_without) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/properties.sql deleted file mode 100644 index af676f3e3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/properties.sql +++ /dev/null @@ -1,46 +0,0 @@ -SELECT - pr.oid, pr.xmin, - pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, pr.proparallel, - pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, - pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, - typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, - pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals, - pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description, - ( - WITH name_with_args_tab AS (SELECT pg_catalog.pg_get_function_identity_arguments(pr.oid) AS val) - SELECT CASE WHEN - val <> '' - THEN - pr.proname || '(' || val || ')' - ELSE - pr.proname::text - END - FROM name_with_args_tab - ) AS name_with_args, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=pr.oid) AS seclabels -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0) -WHERE - proisagg = FALSE - AND typname NOT IN ('trigger', 'event_trigger') -{% if fnid %} - AND pr.oid = {{fnid}}::oid -{% else %} - AND pronamespace = {{scid}}::oid -{% endif %} -ORDER BY - proname; 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 deleted file mode 100644 index 2030c917c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/9.6_plus/update.sql +++ /dev/null @@ -1,109 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} -CREATE OR REPLACE PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if data.arguments %}({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} -{% if not loop.last %}, {% endif %} -{% endfor %} -) -{% endif %} - - {% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} {% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %}LEAKPROOF{% else %}NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} - - {% if 'proparallel' in data and data.proparallel %}PARALLEL {{ data.proparallel }}{% elif 'proparallel' not in data and o_data.proparallel %}PARALLEL {{ o_data.proparallel }}{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} -{% endif %} - -AS {% if data.prosrc %}{{ data.prosrc }}{% else %}{{ o_data.prosrc }}{% endif %}; -{% endif -%} -{% if data.funcowner %} - -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %} - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'PROCEDURE', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% 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 %} -{% endif -%} -{% if 'added' in data.acl %} -{% for priv in data.acl.added %} - -{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif %} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'PROCEDURE', name, data.variables.deleted, o_data.pronamespace) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'PROCEDURE', name, data.merged_variables, o_data.pronamespace) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'PROCEDURE', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'PROCEDURE', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }} - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.pronamespace %} - -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }} - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/create.sql index ff6f846c9..32ab6d1f8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/create.sql @@ -2,6 +2,7 @@ {% import 'macros/functions/privilege.macros' as PRIVILEGE %} {% import 'macros/functions/variable.macros' as VARIABLE %} {% set is_columns = [] %} +{% set exclude_quoting = ['search_path'] %} {% if data %} {% if query_for == 'sql_panel' and func_def is defined %} CREATE OR REPLACE PROCEDURE {{func_def}} @@ -10,14 +11,26 @@ CREATE{% if add_replace_clause %} OR REPLACE{% endif %} PROCEDURE {{ conn|qtIden ({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname)}} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} {% if not loop.last %}, {% endif %} {% endfor -%} +){% endif %} + {% endif %} -) + {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %} {% endif %}{% if data.proleakproof %}LEAKPROOF {% endif %} +{% if data.proisstrict %}STRICT {% endif %} +{% if data.prosecdef %}SECURITY DEFINER{% endif %} +{% if data.proparallel and (data.proparallel == 'r' or data.proparallel == 's' or data.proparallel == 'u') %} +{% if data.proparallel == 'r' %} PARALLEL RESTRICTED{% elif data.proparallel == 's' %} PARALLEL SAFE {% elif data.proparallel == 'u' %} PARALLEL UNSAFE{% endif %}{% endif %}{% if data.procost %} + + COST {{data.procost}}{% endif %}{% if data.prorows and (data.prorows | int) > 0 %} + + ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} + + SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} {% endif %} AS {{ data.prosrc }}; {% if data.funcowner %} -ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}}) +ALTER PROCEDURE {{ conn|qtIdent(data.pronamespace, data.name) }} OWNER TO {{ conn|qtIdent(data.funcowner) }}; {% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/properties.sql index edf682cab..af676f3e3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/properties.sql @@ -1,7 +1,7 @@ SELECT pr.oid, pr.xmin, pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, + pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, pr.proparallel, pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/update.sql index 6c2a71f71..2030c917c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/update.sql @@ -1,14 +1,14 @@ {% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %}{% if data %} +{% import 'macros/functions/privilege.macros' as PRIVILEGE %} +{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} {% set name = o_data.name %} +{% set exclude_quoting = ['search_path'] %} {% if data.name %} {% if data.name != o_data.name %} -ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}{% if o_data.proargtypenames %}({{ o_data.proargtypenames }}){% endif %} - +ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, o_data.name) }} RENAME TO {{ conn|qtIdent(data.name) }}; {% set name = data.name %} {% endif %} - {% endif -%} {% if data.change_func %} CREATE OR REPLACE PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if data.arguments %}({% for p in data.arguments %}{% if p.argmode %}{{p.argmode}} {% endif %}{% if p.argname %}{{ conn|qtIdent(p.argname) }} {% endif %}{% if p.argtype %}{{ p.argtype }}{% endif %}{% if p.argdefval %} DEFAULT {{p.argdefval}}{% endif %} @@ -17,8 +17,20 @@ CREATE OR REPLACE PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if d ) {% endif %} -AS -{% if data.prosrc %}{{ data.prosrc }}{% else %}{{ o_data.prosrc }}{% endif -%}; + {% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }} {% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} {% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %}LEAKPROOF{% else %}NOT LEAKPROOF{% endif %} +{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} +{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} + + {% if 'proparallel' in data and data.proparallel %}PARALLEL {{ data.proparallel }}{% elif 'proparallel' not in data and o_data.proparallel %}PARALLEL {{ o_data.proparallel }}{% endif %} + + {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} + + ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} + + SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} +{% endif %} + +AS {% if data.prosrc %}{{ data.prosrc }}{% else %}{{ o_data.prosrc }}{% endif %}; {% endif -%} {% if data.funcowner %} @@ -36,10 +48,13 @@ 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) }} +{{ PRIVILEGE.SET(conn, 'PROCEDURE', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} {% if 'added' in data.acl %} @@ -49,6 +64,18 @@ ALTER PROCEDURE {{ conn|qtIdent(o_data.pronamespace, name) }}{% if o_data.proarg {% endfor %} {% endif %} {% endif -%} +{% if data.change_func == False %} +{% if data.variables %} +{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} + +{{ VARIABLE.UNSET(conn, 'PROCEDURE', name, data.variables.deleted, o_data.pronamespace) }} +{% endif -%} +{% if 'merged_variables' in data and data.merged_variables|length > 0 %} + +{{ VARIABLE.SET(conn, 'PROCEDURE', name, data.merged_variables, o_data.pronamespace) }} +{% endif -%} +{% endif -%} +{% endif -%} {% set seclabels = data.seclabels %} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/create.sql deleted file mode 100644 index f9661ff1c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/create.sql +++ /dev/null @@ -1,57 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -CREATE{% if add_replace_clause %} OR REPLACE{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}() - RETURNS{% if data.proretset and data.prorettypename.startswith('SETOF ') %} {{ data.prorettypename }}{% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proleakproof %} LEAKPROOF{% else %} NOT LEAKPROOF{% endif %}{% if data.proisstrict %} STRICT{% endif %} -{% if data.prosecdef %} SECURITY DEFINER{% endif %} -{% if data.proiswindow %} WINDOW{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args)}} -{% endfor -%} -{% endif -%} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/delete.sql deleted file mode 100644 index 42bd27f66..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/delete.sql +++ /dev/null @@ -1,21 +0,0 @@ -{% if scid and fnid %} -SELECT - pr.proname as name, '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as func_args, - nspname -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace -WHERE - proisagg = FALSE - AND pronamespace = {{scid}}::oid - AND typname IN ('trigger', 'event_trigger') - AND pr.oid = {{fnid}}; -{% endif %} - -{% if name %} -DROP FUNCTION {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/get_oid.sql deleted file mode 100644 index 86a720aac..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/get_oid.sql +++ /dev/null @@ -1,18 +0,0 @@ -SELECT - pr.oid, pr.proname || '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as name, - lanname, pg_catalog.pg_get_userbyid(proowner) as funcowner, pr.pronamespace AS nsp -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace - AND nsp.nspname={{ nspname|qtLiteral }} -WHERE - proisagg = FALSE - AND typname IN ('trigger', 'event_trigger') - AND lanname NOT IN ('edbspl', 'sql', 'internal') - AND pr.proname = {{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/node.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/node.sql deleted file mode 100644 index d81f2cd88..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/node.sql +++ /dev/null @@ -1,27 +0,0 @@ -SELECT - pr.oid, pr.proname || '()' as name, - lanname, pg_catalog.pg_get_userbyid(proowner) as funcowner, description -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass) -WHERE - proisagg = FALSE - AND typname IN ('trigger', 'event_trigger') -{% if fnid %} - AND pr.oid = {{ fnid|qtLiteral }} -{% endif %} -{% if scid %} - AND pronamespace = {{scid}}::oid -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} - AND lanname NOT IN ('edbspl', 'sql', 'internal') -ORDER BY - proname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/properties.sql deleted file mode 100644 index 9679f2c06..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,36 +0,0 @@ -SELECT - pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, - pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, - pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, - pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, - typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, - pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals, - pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=pr.oid) AS seclabels -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0) -WHERE - proisagg = FALSE - AND typname IN ('trigger', 'event_trigger') - AND lanname NOT IN ('edbspl', 'sql', 'internal') -{% if fnid %} - AND pr.oid = {{fnid}}::oid -{% else %} - AND pronamespace = {{scid}}::oid -{% endif %} -ORDER BY - proname; 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 deleted file mode 100644 index 212c5b0ba..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.2_plus/update.sql +++ /dev/null @@ -1,114 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}() - RETURNS {{ o_data.prorettypename }} -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }}{% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} - -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif %} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/create.sql deleted file mode 100644 index 903050d3e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/create.sql +++ /dev/null @@ -1,57 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -CREATE{% if add_replace_clause %} OR REPLACE{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.proargnames %}{{data.proargnames}}{% endif %}) - RETURNS{% if data.proretset and data.prorettypename.startswith('SETOF ') %} {{ data.prorettypename }}{% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proleakproof %} LEAKPROOF{% else %} NOT LEAKPROOF{% endif %} -{% if data.proisstrict %} STRICT{% endif %} -{% if data.prosecdef %} SECURITY DEFINER{% endif %} -{% if data.proiswindow %} WINDOW{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/node.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/node.sql deleted file mode 100644 index 9d4dbdfac..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/node.sql +++ /dev/null @@ -1,27 +0,0 @@ -SELECT - pr.oid, pr.proname || '()' as name, - lanname, pg_catalog.pg_get_userbyid(proowner) as funcowner, description -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass) -WHERE - proisagg = FALSE -{% if fnid %} - AND pr.oid = {{ fnid|qtLiteral }} -{% endif %} -{% if scid %} - AND pronamespace = {{scid}}::oid -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} - AND typname IN ('trigger', 'event_trigger') - AND lanname NOT IN ('edbspl', 'sql', 'internal') -ORDER BY - proname; 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 deleted file mode 100644 index 0f936f3ca..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/9.5_plus/update.sql +++ /dev/null @@ -1,114 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ -o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}() - RETURNS {{ o_data.prorettypename }} -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }}{% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} - -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/create.sql index c188a7b91..903050d3e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/create.sql @@ -4,14 +4,17 @@ {% set is_columns = [] %} {% set exclude_quoting = ['search_path'] %} {% if data %} -CREATE{% if add_replace_clause %} OR REPLACE{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}() +CREATE{% if add_replace_clause %} OR REPLACE{% endif %} FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({% if data.proargnames %}{{data.proargnames}}{% endif %}) RETURNS{% if data.proretset and data.prorettypename.startswith('SETOF ') %} {{ data.prorettypename }}{% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} LANGUAGE {{ data.lanname|qtLiteral }} {% if data.procost %} COST {{data.procost}} {% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proisstrict %} STRICT{% endif %}{% if data.prosecdef %} SECURITY DEFINER{% endif %}{% if data.proiswindow %} WINDOW{% endif -%} + {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proleakproof %} LEAKPROOF{% else %} NOT LEAKPROOF{% endif %} +{% if data.proisstrict %} STRICT{% endif %} +{% if data.prosecdef %} SECURITY DEFINER{% endif %} +{% if data.proiswindow %} WINDOW{% endif %} {% if data.prorows and (data.prorows | int) > 0 %} ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} @@ -22,12 +25,12 @@ CREATE{% if add_replace_clause %} OR REPLACE{% endif %} FUNCTION {{ conn|qtIdent AS {% if data.lanname == 'c' %} {{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} {% else %} -$BODY${{ data.prosrc }}$BODY${% endif %}; +$BODY${{ data.prosrc }}$BODY${% endif -%}; {% if data.funcowner %} ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif %} +{% endif -%} {% if data.acl %} {% for p in data.acl %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/delete.sql index 9a6bb430d..42bd27f66 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/delete.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/delete.sql @@ -12,7 +12,7 @@ JOIN WHERE proisagg = FALSE AND pronamespace = {{scid}}::oid - AND typname = 'trigger' + AND typname IN ('trigger', 'event_trigger') AND pr.oid = {{fnid}}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/get_oid.sql index f0e279c55..86a720aac 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/get_oid.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/get_oid.sql @@ -13,5 +13,6 @@ JOIN AND nsp.nspname={{ nspname|qtLiteral }} WHERE proisagg = FALSE - AND typname = 'trigger' AND lanname != 'edbspl' + AND typname IN ('trigger', 'event_trigger') + AND lanname NOT IN ('edbspl', 'sql', 'internal') AND pr.proname = {{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/node.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/node.sql index e695f0808..9d4dbdfac 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/node.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/node.sql @@ -17,6 +17,11 @@ WHERE {% if scid %} AND pronamespace = {{scid}}::oid {% endif %} - AND typname = 'trigger' AND lanname != 'edbspl' +{% if schema_diff %} + AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END +{% endif %} + AND typname IN ('trigger', 'event_trigger') + AND lanname NOT IN ('edbspl', 'sql', 'internal') ORDER BY proname; 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 cd28330dc..0f936f3ca 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 @@ -5,7 +5,8 @@ {% set exclude_quoting = ['search_path'] %} {% if data.name %} {% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ +o_data.proargtypenames }}) RENAME TO {{ conn|qtIdent(data.name) }}; {% set name = data.name %} {% endif %} @@ -18,13 +19,14 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}() LANGUAGE {{ data.lanname|qtLiteral }} {% else %} LANGUAGE {{ o_data.lanname|qtLiteral }} {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }}{% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} +{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} {% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} {% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} {% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} + ROWS {{data.prorows}}{% elif data.prorows is not defined and o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} {% endif %} @@ -37,16 +39,17 @@ $BODY${{ o_data.prosrc }}$BODY${% endif -%}; {% endif -%} {% if data.funcowner %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; {% endif -%} {# The SQL generated below will change priviledges #} {% if data.acl %} {% if 'deleted' in data.acl %} {% for priv in data.acl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endfor %} +{% endif -%} {% if 'changed' in data.acl %} {% for priv in data.acl.changed %} @@ -57,29 +60,31 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endif %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} - -{% endfor %}{% endif %} +{% endfor %} +{% endif -%} {% if 'added' in data.acl %} {% for priv in data.acl.added %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %}{% endif %} +{% endfor %}{% endif -%} +{% endif -%} {% if data.change_func == False %} {% if data.variables %} {% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} +{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} {% endif -%} {% if 'merged_variables' in data and data.merged_variables|length > 0 %} -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif %} -{% endif %}{% endif %} +{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} +{% endif -%} +{% endif -%} +{% endif -%} {% set seclabels = data.seclabels %} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} +{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} {% if 'added' in seclabels and seclabels.added|length > 0 %} @@ -90,13 +95,16 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endif -%} {% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} + {{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} +{% endfor %} +{% endif -%} {% if data.description is defined and data.description != o_data.description%} COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) IS {{ data.description|qtLiteral }}; {% endif -%} + {% if data.pronamespace %} ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/create.sql deleted file mode 100644 index 0bf221766..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/create.sql +++ /dev/null @@ -1,58 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}() - RETURNS{% if data.proretset and data.prorettypename.startswith('SETOF ') %} {{ data.prorettypename }}{% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proleakproof %} LEAKPROOF{% else %} NOT LEAKPROOF{% endif %} -{% if data.proisstrict %} STRICT{% endif %} -{% if data.prosecdef %} SECURITY DEFINER{% endif %} -{% if data.proiswindow %} WINDOW{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args)}} -{% endfor -%} -{% endif -%} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/delete.sql deleted file mode 100644 index 87eb7b3fd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/delete.sql +++ /dev/null @@ -1,22 +0,0 @@ -{% if scid and fnid %} -SELECT - pr.proname as name, '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as func_args, - nspname -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace -WHERE - proisagg = FALSE - AND pronamespace = {{scid}}::oid - AND typname IN ('trigger', 'event_trigger') - AND pr.oid = {{fnid}}; -{% endif %} - -{% if name %} -DROP FUNCTION {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade%} CASCADE{% -endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/get_oid.sql deleted file mode 100644 index 823eed26e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/get_oid.sql +++ /dev/null @@ -1,18 +0,0 @@ -SELECT - pr.oid, pr.proname || '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as name, - lanname, pg_catalog.pg_get_userbyid(proowner) as funcowner, pr.pronamespace AS nsp -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace - AND nsp.nspname={{ nspname|qtLiteral }} -WHERE - proisagg = FALSE - AND typname IN ('trigger', 'event_trigger') - AND lanname NOT IN ('sql', 'internal') - AND pr.proname = {{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/node.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/node.sql deleted file mode 100644 index b0a7783e5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/node.sql +++ /dev/null @@ -1,27 +0,0 @@ -SELECT - pr.oid, pr.proname || '()' AS name, - lanname, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass) -WHERE - proisagg = FALSE -{% if fnid %} - AND pr.oid = {{ fnid|qtLiteral }} -{% endif %} -{% if scid %} - AND pronamespace = {{scid}}::oid -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} - AND typname IN ('trigger', 'event_trigger') - AND lanname NOT IN ('sql', 'internal') -ORDER BY - proname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/properties.sql deleted file mode 100644 index 8ef144b66..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,36 +0,0 @@ -SELECT - pr.oid, pr.xmin, pr.proiswindow, pr.prosrc, pr.prosrc AS prosrc_c, - pr.pronamespace, pr.prolang, pr.procost, pr.prorows, - pr.prosecdef, pr.proleakproof, pr.proisstrict, pr.proretset, pr.provolatile, - pr.pronargs, pr.prorettype, pr.proallargtypes, pr.proargmodes, pr.probin, pr.proacl, - pr.proname, pr.proname AS name, pg_catalog.pg_get_function_result(pr.oid) AS prorettypename, - typns.nspname AS typnsp, lanname, proargnames, pg_catalog.oidvectortypes(proargtypes) AS proargtypenames, - pg_catalog.pg_get_expr(proargdefaults, 'pg_catalog.pg_class'::regclass) AS proargdefaultvals, - pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabel sl1 - WHERE - sl1.objoid=pr.oid) AS seclabels -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace typns ON typns.oid=typ.typnamespace -JOIN - pg_catalog.pg_language lng ON lng.oid=prolang -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=pr.oid AND des.classoid='pg_proc'::regclass and des.objsubid = 0) -WHERE - proisagg = FALSE - AND typname IN ('trigger', 'event_trigger') - AND lanname NOT IN ('sql', 'internal') -{% if fnid %} - AND pr.oid = {{fnid}}::oid -{% else %} - AND pronamespace = {{scid}}::oid -{% endif %} -ORDER BY - proname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/update.sql deleted file mode 100644 index f55074685..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.2_plus/update.sql +++ /dev/null @@ -1,110 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}() - RETURNS {{ o_data.prorettypename }} -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }}{% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - - ROWS {{data.prorows}}{% elif o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{% endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} - -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in data.acl %} -{% for priv in data.acl.changed %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} - -{{ 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif %} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/create.sql deleted file mode 100644 index afc31f181..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/create.sql +++ /dev/null @@ -1,57 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %} -{% set is_columns = [] %} -{% set exclude_quoting = ['search_path'] %} -{% if data %} -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}() - RETURNS{% if data.proretset and data.prorettypename.startswith('SETOF ') %} {{ data.prorettypename }}{% elif data.proretset %} SETOF {{ data.prorettypename }}{% else %} {{ data.prorettypename }}{% endif %} - - LANGUAGE {{ data.lanname|qtLiteral }} -{% if data.procost %} - COST {{data.procost}} -{% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proleakproof %} LEAKPROOF{% else %} NOT LEAKPROOF{% endif %} -{% if data.proisstrict %} STRICT{% endif %} -{% if data.prosecdef %} SECURITY DEFINER{% endif %} -{% if data.proiswindow %} WINDOW{% endif %} -{% if data.prorows and (data.prorows | int) > 0 %} - - ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor %} -{% endif %} - -AS {% if data.lanname == 'c' %} -{{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} -{% else %} -$BODY${{ data.prosrc }}$BODY${% endif -%}; -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{% if data.acl %} -{% for p in data.acl %} - -{{ PRIVILEGE.SET(conn, "FUNCTION", p.grantee, data.name, p.without_grant, p.with_grant, data.pronamespace, data.func_args)}} -{% endfor %}{% endif %} -{% if data.revoke_all %} - -{{ PRIVILEGE.UNSETALL(conn, "FUNCTION", "PUBLIC", data.name, data.pronamespace, data.func_args_without)}} -{% endif %} -{% if data.description %} - -COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) - IS {{ data.description|qtLiteral }}; -{% endif -%} -{% if data.seclabels %} -{% for r in data.seclabels %} -{% if r.label and r.provider %} - -{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }} -{% endif %} -{% endfor %} -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/delete.sql deleted file mode 100644 index 42bd27f66..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/delete.sql +++ /dev/null @@ -1,21 +0,0 @@ -{% if scid and fnid %} -SELECT - pr.proname as name, '(' || COALESCE(pg_catalog - .pg_get_function_identity_arguments(pr.oid), '') || ')' as func_args, - nspname -FROM - pg_catalog.pg_proc pr -JOIN - pg_catalog.pg_type typ ON typ.oid=prorettype -JOIN - pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace -WHERE - proisagg = FALSE - AND pronamespace = {{scid}}::oid - AND typname IN ('trigger', 'event_trigger') - AND pr.oid = {{fnid}}; -{% endif %} - -{% if name %} -DROP FUNCTION {{ conn|qtIdent(nspname, name) }}{{func_args}}{% if cascade %} CASCADE{% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/update.sql deleted file mode 100644 index a73f68d65..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/9.5_plus/update.sql +++ /dev/null @@ -1,110 +0,0 @@ -{% import 'macros/functions/security.macros' as SECLABEL %} -{% import 'macros/functions/privilege.macros' as PRIVILEGE %} -{% import 'macros/functions/variable.macros' as VARIABLE %}{% if data %} -{% set name = o_data.name %} -{% set exclude_quoting = ['search_path'] %} -{% if data.name %} -{% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ -o_data.proargtypenames }}) - RENAME TO {{ conn|qtIdent(data.name) }}; -{% set name = data.name %} -{% endif %} -{% endif -%} -{% if data.change_func %} - -CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}() - RETURNS {{ o_data.prorettypename }} -{% if 'lanname' in data %} - LANGUAGE {{ data.lanname|qtLiteral }} {% else %} - LANGUAGE {{ o_data.lanname|qtLiteral }} - {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }}{% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} -{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} -{% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} -{% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} -{% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} - - {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - - ROWS {{data.prorows}}{% elif o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} - - SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} - {% endif %} - -AS {% if (data.lanname == 'c' or o_data.lanname == 'c') and ('probin' in data or 'prosrc_c' in data) %} -{% if 'probin' in data %}{{ data.probin|qtLiteral }}{% else %}{{ o_data.probin|qtLiteral }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral }}{% else %}{{ o_data.prosrc_c|qtLiteral }}{% endif %}{% elif 'prosrc' in data %} -$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %} -{{ o_data.probin|qtLiteral }}, {{ o_data.prosrc_c|qtLiteral }}{% else %} -$BODY${{ o_data.prosrc }}$BODY${% endif -%}; -{% endif -%} -{% if data.funcowner %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif -%} -{# The SQL generated below will change priviledges #} -{% if data.acl %} -{% if 'deleted' in data.acl %} -{% for priv in data.acl.deleted %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in data.datacl %} -{% for priv in data.acl.changed %} - -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} - -{{ 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 %} - -{{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} -{% endif -%} -{% if data.change_func == False %} -{% if data.variables %} -{% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} - -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% if 'merged_variables' in data and data.merged_variables|length > 0 %} - -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} -{% endif -%} -{% endif -%} -{% endif -%} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} - -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} - -{{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %} -{% endif -%} -{% if data.description is defined and data.description != o_data.description%} - -COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - IS {{ data.description|qtLiteral }}; -{% endif -%} - -{% if data.pronamespace %} - -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) - SET SCHEMA {{ conn|qtIdent(data.pronamespace) }}; -{% endif -%} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/create.sql index 87be90cd3..afc31f181 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/create.sql @@ -11,7 +11,10 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}() {% if data.procost %} COST {{data.procost}} {% endif %} - {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proisstrict %} STRICT{% endif %}{% if data.prosecdef %} SECURITY DEFINER{% endif %}{% if data.proiswindow %} WINDOW{% endif -%} + {% if data.provolatile %}{% if data.provolatile == 'i' %}IMMUTABLE{% elif data.provolatile == 's' %}STABLE{% else %}VOLATILE{% endif %}{% endif %}{% if data.proleakproof %} LEAKPROOF{% else %} NOT LEAKPROOF{% endif %} +{% if data.proisstrict %} STRICT{% endif %} +{% if data.prosecdef %} SECURITY DEFINER{% endif %} +{% if data.proiswindow %} WINDOW{% endif %} {% if data.prorows and (data.prorows | int) > 0 %} ROWS {{data.prorows}}{% endif -%}{% if data.variables %}{% for v in data.variables %} @@ -22,12 +25,12 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}() AS {% if data.lanname == 'c' %} {{ data.probin|qtLiteral }}, {{ data.prosrc_c|qtLiteral }} {% else %} -$BODY${{ data.prosrc }}$BODY${% endif %}; +$BODY${{ data.prosrc }}$BODY${% endif -%}; {% if data.funcowner %} ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args}}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; -{% endif %} +{% endif -%} {% if data.acl %} {% for p in data.acl %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/delete.sql index 9a6bb430d..42bd27f66 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/delete.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/delete.sql @@ -12,7 +12,7 @@ JOIN WHERE proisagg = FALSE AND pronamespace = {{scid}}::oid - AND typname = 'trigger' + AND typname IN ('trigger', 'event_trigger') AND pr.oid = {{fnid}}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/get_oid.sql index adfe5fd6b..823eed26e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/get_oid.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/get_oid.sql @@ -13,5 +13,6 @@ JOIN AND nsp.nspname={{ nspname|qtLiteral }} WHERE proisagg = FALSE - AND typname = 'trigger' + AND typname IN ('trigger', 'event_trigger') + AND lanname NOT IN ('sql', 'internal') AND pr.proname = {{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/node.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/node.sql index 3111c7529..b0a7783e5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/node.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/node.sql @@ -17,6 +17,11 @@ WHERE {% if scid %} AND pronamespace = {{scid}}::oid {% endif %} - AND typname = 'trigger' +{% if schema_diff %} + AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = pr.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END +{% endif %} + AND typname IN ('trigger', 'event_trigger') + AND lanname NOT IN ('sql', 'internal') ORDER BY proname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/update.sql index 3a92eecf9..a73f68d65 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/update.sql @@ -5,7 +5,8 @@ {% set exclude_quoting = ['search_path'] %} {% if data.name %} {% if data.name != o_data.name %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, o_data.name) }}({{ +o_data.proargtypenames }}) RENAME TO {{ conn|qtIdent(data.name) }}; {% set name = data.name %} {% endif %} @@ -18,13 +19,14 @@ CREATE OR REPLACE FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}() LANGUAGE {{ data.lanname|qtLiteral }} {% else %} LANGUAGE {{ o_data.lanname|qtLiteral }} {% endif %}{% if 'provolatile' in data and data.provolatile %}{{ data.provolatile }}{% elif 'provolatile' not in data and o_data.provolatile %}{{ o_data.provolatile }}{% endif %} +{% if ('proleakproof' in data and data.proleakproof) or ('proleakproof' not in data and o_data.proleakproof) %} LEAKPROOF{% elif 'proleakproof' in data and not data.proleakproof %} NOT LEAKPROOF{% endif %} {% if ('proisstrict' in data and data.proisstrict) or ('proisstrict' not in data and o_data.proisstrict) %} STRICT{% endif %} {% if ('prosecdef' in data and data.prosecdef) or ('prosecdef' not in data and o_data.prosecdef) %} SECURITY DEFINER{% endif %} {% if ('proiswindow' in data and data.proiswindow) or ('proiswindow' not in data and o_data.proiswindow) %} WINDOW{% endif %} {% if data.procost %}COST {{data.procost}}{% elif o_data.procost %}COST {{o_data.procost}}{% endif %}{% if data.prorows %} - ROWS {{data.prorows}}{% elif o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}}{%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} + ROWS {{data.prorows}}{% elif o_data.prorows and o_data.prorows != '0' %} ROWS {{o_data.prorows}} {%endif -%}{% if data.merged_variables %}{% for v in data.merged_variables %} SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral }}{% endif %}{% endfor -%} {% endif %} @@ -37,44 +39,48 @@ $BODY${{ o_data.prosrc }}$BODY${% endif -%}; {% endif -%} {% if data.funcowner %} -ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }}) +ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) OWNER TO {{ conn|qtIdent(data.funcowner) }}; {% endif -%} {# The SQL generated below will change priviledges #} {% if data.acl %} {% if 'deleted' in data.acl %} {% for priv in data.acl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %} -{% if 'changed' in data.acl %} +{{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} +{% endfor %} +{% endif -%} +{% if 'changed' in data.datacl %} {% for priv in data.acl.changed %} + {{ PRIVILEGE.UNSETALL(conn, 'FUNCTION', priv.grantee, name, o_data.pronamespace, o_data.proargtypenames) }} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} - -{% endfor %}{% endif %} +{% endfor %} +{% endif -%} {% if 'added' in data.acl %} {% for priv in data.acl.added %} {{ PRIVILEGE.SET(conn, 'FUNCTION', priv.grantee, name, priv.without_grant, priv.with_grant, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif %}{% endif %} +{% endfor %}{% endif -%} +{% endif -%} {% if data.change_func == False %} {% if data.variables %} {% if 'deleted' in data.variables and data.variables.deleted|length > 0 %} -{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames ) }} +{{ VARIABLE.UNSET(conn, 'FUNCTION', name, data.variables.deleted, o_data.pronamespace, o_data.proargtypenames) }} {% endif -%} {% if 'merged_variables' in data and data.merged_variables|length > 0 %} -{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames ) }} -{% endif %} -{% endif %}{% endif %} +{{ VARIABLE.SET(conn, 'FUNCTION', name, data.merged_variables, o_data.pronamespace, o_data.proargtypenames) }} +{% endif -%} +{% endif -%} +{% endif -%} {% set seclabels = data.seclabels %} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} +{{ SECLABEL.UNSET(conn, 'FUNCTION', name, r.provider, o_data.pronamespace, o_data.proargtypenames) }} {% endfor %} {% endif -%} {% if 'added' in seclabels and seclabels.added|length > 0 %} @@ -85,13 +91,16 @@ ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtyp {% endif -%} {% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} + {{ SECLABEL.SET(conn, 'FUNCTION', name, r.provider, r.label, o_data.pronamespace, o_data.proargtypenames) }} -{% endfor %}{% endif -%} +{% endfor %} +{% endif -%} {% if data.description is defined and data.description != o_data.description%} COMMENT ON FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) IS {{ data.description|qtLiteral }}; {% endif -%} + {% if data.pronamespace %} ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }}) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_acl.sql deleted file mode 100644 index 79d8a1fe0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_acl.sql +++ /dev/null @@ -1,26 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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; - -GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres; - - - diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_parameter.msql deleted file mode 100644 index 694732c56..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_parameter.msql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - RETURNS character varying - LANGUAGE 'plpgsql' - VOLATILE WINDOW - COST 100 - SET application_name='appname' - SET enable_sort='true' -AS $BODY$ -begin -select '2'; -end -$BODY$; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_parameter.sql deleted file mode 100644 index c901f8bbc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_parameter.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Function3_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"( - ) - RETURNS character varying - LANGUAGE 'plpgsql' - COST 100 - VOLATILE WINDOW - SET application_name='appname' - SET enable_sort='true' -AS $BODY$ -begin -select '2'; -end -$BODY$; - -ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; 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 deleted file mode 100644 index ead07955f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.sql +++ /dev/null @@ -1,21 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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/alter_function_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_comment.sql deleted file mode 100644 index 71aab9c6f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_comment.sql +++ /dev/null @@ -1,22 +0,0 @@ --- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying) - --- DROP FUNCTION IF EXISTS public."Function1_$%{}[]()&*^!@""'`\/#"(character varying); - -CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"( - param character varying DEFAULT '1'::character varying) - RETURNS character varying - LANGUAGE 'plpgsql' - COST 100 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - SET enable_sort='true' -AS $BODY$ -begin -select '1'; -end -$BODY$; - -ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - OWNER TO postgres; - -COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_acl.sql deleted file mode 100644 index 8f4b38ae6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_acl.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_parameter.sql deleted file mode 100644 index d42da98c2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_parameter.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Function3_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"( - ) - RETURNS character varying - LANGUAGE 'plpgsql' - COST 100 - VOLATILE WINDOW - SET enable_sort='true' -AS $BODY$ -begin -select '2'; -end -$BODY$; - -ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_rename.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_rename.sql deleted file mode 100644 index 8f12841a5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_rename.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Function3_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"( - ) - RETURNS character varying - LANGUAGE 'plpgsql' - COST 100 - VOLATILE WINDOW - SET enable_sort='true' -AS $BODY$ -begin -select '1'; -end -$BODY$; - -ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_comment.sql deleted file mode 100644 index e1cfe4ba7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_comment.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - VOLATILE NOT LEAKPROOF -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_1.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_1.sql deleted file mode 100644 index f9ab87078..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_1.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - STABLE LEAKPROOF STRICT SECURITY DEFINER -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_2.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_2.sql deleted file mode 100644 index dda230907..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_2.sql +++ /dev/null @@ -1,22 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 123 - IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER - SET application_name='appname' - SET search_path=public, pg_temp -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_3.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_3.sql deleted file mode 100644 index ed1e163d0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_ptrig_set_3.sql +++ /dev/null @@ -1,23 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 123 - IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER - SET application_name='appname2' - SET search_path=public, pg_catalog - SET array_nulls='true' -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_event_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_event_trigger_full.sql deleted file mode 100644 index 50f59804c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_event_trigger_full.sql +++ /dev/null @@ -1,26 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS SETOF event_trigger - LANGUAGE 'plpgsql' - COST 1234 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - ROWS 4321 - SET application_name='appname' -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION; - -REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function.msql deleted file mode 100644 index c10b3ac50..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function.msql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(IN param character varying DEFAULT '1') - RETURNS character varying - LANGUAGE 'plpgsql' - COST 100 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - SET enable_sort=true -AS $BODY$ -begin -select '1'; -end -$BODY$; - -ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - OWNER TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function.sql deleted file mode 100644 index 2a94729d5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying) - --- DROP FUNCTION IF EXISTS public."Function1_$%{}[]()&*^!@""'`\/#"(character varying); - -CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"( - param character varying DEFAULT '1'::character varying) - RETURNS character varying - LANGUAGE 'plpgsql' - COST 100 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - SET enable_sort='true' -AS $BODY$ -begin -select '1'; -end -$BODY$; - -ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - OWNER TO postgres; - diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function_for_alter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function_for_alter.msql deleted file mode 100644 index d4ea23e50..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function_for_alter.msql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function_for_alter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function_for_alter.sql deleted file mode 100644 index 8f4b38ae6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_function_for_alter.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_plain_trigger.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_plain_trigger.sql deleted file mode 100644 index 759c632e9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_plain_trigger.sql +++ /dev/null @@ -1,17 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - VOLATILE NOT LEAKPROOF -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_plain_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_plain_trigger_full.sql deleted file mode 100644 index 73040efbd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/create_plain_trigger_full.sql +++ /dev/null @@ -1,27 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS SETOF trigger - LANGUAGE 'plpgsql' - COST 1234 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - ROWS 4321 - SET application_name='appname' - SET search_path=public, pg_temp -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION; - -REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; 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 deleted file mode 100644 index 0ed3b29e4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_function.json +++ /dev/null @@ -1,310 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create function with all options.", - "endpoint": "NODE-function.obj", - "msql_endpoint": "NODE-function.msql", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name": "Function1_$%{}[]()&*^!@\"'`\\/#", - "funcowner": "postgres", - "pronamespace": 2200, - "prorettypename": "character varying", - "lanname": "plpgsql", - "provolatile": "v", - "proretset": false, - "proisstrict": true, - "prosecdef": true, - "proiswindow": true, - "procost": "100", - "prorows": "0", - "proleakproof": true, - "arguments": [ - { - "argtype": "character varying", - "argmode": "IN", - "argname": "param", - "argdefval": "'1'" - } - ], - "prosrc": "begin\nselect '1';\nend", - "probin": "$libdir/", - "options": [], - "variables": [ - { - "name": "enable_sort", - "value": true - } - ], - "seclabels": [], - "acl": [], - "schema": "public" - }, - "expected_sql_file": "create_function.sql", - "expected_msql_file": "create_function.msql" - }, - { - "type": "alter", - "name": "Alter function comment", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "description": "Some comment" - }, - "expected_sql_file": "alter_function_comment.sql", - "expected_msql_file": "alter_function_comment.msql" - }, - { - "type": "delete", - "name": "Drop function", - "endpoint": "NODE-function.delete_id", - "data": { - } - }, - { - "type": "create", - "name": "Create function for alter.", - "endpoint": "NODE-function.obj", - "msql_endpoint": "NODE-function.msql", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name": "Function2_$%{}[]()&*^!@\"'`\\/#", - "funcowner": "postgres", - "pronamespace": 2200, - "prorettypename": "character varying", - "lanname": "plpgsql", - "provolatile": "v", - "proiswindow": true, - "arguments": [], - "procost": "100", - "prosrc": "begin\nselect '1';\nend", - "probin": "$libdir/", - "options": [], - "variables": [ - { - "name": "enable_sort", - "value": true - } - ], - "seclabels": [], - "acl": [], - "schema": "public" - }, - "expected_sql_file": "create_function_for_alter.sql", - "expected_msql_file": "create_function_for_alter.msql" - }, - { - "type": "alter", - "name": "Alter function rename.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name":"Function3_$%{}[]()&*^!@\"'`\\/#" - }, - "expected_sql_file": "alter_function_rename.sql", - "expected_msql_file": "alter_function_rename.msql" - }, - { - "type": "alter", - "name": "Alter function code and add parameters.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "prosrc": "begin\nselect '2';\nend\n", - "variables": { - "added": [ - { - "name": "application_name", - "value": "appname" - } - ] - } - }, - "expected_sql_file": "alter_function_add_parameter.sql", - "expected_msql_file": "alter_function_add_parameter.msql" - }, - { - "type": "alter", - "name": "Alter function delete parameters.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "variables": { - "deleted": [ - { - "name": "application_name", - "value": true - } - ] - } - }, - "expected_sql_file": "alter_function_delete_parameter.sql", - "expected_msql_file": "alter_function_delete_parameter.msql" - }, - { - "type": "delete", - "name": "Drop function", - "endpoint": "NODE-function.delete_id", - "data": { - } - }, - { - "type": "create", - "name": "Create function for acl.", - "endpoint": "NODE-function.obj", - "msql_endpoint": "NODE-function.msql", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name": "Function2_$%{}[]()&*^!@\"'`\\/#", - "funcowner": "postgres", - "pronamespace": 2200, - "prorettypename": "character varying", - "lanname": "plpgsql", - "provolatile": "v", - "proiswindow": true, - "arguments": [], - "procost": "100", - "prosrc": "begin\nselect '1';\nend", - "probin": "$libdir/", - "options": [], - "variables": [ - { - "name": "enable_sort", - "value": true - } - ], - "seclabels": [], - "acl": [], - "schema": "public" - }, - "expected_sql_file": "create_function_for_alter.sql", - "expected_msql_file": "create_function_for_alter.msql" - }, - { - "type": "alter", - "name": "Alter function add acl.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "acl": { - "added": [ - { - "grantee": "postgres", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "X", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "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": "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", - "data": { - "acl": { - "deleted": [ - { - "grantee": "PUBLIC", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "X", - "privilege": true, - "with_grant": false - } - ] - }, - { - "grantee": "postgres", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "X", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "expected_sql_file": "alter_function_delete_acl.sql", - "expected_msql_file": "alter_function_delete_acl.msql" - }, - { - "type": "delete", - "name": "Drop function", - "endpoint": "NODE-function.delete_id", - "data": { - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_trigger_functions.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_trigger_functions.json deleted file mode 100644 index 6abea3d2a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/test_trigger_functions.json +++ /dev/null @@ -1,191 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [], - "args": [], - "funcowner": "postgres", - "lanname": "plpgsql", - "options": [], - "pronamespace": 2200, - "prorettypename": "trigger", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [], - "schema": "public" - }, - "expected_sql_file": "create_plain_trigger.sql" - }, { - "type": "alter", - "name": "Alter trigger function comment", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "description": "some comment" - }, - "expected_sql_file": "alter_ptrig_comment.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 1 - Strict, Leakproof, Security of definer, Volatility", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "proisstrict": true, - "proleakproof": true, - "prosecdef": true, - "provolatile": "s" - }, - "expected_sql_file": "alter_ptrig_set_1.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 2 - Cost, Volatility, Add Param", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "procost": "123", - "provolatile": "i", - "variables": { - "added": [{ - "name": "application_name", - "value": "appname" - },{ - "name": "search_path", - "value": "public, pg_temp" - }] - } - }, - "expected_sql_file": "alter_ptrig_set_2.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 3 - Add Param, Change Param", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "variables": { - "added": [{ - "name": "application_name", - "value": "appname2" - }], - "changed": [{ - "name": "array_nulls", - "value": true - },{ - "name": "search_path", - "value": "public, pg_catalog" - }] - } - }, - "expected_sql_file": "alter_ptrig_set_3.sql" - }, { - "type": "delete", - "name": "Drop trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - }, { - "type": "create", - "name": "Create full fledged trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [{ - "grantee": "postgres", - "grantor": "postgres", - "privileges": [ - { - "privilege": true, - "privilege_type": "X", - "with_grant": true - } - ] - }], - "args": [], - "description": "some comment", - "funcowner": "postgres", - "lanname": "plpgsql", - "options": [], - "procost": "1234", - "proisstrict": true, - "proiswindow": true, - "proleakproof": true, - "pronamespace": 2200, - "proretset": true, - "prorettypename": "trigger", - "prorows": "4321", - "prosecdef": true, - "provolatile": "v", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [{ - "name": "application_name", - "value": "appname" - },{ - "name": "search_path", - "value": "public, pg_temp" - }], - "schema": "public" - }, - "expected_sql_file": "create_plain_trigger_full.sql" - }, { - "type": "delete", - "name": "Drop full fledged trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - }, { - "type": "create", - "name": "Create full fledged event trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [{ - "grantee": "postgres", - "grantor": "postgres", - "privileges": [ - { - "privilege": true, - "privilege_type": "X", - "with_grant": true - } - ] - }], - "args": [], - "description": "some comment", - "funcowner": "postgres", - "lanname": "plpgsql", - "options": [], - "procost": "1234", - "proisstrict": true, - "proiswindow": true, - "proleakproof": true, - "pronamespace": 2200, - "proretset": true, - "prorettypename": "event_trigger", - "prorows": "4321", - "prosecdef": true, - "provolatile": "v", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [{ - "name": "application_name", - "value": "appname" - }], - "schema": "public" - }, - "expected_sql_file": "create_event_trigger_full.sql" - }, { - "type": "delete", - "name": "Drop full fledged event trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_acl.msql deleted file mode 100644 index 82ce0c5cc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_acl.msql +++ /dev/null @@ -1 +0,0 @@ -GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO postgres; 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 deleted file mode 100644 index a5c3dd5e5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.msql +++ /dev/null @@ -1,3 +0,0 @@ -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_delete_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_acl.msql deleted file mode 100644 index 1393bd746..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_acl.msql +++ /dev/null @@ -1,3 +0,0 @@ -REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC; - -REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_comment.sql deleted file mode 100644 index e1cfe4ba7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_comment.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - VOLATILE NOT LEAKPROOF -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_1.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_1.sql deleted file mode 100644 index f9ab87078..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_1.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - STABLE LEAKPROOF STRICT SECURITY DEFINER -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_2.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_2.sql deleted file mode 100644 index dda230907..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_2.sql +++ /dev/null @@ -1,22 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 123 - IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER - SET application_name='appname' - SET search_path=public, pg_temp -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_3.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_3.sql deleted file mode 100644 index ed1e163d0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_ptrig_set_3.sql +++ /dev/null @@ -1,23 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 123 - IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER - SET application_name='appname2' - SET search_path=public, pg_catalog - SET array_nulls='true' -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_event_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_event_trigger_full.sql deleted file mode 100644 index 50f59804c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_event_trigger_full.sql +++ /dev/null @@ -1,26 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS SETOF event_trigger - LANGUAGE 'plpgsql' - COST 1234 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - ROWS 4321 - SET application_name='appname' -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION; - -REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_plain_trigger.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_plain_trigger.sql deleted file mode 100644 index 759c632e9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_plain_trigger.sql +++ /dev/null @@ -1,17 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - VOLATILE NOT LEAKPROOF -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_plain_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_plain_trigger_full.sql deleted file mode 100644 index 73040efbd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_plain_trigger_full.sql +++ /dev/null @@ -1,27 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS SETOF trigger - LANGUAGE 'plpgsql' - COST 1234 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - ROWS 4321 - SET application_name='appname' - SET search_path=public, pg_temp -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO postgres; - -GRANT EXECUTE ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() TO postgres WITH GRANT OPTION; - -REVOKE ALL ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_trigger_functions.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_trigger_functions.json deleted file mode 100644 index 6abea3d2a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_trigger_functions.json +++ /dev/null @@ -1,191 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [], - "args": [], - "funcowner": "postgres", - "lanname": "plpgsql", - "options": [], - "pronamespace": 2200, - "prorettypename": "trigger", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [], - "schema": "public" - }, - "expected_sql_file": "create_plain_trigger.sql" - }, { - "type": "alter", - "name": "Alter trigger function comment", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "description": "some comment" - }, - "expected_sql_file": "alter_ptrig_comment.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 1 - Strict, Leakproof, Security of definer, Volatility", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "proisstrict": true, - "proleakproof": true, - "prosecdef": true, - "provolatile": "s" - }, - "expected_sql_file": "alter_ptrig_set_1.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 2 - Cost, Volatility, Add Param", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "procost": "123", - "provolatile": "i", - "variables": { - "added": [{ - "name": "application_name", - "value": "appname" - },{ - "name": "search_path", - "value": "public, pg_temp" - }] - } - }, - "expected_sql_file": "alter_ptrig_set_2.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 3 - Add Param, Change Param", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "variables": { - "added": [{ - "name": "application_name", - "value": "appname2" - }], - "changed": [{ - "name": "array_nulls", - "value": true - },{ - "name": "search_path", - "value": "public, pg_catalog" - }] - } - }, - "expected_sql_file": "alter_ptrig_set_3.sql" - }, { - "type": "delete", - "name": "Drop trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - }, { - "type": "create", - "name": "Create full fledged trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [{ - "grantee": "postgres", - "grantor": "postgres", - "privileges": [ - { - "privilege": true, - "privilege_type": "X", - "with_grant": true - } - ] - }], - "args": [], - "description": "some comment", - "funcowner": "postgres", - "lanname": "plpgsql", - "options": [], - "procost": "1234", - "proisstrict": true, - "proiswindow": true, - "proleakproof": true, - "pronamespace": 2200, - "proretset": true, - "prorettypename": "trigger", - "prorows": "4321", - "prosecdef": true, - "provolatile": "v", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [{ - "name": "application_name", - "value": "appname" - },{ - "name": "search_path", - "value": "public, pg_temp" - }], - "schema": "public" - }, - "expected_sql_file": "create_plain_trigger_full.sql" - }, { - "type": "delete", - "name": "Drop full fledged trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - }, { - "type": "create", - "name": "Create full fledged event trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [{ - "grantee": "postgres", - "grantor": "postgres", - "privileges": [ - { - "privilege": true, - "privilege_type": "X", - "with_grant": true - } - ] - }], - "args": [], - "description": "some comment", - "funcowner": "postgres", - "lanname": "plpgsql", - "options": [], - "procost": "1234", - "proisstrict": true, - "proiswindow": true, - "proleakproof": true, - "pronamespace": 2200, - "proretset": true, - "prorettypename": "event_trigger", - "prorows": "4321", - "prosecdef": true, - "provolatile": "v", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [{ - "name": "application_name", - "value": "appname" - }], - "schema": "public" - }, - "expected_sql_file": "create_event_trigger_full.sql" - }, { - "type": "delete", - "name": "Drop full fledged event trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_acl.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_add_acl.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_acl.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_parameter.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_parameter.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_parameter.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_add_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_add_parameter.sql 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/default/alter_function_change_grantee_acl.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_change_grantee_acl.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_change_grantee_acl.msql 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/default/alter_function_change_grantee_acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_change_grantee_acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_change_grantee_acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_comment.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_comment.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_comment.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_comment.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_comment.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_comment.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_comment.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_acl.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_acl.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_acl.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_parameter.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_delete_parameter.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_parameter.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_delete_parameter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_rename.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_rename.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.5_plus/alter_function_rename.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_rename.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_rename.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_rename.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_rename.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_function_rename.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_comment.sql index 9538dde02..e1cfe4ba7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_comment.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_comment.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS trigger diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_1.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_1.sql index 87e1f4bd1..f9ab87078 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_1.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_1.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS trigger diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_2.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_2.sql index 351d0ba11..dda230907 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_2.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_2.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS trigger diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_3.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_3.sql index fd1d62aad..ed1e163d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_3.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/alter_ptrig_set_3.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS trigger diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_event_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_event_trigger_full.sql index fdd0225b2..50f59804c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_event_trigger_full.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_event_trigger_full.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS SETOF event_trigger diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function_for_alter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function_for_alter.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function_for_alter.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function_for_alter.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function_for_alter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function_for_alter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/create_function_for_alter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_function_for_alter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger.sql index 435237a01..759c632e9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS trigger diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger_full.sql index 5d8d93001..73040efbd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger_full.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/create_plain_trigger_full.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS SETOF trigger 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/default/test_function.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/test_function.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/default/test_function.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_acl.sql deleted file mode 100644 index a11c52100..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_acl.sql +++ /dev/null @@ -1,24 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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; - -GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO enterprisedb; - diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_parameter.sql deleted file mode 100644 index 7afd695a6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_parameter.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Function3_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"( - ) -RETURNS character varying - LANGUAGE 'plpgsql' - VOLATILE SECURITY DEFINER WINDOW - COST 100 - SET application_name='appname' - SET enable_sort='true' -AS $BODY$ -begin -select '2'; -end -$BODY$; - -ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; 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 deleted file mode 100644 index 0710dddd3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.sql +++ /dev/null @@ -1,21 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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/alter_function_comment.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_comment.msql deleted file mode 100644 index 12b3a148c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_comment.msql +++ /dev/null @@ -1,2 +0,0 @@ -COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_comment.sql deleted file mode 100644 index b38a5aef7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_comment.sql +++ /dev/null @@ -1,22 +0,0 @@ --- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying) - --- DROP FUNCTION IF EXISTS public."Function1_$%{}[]()&*^!@""'`\/#"(character varying); - -CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"( - param character varying DEFAULT '1'::character varying) -RETURNS character varying - LANGUAGE 'plpgsql' - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - COST 100 - SET enable_sort='true' -AS $BODY$ -begin -select '1'; -end -$BODY$; - -ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - OWNER TO enterprisedb; - -COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_acl.sql deleted file mode 100644 index fd8f035ba..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_acl.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_parameter.msql deleted file mode 100644 index f21583867..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_parameter.msql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - RESET application_name; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_parameter.sql deleted file mode 100644 index 6790c1282..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_parameter.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Function3_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"( - ) -RETURNS character varying - LANGUAGE 'plpgsql' - VOLATILE SECURITY DEFINER WINDOW - COST 100 - SET enable_sort='true' -AS $BODY$ -begin -select '2'; -end -$BODY$; - -ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_rename.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_rename.msql deleted file mode 100644 index 8ddfca77b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_rename.msql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() - RENAME TO "Function3_$%{}[]()&*^!@""'`\/#"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_rename.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_rename.sql deleted file mode 100644 index b86e9d559..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_rename.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function3_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Function3_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"( - ) -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."Function3_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function.msql deleted file mode 100644 index da7f8fd1f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function.msql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(IN param character varying DEFAULT '1') -RETURNS character varying - LANGUAGE 'plpgsql' - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - COST 100 - SET enable_sort=true -AS $BODY$ -begin -select '1'; -end -$BODY$; - -ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - OWNER TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function.sql deleted file mode 100644 index 81c2f07f1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function1_$%{}[]()&*^!@"'`\/#(character varying) - --- DROP FUNCTION IF EXISTS public."Function1_$%{}[]()&*^!@""'`\/#"(character varying); - -CREATE OR REPLACE FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"( - param character varying DEFAULT '1'::character varying) -RETURNS character varying - LANGUAGE 'plpgsql' - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - COST 100 - SET enable_sort='true' -AS $BODY$ -begin -select '1'; -end -$BODY$; - -ALTER FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - OWNER TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function_for_alter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function_for_alter.msql deleted file mode 100644 index a568fb034..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function_for_alter.msql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function_for_alter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function_for_alter.sql deleted file mode 100644 index fd8f035ba..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/create_function_for_alter.sql +++ /dev/null @@ -1,19 +0,0 @@ --- FUNCTION: public.Function2_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS 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; 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 deleted file mode 100644 index 56cf4c8da..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/test_function.json +++ /dev/null @@ -1,322 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create function with all options.", - "endpoint": "NODE-function.obj", - "msql_endpoint": "NODE-function.msql", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name": "Function1_$%{}[]()&*^!@\"'`\\/#", - "funcowner": "enterprisedb", - "pronamespace": 2200, - "prorettypename": "character varying", - "lanname": "plpgsql", - "provolatile": "v", - "proretset": false, - "proisstrict": true, - "prosecdef": true, - "proiswindow": true, - "procost": "100", - "prorows": "0", - "proleakproof": true, - "arguments": [ - { - "argtype": "character varying", - "argmode": "IN", - "argname": "param", - "argdefval": "'1'" - } - ], - "prosrc": "begin\nselect '1';\nend", - "probin": "$libdir/", - "options": [], - "variables": [ - { - "name": "enable_sort", - "value": true - } - ], - "seclabels": [], - "acl": [], - "schema": "public" - }, - "expected_sql_file": "create_function.sql", - "expected_msql_file": "create_function.msql" - }, - { - "type": "alter", - "name": "Alter function comment", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "description": "Some comment" - }, - "expected_sql_file": "alter_function_comment.sql", - "expected_msql_file": "alter_function_comment.msql" - }, - { - "type": "delete", - "name": "Drop function", - "endpoint": "NODE-function.delete_id", - "data": { - } - }, - { - "type": "create", - "name": "Create function for alter.", - "endpoint": "NODE-function.obj", - "msql_endpoint": "NODE-function.msql", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name": "Function2_$%{}[]()&*^!@\"'`\\/#", - "funcowner": "enterprisedb", - "pronamespace": 2200, - "prorettypename": "character varying", - "lanname": "plpgsql", - "provolatile": "v", - "proiswindow": true, - "prosecdef": true, - "arguments": [], - "procost": "100", - "prosrc": "begin\nselect '1';\nend", - "probin": "$libdir/", - "options": [], - "variables": [ - { - "name": "enable_sort", - "value": true - } - ], - "seclabels": [], - "acl": [], - "schema": "public" - }, - "expected_sql_file": "create_function_for_alter.sql", - "expected_msql_file": "create_function_for_alter.msql" - }, - { - "type": "alter", - "name": "Alter function rename.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name": "Function3_$%{}[]()&*^!@\"'`\\/#" - }, - "expected_sql_file": "alter_function_rename.sql", - "expected_msql_file": "alter_function_rename.msql" - }, - { - "type": "alter", - "name": "Alter function code and add parameters.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "prosrc": "begin\nselect '2';\nend\n", - "variables": { - "added": [ - { - "name": "application_name", - "value": "appname" - } - ] - } - }, - "expected_sql_file": "alter_function_add_parameter.sql" - }, - { - "type": "alter", - "name": "Alter function delete parameters.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "variables": { - "deleted": [ - { - "name": "application_name", - "value": true - } - ] - } - }, - "expected_sql_file": "alter_function_delete_parameter.sql", - "expected_msql_file": "alter_function_delete_parameter.msql" - }, - { - "type": "delete", - "name": "Drop function", - "endpoint": "NODE-function.delete_id", - "data": { - } - }, - { - "type": "create", - "name": "Create function for acl.", - "endpoint": "NODE-function.obj", - "msql_endpoint": "NODE-function.msql", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "name": "Function2_$%{}[]()&*^!@\"'`\\/#", - "funcowner": "enterprisedb", - "pronamespace": 2200, - "prorettypename": "character varying", - "lanname": "plpgsql", - "provolatile": "v", - "proiswindow": true, - "prosecdef": true, - "arguments": [], - "procost": "100", - "prosrc": "begin\nselect '1';\nend", - "probin": "$libdir/", - "options": [], - "variables": [ - { - "name": "enable_sort", - "value": true - } - ], - "seclabels": [], - "acl": [], - "schema": "public" - }, - "expected_sql_file": "create_function_for_alter.sql", - "expected_msql_file": "create_function_for_alter.msql" - }, - { - "type": "alter", - "name": "Alter function add acl.", - "endpoint": "NODE-function.obj_id", - "msql_endpoint": "NODE-function.msql_id", - "sql_endpoint": "NODE-function.sql_id", - "data": { - "acl": { - "added": [ - { - "grantee": "PUBLIC", - "grantor": "enterprisedb", - "privileges": [ - { - "privilege_type": "X", - "privilege": true, - "with_grant": false - } - ] - }, - { - "grantee": "enterprisedb", - "grantor": "enterprisedb", - "privileges": [ - { - "privilege_type": "X", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "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 delete acl.", - "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 - } - ] - }, - { - "grantee": "enterprisedb", - "grantor": "enterprisedb", - "privileges": [ - { - "privilege_type": "X", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "expected_sql_file": "alter_function_delete_acl.sql", - "expected_msql_file": "alter_function_delete_acl.msql" - }, - { - "type": "delete", - "name": "Drop function", - "endpoint": "NODE-function.delete_id", - "data": { - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_acl.msql deleted file mode 100644 index f5f875cd9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_acl.msql +++ /dev/null @@ -1,3 +0,0 @@ -GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO PUBLIC; - -GRANT EXECUTE ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_parameter.msql deleted file mode 100644 index 900e3a9cd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_parameter.msql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE OR REPLACE FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - RETURNS character varying - LANGUAGE 'plpgsql' - VOLATILE SECURITY DEFINER - - COST 100 - SET application_name='appname' - SET enable_sort='true' -AS $BODY$ -begin -select '2'; -end -$BODY$; 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 deleted file mode 100644 index 0333fa578..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.msql +++ /dev/null @@ -1,3 +0,0 @@ -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_comment.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_comment.msql deleted file mode 100644 index 12b3a148c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_comment.msql +++ /dev/null @@ -1,2 +0,0 @@ -COMMENT ON FUNCTION public."Function1_$%{}[]()&*^!@""'`\/#"(character varying) - IS 'Some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_acl.msql deleted file mode 100644 index 13bb67bf4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_acl.msql +++ /dev/null @@ -1,3 +0,0 @@ -REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM PUBLIC; - -REVOKE ALL ON FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() FROM enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_parameter.msql deleted file mode 100644 index f21583867..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_parameter.msql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER FUNCTION public."Function3_$%{}[]()&*^!@""'`\/#"() - RESET application_name; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_rename.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_rename.msql deleted file mode 100644 index 8ddfca77b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_rename.msql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER FUNCTION public."Function2_$%{}[]()&*^!@""'`\/#"() - RENAME TO "Function3_$%{}[]()&*^!@""'`\/#"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_comment.sql deleted file mode 100644 index 241e38d3f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_comment.sql +++ /dev/null @@ -1,17 +0,0 @@ --- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) - --- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); - -CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( - i1 integer) - VOLATILE SECURITY DEFINER PARALLEL UNSAFE - COST 100 -AS begin -select 1; -end; - -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_comment_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_comment_msql.sql deleted file mode 100644 index 616d2d225..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_comment_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`/#" - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_opt.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_opt.sql deleted file mode 100644 index 29e7267d0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_opt.sql +++ /dev/null @@ -1,18 +0,0 @@ --- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) - --- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); - -CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( - i1 integer) - VOLATILE SECURITY DEFINER PARALLEL RESTRICTED - COST 120 - SET application_name='pgadmin' -AS begin -select 1; -end; - -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_opt_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_opt_msql.sql deleted file mode 100644 index c7cfe58d1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_opt_msql.sql +++ /dev/null @@ -1,15 +0,0 @@ --- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) - --- DROP PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); - -CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( - i1 integer) - VOLATILE SECURITY DEFINER PARALLEL RESTRICTED - COST 120 - SET application_name='pgadmin' -AS begin -select 1; -end; - -COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_param.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_param.sql deleted file mode 100644 index 40ddcd3f4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_param.sql +++ /dev/null @@ -1,18 +0,0 @@ --- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) - --- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); - -CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( - i1 integer) - VOLATILE SECURITY DEFINER PARALLEL UNSAFE - COST 100 - SET application_name='pgadmin' -AS begin -select 1; -end; - -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; - -COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_param_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_param_msql.sql deleted file mode 100644 index 900c68ed4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_param_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`/#" - SET application_name=pgadmin; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_comment.sql deleted file mode 100644 index 156735044..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_comment.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - VOLATILE NOT LEAKPROOF -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_1.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_1.sql deleted file mode 100644 index 1981336d0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_1.sql +++ /dev/null @@ -1,20 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - STABLE LEAKPROOF STRICT SECURITY DEFINER -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_2.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_2.sql deleted file mode 100644 index b4c873f4c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_2.sql +++ /dev/null @@ -1,22 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 123 - IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER - SET application_name='appname' - SET search_path=public, pg_temp -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_3.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_3.sql deleted file mode 100644 index e5d4ae970..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_ptrig_set_3.sql +++ /dev/null @@ -1,23 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 123 - IMMUTABLE LEAKPROOF STRICT SECURITY DEFINER - SET application_name='appname2' - SET search_path=public, pg_catalog - SET array_nulls='true' -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_event_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_event_trigger_full.sql deleted file mode 100644 index 4950ef5a6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_event_trigger_full.sql +++ /dev/null @@ -1,22 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS SETOF event_trigger - LANGUAGE 'plpgsql' - COST 1234 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW - ROWS 4321 - SET application_name='appname' -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_plain_trigger.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_plain_trigger.sql deleted file mode 100644 index a794a288a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_plain_trigger.sql +++ /dev/null @@ -1,17 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - VOLATILE NOT LEAKPROOF -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_plain_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_plain_trigger_full.sql deleted file mode 100644 index d1bcf8b0e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_plain_trigger_full.sql +++ /dev/null @@ -1,23 +0,0 @@ --- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() - --- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); - -CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - RETURNS SETOF trigger - LANGUAGE 'plpgsql' - COST 1234 - STABLE LEAKPROOF STRICT SECURITY DEFINER WINDOW - ROWS 4321 - SET application_name='appname' - SET search_path=public, pg_temp -AS $BODY$ -begin -select 1; -end; -$BODY$; - -ALTER FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - OWNER TO enterprisedb; - -COMMENT ON FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() - IS 'some comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_procedure.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_procedure.sql deleted file mode 100644 index b377916ad..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_procedure.sql +++ /dev/null @@ -1,14 +0,0 @@ --- PROCEDURE: public.Proc1_$%{}[]()&*^!@"'`\/#(integer) - --- DROP PROCEDURE IF EXISTS public."Proc1_$%{}[]()&*^!@""'`\/#"(integer); - -CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( - i1 integer) - VOLATILE SECURITY DEFINER PARALLEL UNSAFE - COST 100 -AS begin -select 1; -end; - -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" - OWNER TO enterprisedb; 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 deleted file mode 100644 index b51bc23fa..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_procedures.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create procedure", - "endpoint": "NODE-procedure.obj", - "sql_endpoint": "NODE-procedure.sql_id", - "data": { - "name": "Proc1_$%{}[]()&*^!@\"'`\\/#", - "acl": [], - "arguments": [ - { - "argtype": "integer", - "argmode": "IN", - "argname": "i1", - "argdefval": "" - } - ], - "funcowner": "enterprisedb", - "lanname": "plpgsql", - "options": [], - "pronamespace": 2200, - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [], - "schema": "public", - "provolatile": null, - "proisstrict": false, - "proparallel": null, - "procost": null, - "proleakproof": false, - "probin": "$libdir/" - }, - "expected_sql_file": "create_procedure.sql" - }, - { - "type": "alter", - "name": "Alter procedure comment", - "endpoint": "NODE-procedure.obj_id", - "sql_endpoint": "NODE-procedure.sql_id", - "data": { - "description": "some comment" - }, - "expected_sql_file": "alter_proc_comment.sql", - "expected_msql_file": "alter_proc_comment_msql.sql" - }, - { - "type": "alter", - "name": "Alter procedure param", - "endpoint": "NODE-procedure.obj_id", - "provolatile": "s", - "sql_endpoint": "NODE-procedure.sql_id", - "data": { - "variables": { - "added": [ - { - "name": "application_name", - "value": "pgadmin" - } - ] - } - }, - "expected_sql_file": "alter_proc_param.sql", - "expected_msql_file": "alter_proc_param_msql.sql" - }, - { - "type": "alter", - "name": "Alter procedure options", - "endpoint": "NODE-procedure.obj_id", - "sql_endpoint": "NODE-procedure.sql_id", - "data": { - "provolatile": "s", - "proparallel": "r", - "description": "some comment", - "procost": "120" - }, - "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", - "endpoint": "NODE-procedure.delete_id", - "data": { - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_trigger_functions.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_trigger_functions.json deleted file mode 100644 index 96e2fc382..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_trigger_functions.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [], - "args": [], - "funcowner": "enterprisedb", - "lanname": "plpgsql", - "options": [], - "pronamespace": 2200, - "prorettypename": "trigger", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [], - "schema": "public" - }, - "expected_sql_file": "create_plain_trigger.sql" - }, { - "type": "alter", - "name": "Alter trigger function comment", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "description": "some comment" - }, - "expected_sql_file": "alter_ptrig_comment.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 1 - Strict, Leakproof, Security of definer, Volatility", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "proisstrict": true, - "proleakproof": true, - "prosecdef": true, - "provolatile": "s" - }, - "expected_sql_file": "alter_ptrig_set_1.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 2 - Cost, Volatility, Add Param", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "procost": "123", - "provolatile": "i", - "variables": { - "added": [{ - "name": "application_name", - "value": "appname" - },{ - "name": "search_path", - "value": "public, pg_temp" - }] - } - }, - "expected_sql_file": "alter_ptrig_set_2.sql" - }, { - "type": "alter", - "name": "Alter trigger function Set 3 - Add Param, Change Param", - "endpoint": "NODE-trigger_function.obj_id", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "variables": { - "changed": [{ - "name": "application_name", - "value": "appname2" - },{ - "name": "search_path", - "value": "public, pg_catalog" - }], - "added": [{ - "name": "array_nulls", - "value": true - }] - } - }, - "expected_sql_file": "alter_ptrig_set_3.sql" - }, { - "type": "delete", - "name": "Drop trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - }, { - "type": "create", - "name": "Create full fledged trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [], - "args": [], - "description": "some comment", - "funcowner": "enterprisedb", - "lanname": "plpgsql", - "options": [], - "procost": "1234", - "proisstrict": true, - "proiswindow": true, - "proleakproof": true, - "pronamespace": 2200, - "proretset": true, - "prorettypename": "trigger", - "prorows": "4321", - "prosecdef": true, - "provolatile": "s", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [{ - "name": "application_name", - "value": "appname" - },{ - "name": "search_path", - "value": "public, pg_temp" - }], - "schema": "public" - }, - "expected_sql_file": "create_plain_trigger_full.sql" - }, { - "type": "delete", - "name": "Drop full fledged trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - }, { - "type": "create", - "name": "Create full fledged event trigger function", - "endpoint": "NODE-trigger_function.obj", - "sql_endpoint": "NODE-trigger_function.sql_id", - "data": { - "name": "Trig1_$%{}[]()&*^!@\"'`\\/#", - "acl": [], - "args": [], - "description": "some comment", - "funcowner": "enterprisedb", - "lanname": "plpgsql", - "options": [], - "procost": "1234", - "proisstrict": true, - "proiswindow": true, - "proleakproof": true, - "pronamespace": 2200, - "proretset": true, - "prorettypename": "event_trigger", - "prorows": "4321", - "prosecdef": true, - "provolatile": "v", - "prosrc": "begin\nselect 1;\nend;", - "seclabels": [], - "variables": [{ - "name": "application_name", - "value": "appname" - }], - "schema": "public" - }, - "expected_sql_file": "create_event_trigger_full.sql" - }, { - "type": "delete", - "name": "Drop full fledged event trigger function", - "endpoint": "NODE-trigger_function.delete_id", - "data": { - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_acl.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_acl.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_acl.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_parameter.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_add_parameter.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_parameter.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_add_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_add_parameter.sql 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/default/alter_function_change_grantee_acl.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_change_grantee_acl.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_change_grantee_acl.msql 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/default/alter_function_change_grantee_acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_change_grantee_acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_change_grantee_acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_comment.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_comment.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_comment.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_comment.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_comment.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_comment.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_comment.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_acl.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_acl.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.5_plus/alter_function_delete_acl.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_acl.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_parameter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_parameter.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_delete_parameter.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_parameter.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_delete_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_delete_parameter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_rename.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_rename.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/pg/9.6_plus/alter_function_rename.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_rename.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_rename.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_rename.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_function_rename.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_function_rename.sql 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/default/alter_proc_change_grantee_priv.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_change_grantee_priv.msql 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/default/alter_proc_change_grantee_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/alter_proc_change_grantee_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_change_grantee_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_comment.sql index b842697a7..241e38d3f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_comment.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_comment.sql @@ -4,13 +4,13 @@ CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( i1 integer) - VOLATILE SECURITY DEFINER + VOLATILE SECURITY DEFINER PARALLEL UNSAFE COST 100 -AS begin +AS begin select 1; end; -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) +ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" OWNER TO enterprisedb; COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt.sql index 1426b2012..29e7267d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt.sql @@ -4,14 +4,14 @@ CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( i1 integer) - STABLE SECURITY DEFINER + VOLATILE SECURITY DEFINER PARALLEL RESTRICTED COST 120 SET application_name='pgadmin' -AS begin +AS begin select 1; end; -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) +ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" OWNER TO enterprisedb; COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt_msql.sql index 147ebbe02..c7cfe58d1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_opt_msql.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( i1 integer) - STABLE SECURITY DEFINER + VOLATILE SECURITY DEFINER PARALLEL RESTRICTED COST 120 SET application_name='pgadmin' AS begin diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_param.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_param.sql index 78416c7f7..40ddcd3f4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_param.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/alter_proc_param.sql @@ -4,14 +4,14 @@ CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( i1 integer) - VOLATILE SECURITY DEFINER + VOLATILE SECURITY DEFINER PARALLEL UNSAFE COST 100 SET application_name='pgadmin' -AS begin +AS begin select 1; end; -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) +ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" OWNER TO enterprisedb; COMMENT ON PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function_for_alter.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function_for_alter.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function_for_alter.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function_for_alter.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function_for_alter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function_for_alter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/create_function_for_alter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_function_for_alter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger.sql index 2d7383c6d..a794a288a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger.sql @@ -1,6 +1,6 @@ -- FUNCTION: public.Trig1_$%{}[]()&*^!@"'`\/#() --- DROP FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"(); +-- DROP FUNCTION IF EXISTS public."Trig1_$%{}[]()&*^!@""'`\/#"(); CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS trigger diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger_full.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger_full.sql index e74efbcc6..d1bcf8b0e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger_full.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_plain_trigger_full.sql @@ -6,7 +6,7 @@ CREATE OR REPLACE FUNCTION public."Trig1_$%{}[]()&*^!@""'`\/#"() RETURNS SETOF trigger LANGUAGE 'plpgsql' COST 1234 - VOLATILE LEAKPROOF STRICT SECURITY DEFINER WINDOW + STABLE LEAKPROOF STRICT SECURITY DEFINER WINDOW ROWS 4321 SET application_name='appname' SET search_path=public, pg_temp diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_procedure.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_procedure.sql index b5e324f05..b377916ad 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_procedure.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/create_procedure.sql @@ -4,11 +4,11 @@ CREATE OR REPLACE PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"( i1 integer) - VOLATILE SECURITY DEFINER + VOLATILE SECURITY DEFINER PARALLEL UNSAFE COST 100 -AS begin +AS begin select 1; end; -ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#"(integer) +ALTER PROCEDURE public."Proc1_$%{}[]()&*^!@""'`\/#" OWNER TO enterprisedb; 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/default/test_function.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/9.6_plus/test_function.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_function.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_procedures.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_procedures.json index f908a56ee..b51bc23fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_procedures.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_procedures.json @@ -8,9 +8,16 @@ "data": { "name": "Proc1_$%{}[]()&*^!@\"'`\\/#", "acl": [], - "arguments": [{"argtype": "integer", "argmode": "IN", "argname": "i1", "argdefval": ""}], + "arguments": [ + { + "argtype": "integer", + "argmode": "IN", + "argname": "i1", + "argdefval": "" + } + ], "funcowner": "enterprisedb", - "lanname": "edbspl", + "lanname": "plpgsql", "options": [], "pronamespace": 2200, "prosrc": "begin\nselect 1;\nend;", @@ -25,7 +32,8 @@ "probin": "$libdir/" }, "expected_sql_file": "create_procedure.sql" - }, { + }, + { "type": "alter", "name": "Alter procedure comment", "endpoint": "NODE-procedure.obj_id", @@ -35,32 +43,75 @@ }, "expected_sql_file": "alter_proc_comment.sql", "expected_msql_file": "alter_proc_comment_msql.sql" - }, { + }, + { "type": "alter", "name": "Alter procedure param", "endpoint": "NODE-procedure.obj_id", + "provolatile": "s", "sql_endpoint": "NODE-procedure.sql_id", "data": { "variables": { - "added": [{"name": "application_name", "value": "pgadmin"}] + "added": [ + { + "name": "application_name", + "value": "pgadmin" + } + ] } }, "expected_sql_file": "alter_proc_param.sql", "expected_msql_file": "alter_proc_param_msql.sql" - }, { + }, + { "type": "alter", "name": "Alter procedure options", "endpoint": "NODE-procedure.obj_id", "sql_endpoint": "NODE-procedure.sql_id", "data": { - "provolatile": "v", + "provolatile": "s", "proparallel": "r", "description": "some comment", "procost": "120" }, "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", "endpoint": "NODE-procedure.delete_id", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_trigger_functions.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_trigger_functions.json index da99d9d4c..96e2fc382 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_trigger_functions.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/tests/ppas/default/test_trigger_functions.json @@ -109,7 +109,7 @@ "prorettypename": "trigger", "prorows": "4321", "prosecdef": true, - "provolatile": "v", + "provolatile": "s", "prosrc": "begin\nselect 1;\nend;", "seclabels": [], "variables": [{ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/acl.sql deleted file mode 100644 index 9c1bef1b3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/acl.sql +++ /dev/null @@ -1,33 +0,0 @@ -SELECT 'pkgacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT nspacl - FROM pg_catalog.pg_namespace - WHERE nspparent = {{scid}}::oid - AND oid = {{pkgid}}::oid - ) acl, - (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable - AS is_grantable, (d).privilege_type AS privilege_type FROM (SELECT pg_catalog.aclexplode(nspacl) as d FROM pg_catalog.pg_namespace - WHERE nspparent = {{scid}}::oid - AND oid = {{pkgid}}::oid) a ORDER BY privilege_type) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/create.sql deleted file mode 100644 index 0e3f0221e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/create.sql +++ /dev/null @@ -1,24 +0,0 @@ -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} - -{% if data %} -CREATE OR REPLACE PACKAGE {{ conn|qtIdent(data.schema,data.name) }} -IS -{{data.pkgheadsrc}} -END {{ conn|qtIdent(data.name) }}; -{% if data.pkgbodysrc %} - -CREATE OR REPLACE PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }} -IS -{{data.pkgbodysrc}} -END {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.pkgacl %} - -{% for priv in data.pkgacl %} -{{ PRIVILEGE.SET(conn, 'PACKAGE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %}{% if data.description %} -COMMENT ON PACKAGE {{ conn|qtIdent(data.schema,data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/get_oid.sql deleted file mode 100644 index b4bb5e4c4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/get_oid.sql +++ /dev/null @@ -1,4 +0,0 @@ -SELECT nsp.oid -FROM pg_catalog.pg_namespace nsp -WHERE nspparent = {{scid}}::oid -AND nspname = {{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/nodes.sql deleted file mode 100644 index 70282322a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/nodes.sql +++ /dev/null @@ -1,13 +0,0 @@ -SELECT - nsp.oid, nspname AS name -FROM - pg_catalog.pg_namespace nsp -WHERE nspparent = {{scid}}::oid -{% if pkgid %} -AND nsp.oid = {{pkgid}}::oid -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = nsp.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY nspname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/properties.sql deleted file mode 100644 index 448d3b4de..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/properties.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT nsp.oid, nsp.xmin, nspname AS name, - pg_catalog.edb_get_packagebodydef(nsp.oid) AS pkgbodysrc, - pg_catalog.edb_get_packageheaddef(nsp.oid) AS pkgheadsrc, - pg_catalog.pg_get_userbyid(nspowner) AS owner, - pg_catalog.array_to_string(nsp.nspacl::text[], ', ') as acl, - description, - CASE - WHEN nspname LIKE E'pg\\_%' THEN true - ELSE false - END AS is_sys_object -FROM pg_catalog.pg_namespace nsp -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=nsp.oid AND des.classoid='pg_namespace'::regclass) -WHERE nspparent = {{scid}}::oid -{% if pkgid %} -AND nsp.oid = {{pkgid}}::oid -{% endif %} -ORDER BY nspname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/delete.sql deleted file mode 100644 index c5bb596c8..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/delete.sql +++ /dev/null @@ -1 +0,0 @@ -DROP PACKAGE {{ conn|qtIdent(data.schema,data.name) }}{% if cascade%} CASCADE{% endif %}; \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/get_schema.sql deleted file mode 100644 index 2d77757ea..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/get_schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/grant.sql deleted file mode 100644 index d4a382c66..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/grant.sql +++ /dev/null @@ -1,26 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# Construct sequence name from name and schema #} -{% set seqname=conn|qtIdent(data.schema, data.name) %} -{% if data.seqowner %} - -ALTER SEQUENCE {{ seqname }} - OWNER TO {{ conn|qtIdent(data.seqowner) }}; -{% endif %} -{% if data.comment %} - -COMMENT ON SEQUENCE {{ seqname }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% if data.securities %} - -{% for r in data.securities %} -{{ SECLABEL.SET(conn, 'SEQUENCE', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if data.relacl %} - -{% for priv in data.relacl %} -{{ PRIVILEGE.SET(conn, 'SEQUENCE', 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/packages/templates/packages/ppas/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/update.sql deleted file mode 100644 index ecef723b4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/update.sql +++ /dev/null @@ -1,48 +0,0 @@ -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} - -{% if data %} -{% set recreate_pkg_body = false %} -{% if data.pkgbodysrc is defined and data.pkgbodysrc == '' %} -{% if is_schema_diff is defined and is_schema_diff != None %}{% set recreate_pkg_body = true %}{% endif %} -DROP PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }}; -{% endif %} -{% if data.pkgheadsrc %} - -CREATE OR REPLACE PACKAGE {{ conn|qtIdent(data.schema,data.name) }} -IS -{{data.pkgheadsrc}} -END {{ conn|qtIdent(data.name) }}; - -{% endif %} -{% if data.pkgbodysrc or (o_data.pkgbodysrc and recreate_pkg_body) %} - -CREATE OR REPLACE PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }} -IS -{% if data.pkgbodysrc %}{{data.pkgbodysrc}}{% else %}{{o_data.pkgbodysrc}}{% endif %} - -END {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.pkgacl %} -{% if 'deleted' in data.pkgacl %} -{% for priv in data.pkgacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'PACKAGE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.pkgacl %} -{% for priv in data.pkgacl.changed %} -{{ PRIVILEGE.UNSETALL(conn, 'PACKAGE', priv.grantee, data.name, data.schema) }} -{{ PRIVILEGE.SET(conn, 'PACKAGE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in data.pkgacl %} -{% for priv in data.pkgacl.added %} -{{ PRIVILEGE.SET(conn, 'PACKAGE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% if data.description is defined %} - -COMMENT ON PACKAGE {{ conn|qtIdent(data.schema,data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/delete.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/delete.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/delete.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/get_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/get_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/get_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/get_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/get_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/get_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/grant.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/grant.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/grant.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.2_plus/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/properties.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/9.1_plus/update.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/packages/ppas/default/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/alter_package_headers_and_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/alter_package_headers_and_comment.sql deleted file mode 100644 index 3bcea43b4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/alter_package_headers_and_comment.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Package: public.pkg_emp_$%{}[]()&*^!@"'`\/# - --- DROP PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#"; - -CREATE OR REPLACE PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" -IS -FUNCTION func1(v1 integer) RETURN integer; -PROCEDURE proc1(v1 integer); -END "pkg_emp_$%{}[]()&*^!@""'`\/#"; - -CREATE OR REPLACE PACKAGE BODY public."pkg_emp_$%{}[]()&*^!@""'`\/#" -IS -FUNCTION func1(v1 integer) RETURN integer IS BEGIN RETURN V1+10; END; -PROCEDURE proc1(v1 integer) IS BEGIN DBMS_OUTPUT.put_line(v1+50); END; - -END "pkg_emp_$%{}[]()&*^!@""'`\/#"; - -GRANT EXECUTE ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -COMMENT ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" - IS 'test comment updated'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/alter_package_headers_and_comment_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/alter_package_headers_and_comment_msql.sql deleted file mode 100644 index 00918abdd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/alter_package_headers_and_comment_msql.sql +++ /dev/null @@ -1,4 +0,0 @@ -REVOKE ALL ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" FROM enterprisedb; - -COMMENT ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" - IS 'test comment updated'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/create_package_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/create_package_with_all_options.sql deleted file mode 100644 index 82156e332..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/create_package_with_all_options.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Package: public.pkg_emp_$%{}[]()&*^!@"'`\/# - --- DROP PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#"; - -CREATE OR REPLACE PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" -IS -FUNCTION func1(v1 integer) RETURN integer; -PROCEDURE proc1(v1 integer); -END "pkg_emp_$%{}[]()&*^!@""'`\/#"; - -CREATE OR REPLACE PACKAGE BODY public."pkg_emp_$%{}[]()&*^!@""'`\/#" -IS -FUNCTION func1(v1 integer) RETURN integer IS BEGIN RETURN V1+10; END; -PROCEDURE proc1(v1 integer) IS BEGIN DBMS_OUTPUT.put_line(v1+50); END; - -END "pkg_emp_$%{}[]()&*^!@""'`\/#"; - -GRANT EXECUTE ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" TO PUBLIC; - -GRANT EXECUTE ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" TO enterprisedb WITH GRANT OPTION; - -COMMENT ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" - IS 'test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/create_package_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/create_package_with_all_options_msql.sql deleted file mode 100644 index 1b04f99f8..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/create_package_with_all_options_msql.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE OR REPLACE PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" -IS -FUNCTION func1(v1 integer) RETURN integer; -PROCEDURE proc1(v1 integer); -END "pkg_emp_$%{}[]()&*^!@""'`\/#"; - -CREATE OR REPLACE PACKAGE BODY public."pkg_emp_$%{}[]()&*^!@""'`\/#" -IS -FUNCTION func1(v1 integer) RETURN integer IS BEGIN RETURN V1+10; END FUNC1; -PROCEDURE proc1(v1 integer) IS BEGIN DBMS_OUTPUT.put_line(v1+50); END; - -END "pkg_emp_$%{}[]()&*^!@""'`\/#"; - -GRANT EXECUTE ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" TO enterprisedb WITH GRANT OPTION; - -COMMENT ON PACKAGE public."pkg_emp_$%{}[]()&*^!@""'`\/#" - IS 'test comment'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/test.json deleted file mode 100644 index 29344c76d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/9.2_plus/test.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Packages", - "endpoint": "NODE-package.obj", - "sql_endpoint": "NODE-package.sql_id", - "msql_endpoint": "NODE-package.msql", - "data": - { - "name": "pkg_emp_$%{}[]()&*^!@\"'`\\/#", - "owner": "enterprisedb", - "description": "test comment", - "pkgheadsrc": "FUNCTION func1(v1 integer) RETURN integer;\nPROCEDURE proc1(v1 integer);", - "pkgbodysrc": "FUNCTION func1(v1 integer) RETURN integer IS BEGIN RETURN V1+10; END FUNC1;\nPROCEDURE proc1(v1 integer) IS BEGIN DBMS_OUTPUT.put_line(v1+50); END;", - "pkgacl": [{ - "grantee": "enterprisedb", - "grantor": "enterprisedb", - "privileges": [{ - "privilege_type": "X", - "privilege": true, - "with_grant": true - }] - }], - "schema": "public" - }, - "expected_sql_file": "create_package_with_all_options.sql", - "expected_msql_file": "create_package_with_all_options_msql.sql" - }, - { - "type": "alter", - "name": "Alter Packages", - "endpoint": "NODE-package.obj_id", - "sql_endpoint": "NODE-package.sql_id", - "msql_endpoint": "NODE-package.msql_id", - "data": - { - "description": "test comment updated", - "owner": "enterprisedb", - "pkgacl": { - "deleted": [{ - "grantee": "enterprisedb", - "grantor": "enterprisedb", - "privileges": [{ - "privilege_type": "X", - "privilege": true, - "with_grant": true - }] - }] - }, - "schema": "public" - }, - "expected_sql_file": "alter_package_headers_and_comment.sql", - "expected_msql_file": "alter_package_headers_and_comment_msql.sql" - }, - { - "type": "delete", - "name": "Drop Package", - "endpoint": "NODE-package.delete_id", - "data": { - "name": "pkg_emp_$%{}[]()&*^!@\"'`\\/#" - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/alter_package_headers_and_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/alter_package_headers_and_comment.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/alter_package_headers_and_comment.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/alter_package_headers_and_comment.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/alter_package_headers_and_comment_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/alter_package_headers_and_comment_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/alter_package_headers_and_comment_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/alter_package_headers_and_comment_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/create_package_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/create_package_with_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/create_package_with_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/create_package_with_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/create_package_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/create_package_with_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/create_package_with_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/create_package_with_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/test.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/10_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/ppas/default/test.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/10_plus/get_def.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/10_plus/get_def.sql deleted file mode 100644 index 335b1fad6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/10_plus/get_def.sql +++ /dev/null @@ -1,11 +0,0 @@ -SELECT - last_value, - seqmin AS min_value, - seqmax AS max_value, - seqstart AS start_value, - seqcache AS cache_value, - seqcycle AS is_cycled, - seqincrement AS increment_by, - is_called -FROM pg_catalog.pg_sequence, {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.name) }} -WHERE seqrelid = {{data.oid}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/get_def.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/get_def.sql index e0e9efba1..335b1fad6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/get_def.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequences/sql/default/get_def.sql @@ -1,10 +1,11 @@ -SELECT - last_value, - min_value, - max_value, - start_value, - cache_value, - is_cycled, - increment_by, +SELECT + last_value, + seqmin AS min_value, + seqmax AS max_value, + seqstart AS start_value, + seqcache AS cache_value, + seqcycle AS is_cycled, + seqincrement AS increment_by, is_called -FROM {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.name) }} \ No newline at end of file +FROM pg_catalog.pg_sequence, {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.name) }} +WHERE seqrelid = {{data.oid}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.2_plus/get_objects.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.2_plus/get_objects.sql deleted file mode 100644 index e284d7b46..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.2_plus/get_objects.sql +++ /dev/null @@ -1,56 +0,0 @@ -{###########################################} -{### If Target Type is Function ###} -{###########################################} -{% if trgTyp == 'f' %} -SELECT DISTINCT proname AS name - FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n -WHERE p.pronamespace = n.oid AND - n.nspname = {{ trgSchema|qtLiteral }} AND - p.protype = '0' -ORDER BY proname; -{###########################################} -{### If Target Type is Procedure ###} -{###########################################} -{% elif trgTyp == 'p' %} -SELECT DISTINCT proname AS name - FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n -WHERE p.pronamespace = n.oid AND - n.nspname = {{ trgSchema|qtLiteral }} AND - p.protype = '1' -ORDER BY proname; -{###########################################} -{### If Target Type is Synonym ###} -{###########################################} -{% elif trgTyp == 's' %} -SELECT synname AS name - FROM pg_catalog.pg_synonym -ORDER BY synname; -{###########################################} -{### If Target Type is Package ###} -{###########################################} -{% elif trgTyp == 'P' %} -SELECT nspname AS name - FROM pg_catalog.pg_namespace -WHERE nspparent IN ( - SELECT oid - FROM pg_catalog.pg_namespace - WHERE nspname = {{ trgSchema|qtLiteral }} LIMIT 1 - ) - AND nspobjecttype = 0 -ORDER BY nspname; -{% else %} -{###################################################} -{### If Target Type is Table/View/M.View/Sequnce ###} -{###################################################} -SELECT relname AS name - FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n -WHERE c.relnamespace = n.oid AND - n.nspname = {{ trgSchema|qtLiteral }} AND -{% if trgTyp == 'v' %} -{# If view is select then we need to fetch both view and materialized view #} - (c.relkind = 'v' OR c.relkind = 'm') -{% else %} - c.relkind = {{ trgTyp|qtLiteral }} -{% endif %} -ORDER BY relname; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.2_plus/properties.sql deleted file mode 100644 index e4167a0af..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,34 +0,0 @@ -SELECT synname AS name, pg_catalog.pg_get_userbyid(synowner) AS owner, - synobjschema, synobjname, ns.nspname as schema, - COALESCE( - (SELECT relkind - FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n - WHERE c.relnamespace = n.oid - AND n.nspname = synobjschema - AND c.relname = synobjname), - -- For Function/Procedure - (SELECT CASE WHEN p.protype = '0' THEN 'f'::"char" ELSE 'p'::"char" END - FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n - WHERE p.pronamespace = n.oid - AND n.nspname = synobjschema - AND p.proname = synobjname LIMIT 1), - -- For Package - (SELECT CASE WHEN count(*) > 0 THEN 'P'::"char" END - FROM pg_catalog.pg_namespace - WHERE nspparent IN (SELECT oid - FROM pg_catalog.pg_namespace - WHERE nspname = synobjschema LIMIT 1) - AND nspname = synobjname - AND nspobjecttype = 0), - -- Default s = Synonym - 's') AS targettype -FROM pg_catalog.pg_synonym s JOIN pg_catalog.pg_namespace ns ON s.synnamespace = ns.oid - WHERE s.synnamespace={{scid}}::oid - {% if syid %} - AND s.oid={{syid}}::oid - {% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = s.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY synname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/get_objects.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/get_objects.sql deleted file mode 100644 index e284d7b46..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/get_objects.sql +++ /dev/null @@ -1,56 +0,0 @@ -{###########################################} -{### If Target Type is Function ###} -{###########################################} -{% if trgTyp == 'f' %} -SELECT DISTINCT proname AS name - FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n -WHERE p.pronamespace = n.oid AND - n.nspname = {{ trgSchema|qtLiteral }} AND - p.protype = '0' -ORDER BY proname; -{###########################################} -{### If Target Type is Procedure ###} -{###########################################} -{% elif trgTyp == 'p' %} -SELECT DISTINCT proname AS name - FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n -WHERE p.pronamespace = n.oid AND - n.nspname = {{ trgSchema|qtLiteral }} AND - p.protype = '1' -ORDER BY proname; -{###########################################} -{### If Target Type is Synonym ###} -{###########################################} -{% elif trgTyp == 's' %} -SELECT synname AS name - FROM pg_catalog.pg_synonym -ORDER BY synname; -{###########################################} -{### If Target Type is Package ###} -{###########################################} -{% elif trgTyp == 'P' %} -SELECT nspname AS name - FROM pg_catalog.pg_namespace -WHERE nspparent IN ( - SELECT oid - FROM pg_catalog.pg_namespace - WHERE nspname = {{ trgSchema|qtLiteral }} LIMIT 1 - ) - AND nspobjecttype = 0 -ORDER BY nspname; -{% else %} -{###################################################} -{### If Target Type is Table/View/M.View/Sequnce ###} -{###################################################} -SELECT relname AS name - FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n -WHERE c.relnamespace = n.oid AND - n.nspname = {{ trgSchema|qtLiteral }} AND -{% if trgTyp == 'v' %} -{# If view is select then we need to fetch both view and materialized view #} - (c.relkind = 'v' OR c.relkind = 'm') -{% else %} - c.relkind = {{ trgTyp|qtLiteral }} -{% endif %} -ORDER BY relname; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/properties.sql deleted file mode 100644 index ef7444d4d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/properties.sql +++ /dev/null @@ -1,34 +0,0 @@ -SELECT s.oid, synname AS name, pg_catalog.pg_get_userbyid(synowner) AS owner, - synobjschema, synobjname, ns.nspname as schema, - COALESCE( - (SELECT relkind - FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n - WHERE c.relnamespace = n.oid - AND n.nspname = synobjschema - AND c.relname = synobjname), - -- For Function/Procedure - (SELECT CASE WHEN p.protype = '0' THEN 'f'::"char" ELSE 'p'::"char" END - FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n - WHERE p.pronamespace = n.oid - AND n.nspname = synobjschema - AND p.proname = synobjname LIMIT 1), - -- For Package - (SELECT CASE WHEN count(*) > 0 THEN 'P'::"char" END - FROM pg_catalog.pg_namespace - WHERE nspparent IN (SELECT oid - FROM pg_catalog.pg_namespace - WHERE nspname = synobjschema LIMIT 1) - AND nspname = synobjname - AND nspobjecttype = 0), - -- Default s = Synonym - 's') AS targettype -FROM pg_catalog.pg_synonym s JOIN pg_catalog.pg_namespace ns ON s.synnamespace = ns.oid - WHERE s.synnamespace={{scid}}::oid - {% if syid %} - AND s.oid={{syid}}::oid - {% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = s.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY synname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/get_objects.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/get_objects.sql index 24fa71ff6..e284d7b46 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/get_objects.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/get_objects.sql @@ -25,6 +25,19 @@ ORDER BY proname; SELECT synname AS name FROM pg_catalog.pg_synonym ORDER BY synname; +{###########################################} +{### If Target Type is Package ###} +{###########################################} +{% elif trgTyp == 'P' %} +SELECT nspname AS name + FROM pg_catalog.pg_namespace +WHERE nspparent IN ( + SELECT oid + FROM pg_catalog.pg_namespace + WHERE nspname = {{ trgSchema|qtLiteral }} LIMIT 1 + ) + AND nspobjecttype = 0 +ORDER BY nspname; {% else %} {###################################################} {### If Target Type is Table/View/M.View/Sequnce ###} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/get_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/9.5_plus/get_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/get_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/properties.sql index 41cc20f22..ef7444d4d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/templates/synonyms/sql/default/properties.sql @@ -1,15 +1,27 @@ -SELECT synname AS name, pg_catalog.pg_get_userbyid(synowner) AS owner, +SELECT s.oid, synname AS name, pg_catalog.pg_get_userbyid(synowner) AS owner, synobjschema, synobjname, ns.nspname as schema, - COALESCE((SELECT relkind + COALESCE( + (SELECT relkind FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n WHERE c.relnamespace = n.oid AND n.nspname = synobjschema AND c.relname = synobjname), + -- For Function/Procedure (SELECT CASE WHEN p.protype = '0' THEN 'f'::"char" ELSE 'p'::"char" END FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n WHERE p.pronamespace = n.oid AND n.nspname = synobjschema - AND p.proname = synobjname LIMIT 1), 's') AS targettype -- Default s = Synonym + AND p.proname = synobjname LIMIT 1), + -- For Package + (SELECT CASE WHEN count(*) > 0 THEN 'P'::"char" END + FROM pg_catalog.pg_namespace + WHERE nspparent IN (SELECT oid + FROM pg_catalog.pg_namespace + WHERE nspname = synobjschema LIMIT 1) + AND nspname = synobjname + AND nspobjecttype = 0), + -- Default s = Synonym + 's') AS targettype FROM pg_catalog.pg_synonym s JOIN pg_catalog.pg_namespace ns ON s.synnamespace = ns.oid WHERE s.synnamespace={{scid}}::oid {% if syid %} 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 deleted file mode 100644 index 63674778f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.msql +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 2efcafa64..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_alt_privilege.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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/pg/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 deleted file mode 100644 index 5a232ed75..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.msql +++ /dev/null @@ -1,15 +0,0 @@ -ALTER TABLE IF EXISTS 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 IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; - -ALTER TABLE IF EXISTS 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/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 deleted file mode 100644 index e4b793586..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_char.sql +++ /dev/null @@ -1,17 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" - IS 'Comment for alter'; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; - -ALTER TABLE IF EXISTS 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/pg/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 deleted file mode 100644 index 31a650287..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.msql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE IF EXISTS 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/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 deleted file mode 100644 index 207bc646f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_int.sql +++ /dev/null @@ -1,11 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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/pg/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 deleted file mode 100644 index 8f400900f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.msql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE IF EXISTS 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; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/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 deleted file mode 100644 index 45f6e03cf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_numeric.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for alter'; - -ALTER TABLE IF EXISTS 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/pg/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 deleted file mode 100644 index d4caec80e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.msql +++ /dev/null @@ -1,2 +0,0 @@ -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/pg/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 deleted file mode 100644 index 96a9438dc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_remove_length.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for alter'; - -ALTER TABLE IF EXISTS 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/pg/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 deleted file mode 100644 index b07eb190e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.msql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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/pg/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 deleted file mode 100644 index 51559b69e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_char.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_2_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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/pg/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 deleted file mode 100644 index ec7d70ac7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.msql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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/pg/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 deleted file mode 100644 index e62203d82..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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/pg/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 deleted file mode 100644 index 08d2390d8..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.msql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for create'; - -ALTER TABLE IF EXISTS 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/pg/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 deleted file mode 100644 index f14a91356..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_numeric.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_4_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for create'; - -ALTER TABLE IF EXISTS 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/pg/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json deleted file mode 100644 index 37db613cb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/test.json +++ /dev/null @@ -1,698 +0,0 @@ -{ - "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": "", - "attprecision": "", - "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": "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": "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": "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)", - "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": "", - "attoptions": [], - "seclabels": [] - }, - "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": "postgres", - "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": "", - "attprecision": "", - "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": "postgres", - "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": "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": "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": "", - "attprecision": "", - "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": "", - "attprecision": "", - "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_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Column with text & default value", - "endpoint": "NODE-column.obj", - "sql_endpoint": "NODE-column.sql_id", - "msql_endpoint": "NODE-column.msql", - "data": { - "name": "col__1_$%{}[]()&*^!@\"'`\\/#", - "cltype": "text", - "attacl": [], - "description": "test comment", - "is_primary_key": false, - "attnotnull": false, - "attlen": "", - "attprecision": "", - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [], - "defval": "'xyz'" - }, - "expected_sql_file": "create_column_text_with_default_value.sql", - "expected_msql_file": "create_column_text_with_default_value.msql" - }, - { - "type": "alter", - "name": "Alter Column with text & update default value", - "endpoint": "NODE-column.obj_id", - "sql_endpoint": "NODE-column.sql_id", - "msql_endpoint": "NODE-column.msql_id", - "data": { - "name": "col__1_$%{}[]()&*^!@\"'`\\/#", - "defval": "'changed default value'", - "attacl": { - "added": [ - { - "grantee": "PUBLIC", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "r", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "expected_sql_file": "alter_column_text_with_default_value.sql", - "expected_msql_file": "alter_column_text_with_default_value.msql" - }, - { - "type": "delete", - "name": "Drop Column with identity (ALWAYS)", - "endpoint": "NODE-column.obj_id", - "sql_endpoint": "NODE-column.sql_id", - "data": { - "name": "col__1_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Column with time with time zone & default value using function", - "endpoint": "NODE-column.obj", - "sql_endpoint": "NODE-column.sql_id", - "msql_endpoint": "NODE-column.msql", - "data": { - "name": "col__2_$%{}[]()&*^!@\"'`\\/#", - "cltype": "time with time zone", - "attacl": [], - "description": "test comment", - "min_val_attlen": 0, - "max_val_attlen": 6, - "is_primary_key": false, - "attnotnull": false, - "attlen": "4", - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [], - "defval": "now()" - }, - "expected_sql_file": "create_column_timestamp_with_default_value_using_function.sql", - "expected_msql_file": "create_column_timestamp_with_default_value_using_function.msql" - }, - { - "type": "alter", - "name": "Alter Column with time with time zone & update length", - "endpoint": "NODE-column.obj_id", - "sql_endpoint": "NODE-column.sql_id", - "msql_endpoint": "NODE-column.msql_id", - "data": { - "name": "col__2_$%{}[]()&*^!@\"'`\\/#", - "attlen": "6", - "attnotnull": true, - "description": "test comment modification" - }, - "expected_sql_file": "alter_column_timestamp_with_default_value_using_function.sql", - "expected_msql_file": "alter_column_timestamp_with_default_value_using_function.msql" - }, - { - "type": "delete", - "name": "Drop Column with identity (ALWAYS)", - "endpoint": "NODE-column.obj_id", - "sql_endpoint": "NODE-column.sql_id", - "data": { - "name": "col__2_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Column with interger_array and options", - "endpoint": "NODE-column.obj", - "sql_endpoint": "NODE-column.sql_id", - "msql_endpoint": "NODE-column.msql", - "data": { - "name": "col__3_$%{}[]()&*^!@\"'`\\/#", - "cltype": "integer[]", - "attacl": [], - "description": "comment", - "is_primary_key": false, - "attnotnull": true, - "attlen": "", - "attprecision": "", - "attidentity": "a", - "colconstype": "n", - "attoptions": [ - { - "name": "n_distinct", - "value": "1" - } - ], - "seclabels": [] - }, - "expected_sql_file": "create_column_with_interger_array_and_options.sql", - "expected_msql_file": "create_column_with_interger_array_and_options.msql" - }, - { - "type": "alter", - "name": "Alter Column with interger_array and options", - "endpoint": "NODE-column.obj_id", - "sql_endpoint": "NODE-column.sql_id", - "msql_endpoint": "NODE-column.msql_id", - "data": { - "name": "col__3_$%{}[]()&*^!@\"'`\\/#", - "attoptions": { - "changed": [ - { - "name": "n_distinct", - "value": "2" - } - ] - } - }, - "expected_sql_file": "alter_column_with_interger_array_and_options.sql", - "expected_msql_file": "alter_column_with_interger_array_and_options.msql" - }, - { - "type": "delete", - "name": "Drop Column with identity (ALWAYS)", - "endpoint": "NODE-column.obj_id", - "sql_endpoint": "NODE-column.sql_id", - "data": { - "name": "col__3_$%{}[]()&*^!@\"'`\\/#" - } - } - ] -} 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 index 24fa69019..63674778f 100644 --- 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 @@ -1,2 +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; +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/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 index 117972430..2efcafa64 100644 --- 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 @@ -1,13 +1,13 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; -GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO 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/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql index 569d1474e..5a232ed75 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.msql @@ -1,15 +1,15 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" +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_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/pg/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql index e15bbff46..e4b793586 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_char.sql @@ -1,17 +1,17 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS 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_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/pg/10_plus/alter_column_drop_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_drop_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_comb_start_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_comb_start_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql index c54b18a36..31a650287 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.msql @@ -1,9 +1,9 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/pg/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql index 1928d9123..207bc646f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_int.sql @@ -1,11 +1,11 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/pg/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql index 663cc4953..8f400900f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.msql @@ -1,9 +1,9 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +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_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/pg/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql index 259de464e..45f6e03cf 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_numeric.sql @@ -1,15 +1,15 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" SET (n_distinct=1); -GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/pg/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 index 07891245e..d4caec80e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/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 @@ -1,2 +1,2 @@ -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric; \ No newline at end of file +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/pg/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 index b3b732333..96a9438dc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/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 @@ -1,15 +1,15 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" SET (n_distinct=1); -GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/pg/10_plus/alter_column_text_with_default_value.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_text_with_default_value.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_text_with_default_value.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_text_with_default_value.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_text_with_default_value.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_text_with_default_value.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_text_with_default_value.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_text_with_default_value.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_timestamp_with_default_value_using_function.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_timestamp_with_default_value_using_function.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_timestamp_with_default_value_using_function.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_timestamp_with_default_value_using_function.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_timestamp_with_default_value_using_function.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_timestamp_with_default_value_using_function.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_timestamp_with_default_value_using_function.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_timestamp_with_default_value_using_function.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_with_interger_array_and_options.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_with_interger_array_and_options.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_with_interger_array_and_options.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_with_interger_array_and_options.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_with_interger_array_and_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_with_interger_array_and_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/alter_column_with_interger_array_and_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/alter_column_with_interger_array_and_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql index 6c6a7203e..b07eb190e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.msql @@ -1,5 +1,5 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" +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/pg/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql index 41ab08a13..51559b69e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_char.sql @@ -1,9 +1,9 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_2_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_2_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" +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/pg/10_plus/create_column_identity_for_restart_seq.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_identity_for_restart_seq.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_identity_for_restart_seq.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql index e0c67ea38..ec7d70ac7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.msql @@ -1,5 +1,5 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_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/pg/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql index 38da2b3d6..e62203d82 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int.sql @@ -1,9 +1,9 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_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/pg/10_plus/create_column_int_identity.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity_by_default.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_int_identity_by_default.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql index cfda50c95..08d2390d8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.msql @@ -1,9 +1,9 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_3_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for create'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS 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/pg/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql index b85cd3569..f14a91356 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_numeric.sql @@ -1,13 +1,13 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_3_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_3_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for create'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS 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/pg/10_plus/create_column_text_with_default_value.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_text_with_default_value.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_text_with_default_value.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_text_with_default_value.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_text_with_default_value.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_text_with_default_value.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_text_with_default_value.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_text_with_default_value.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_timestamp_with_default_value_using_function.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_timestamp_with_default_value_using_function.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_timestamp_with_default_value_using_function.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_timestamp_with_default_value_using_function.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_timestamp_with_default_value_using_function.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_timestamp_with_default_value_using_function.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_timestamp_with_default_value_using_function.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_timestamp_with_default_value_using_function.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_with_interger_array_and_options.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_with_interger_array_and_options.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_with_interger_array_and_options.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_with_interger_array_and_options.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_with_interger_array_and_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_with_interger_array_and_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/10_plus/create_column_with_interger_array_and_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/create_column_with_interger_array_and_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json index 46e36c0aa..37db613cb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/pg/default/test.json @@ -2,11 +2,11 @@ "scenarios": [ { "type": "create", - "name": "Create Table for testing column node (Ver.default)", + "name": "Create Table for testing column node (v.10+)", "endpoint": "NODE-table.obj", "sql_endpoint": "NODE-table.sql_id", "data": { - "name": "table_1_$%{}[]()&*^!@\"'`\\/#", + "name": "table_2_$%{}[]()&*^!@\"'`\\/#", "is_partitioned": false, "columns": [], "schema": "testschema" @@ -89,6 +89,7 @@ "data": { "attnum": 1, "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", "attacl": { "changed": [ { @@ -198,13 +199,103 @@ }, { "type": "create", - "name": "Create Column (Numeric type with Length Precision & Variables)", + "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": "", + "attprecision": "", + "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": "postgres", + "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", @@ -232,8 +323,8 @@ "sql_endpoint": "NODE-column.sql_id", "msql_endpoint": "NODE-column.msql_id", "data": { - "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", - "attnum": 3, + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "attnum": 4, "attlen": "15", "attprecision": "6", "description": "Comment for alter", @@ -290,7 +381,317 @@ "endpoint": "NODE-column.obj_id", "sql_endpoint": "NODE-column.sql_id", "data": { - "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + "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": "", + "attprecision": "", + "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": "", + "attprecision": "", + "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_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with text & default value", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col__1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "text", + "attacl": [], + "description": "test comment", + "is_primary_key": false, + "attnotnull": false, + "attlen": "", + "attprecision": "", + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [], + "defval": "'xyz'" + }, + "expected_sql_file": "create_column_text_with_default_value.sql", + "expected_msql_file": "create_column_text_with_default_value.msql" + }, + { + "type": "alter", + "name": "Alter Column with text & update default value", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "col__1_$%{}[]()&*^!@\"'`\\/#", + "defval": "'changed default value'", + "attacl": { + "added": [ + { + "grantee": "PUBLIC", + "grantor": "postgres", + "privileges": [ + { + "privilege_type": "r", + "privilege": true, + "with_grant": false + } + ] + } + ] + } + }, + "expected_sql_file": "alter_column_text_with_default_value.sql", + "expected_msql_file": "alter_column_text_with_default_value.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col__1_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with time with time zone & default value using function", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col__2_$%{}[]()&*^!@\"'`\\/#", + "cltype": "time with time zone", + "attacl": [], + "description": "test comment", + "min_val_attlen": 0, + "max_val_attlen": 6, + "is_primary_key": false, + "attnotnull": false, + "attlen": "4", + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [], + "defval": "now()" + }, + "expected_sql_file": "create_column_timestamp_with_default_value_using_function.sql", + "expected_msql_file": "create_column_timestamp_with_default_value_using_function.msql" + }, + { + "type": "alter", + "name": "Alter Column with time with time zone & update length", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "col__2_$%{}[]()&*^!@\"'`\\/#", + "attlen": "6", + "attnotnull": true, + "description": "test comment modification" + }, + "expected_sql_file": "alter_column_timestamp_with_default_value_using_function.sql", + "expected_msql_file": "alter_column_timestamp_with_default_value_using_function.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col__2_$%{}[]()&*^!@\"'`\\/#" + } + }, + { + "type": "create", + "name": "Create Column with interger_array and options", + "endpoint": "NODE-column.obj", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql", + "data": { + "name": "col__3_$%{}[]()&*^!@\"'`\\/#", + "cltype": "integer[]", + "attacl": [], + "description": "comment", + "is_primary_key": false, + "attnotnull": true, + "attlen": "", + "attprecision": "", + "attidentity": "a", + "colconstype": "n", + "attoptions": [ + { + "name": "n_distinct", + "value": "1" + } + ], + "seclabels": [] + }, + "expected_sql_file": "create_column_with_interger_array_and_options.sql", + "expected_msql_file": "create_column_with_interger_array_and_options.msql" + }, + { + "type": "alter", + "name": "Alter Column with interger_array and options", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "msql_endpoint": "NODE-column.msql_id", + "data": { + "name": "col__3_$%{}[]()&*^!@\"'`\\/#", + "attoptions": { + "changed": [ + { + "name": "n_distinct", + "value": "2" + } + ] + } + }, + "expected_sql_file": "alter_column_with_interger_array_and_options.sql", + "expected_msql_file": "alter_column_with_interger_array_and_options.msql" + }, + { + "type": "delete", + "name": "Drop Column with identity (ALWAYS)", + "endpoint": "NODE-column.obj_id", + "sql_endpoint": "NODE-column.sql_id", + "data": { + "name": "col__3_$%{}[]()&*^!@\"'`\\/#" } } ] 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 deleted file mode 100644 index 7f5387c51..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.msql +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index fefc11b7f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_alt_privilege.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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 deleted file mode 100644 index 5a232ed75..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.msql +++ /dev/null @@ -1,15 +0,0 @@ -ALTER TABLE IF EXISTS 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 IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; - -ALTER TABLE IF EXISTS 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; 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 deleted file mode 100644 index e4b793586..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_char.sql +++ /dev/null @@ -1,17 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" - IS 'Comment for alter'; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; - -ALTER TABLE IF EXISTS 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_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql deleted file mode 100644 index 31a650287..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.msql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE IF EXISTS 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; 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 deleted file mode 100644 index 207bc646f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_int.sql +++ /dev/null @@ -1,11 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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 deleted file mode 100644 index 8f400900f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.msql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE IF EXISTS 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; 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 deleted file mode 100644 index 45f6e03cf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_numeric.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for alter'; - -ALTER TABLE IF EXISTS 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 deleted file mode 100644 index e2ffd2c85..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.msql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric; 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 deleted file mode 100644 index 96a9438dc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_remove_length.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for alter'; - -ALTER TABLE IF EXISTS 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 deleted file mode 100644 index b07eb190e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.msql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql deleted file mode 100644 index 51559b69e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_char.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_2_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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_int.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql deleted file mode 100644 index ec7d70ac7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.msql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql deleted file mode 100644 index e62203d82..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "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_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql deleted file mode 100644 index 08d2390d8..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.msql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for create'; - -ALTER TABLE IF EXISTS 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/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql deleted file mode 100644 index f14a91356..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_numeric.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" - --- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_4_$%{}[]()&*^!@""'`\/#"; - -ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; - -COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" - IS 'Comment for create'; - -ALTER TABLE IF EXISTS 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 deleted file mode 100644 index b242dd51d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/test.json +++ /dev/null @@ -1,530 +0,0 @@ -{ - "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": "", - "attprecision": "", - "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": "", - "attoptions": [], - "seclabels": [] - }, - "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": "", - "attprecision": "", - "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": "", - "attprecision": "", - "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": "", - "attprecision": "", - "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 index 08de11032..7f5387c51 100644 --- 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 @@ -1,2 +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; +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/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 index c99db583a..fefc11b7f 100644 --- 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 @@ -1,13 +1,13 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_2_$%{}[]()&*^!@""'`\/#" TO PUBLIC; -GRANT INSERT("new_col_1_$%{}[]()&*^!@""'`\/#"), SELECT("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO 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/default/alter_column_char.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.msql index 569d1474e..5a232ed75 100644 --- 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 @@ -1,15 +1,15 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" RENAME "col_2_$%{}[]()&*^!@""'`\/#" TO "new_col_2_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" TYPE character(None) COLLATE pg_catalog."C"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STORAGE PLAIN; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" +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_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/default/alter_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_char.sql index e15bbff46..e4b793586 100644 --- 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 @@ -1,17 +1,17 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "new_col_2_$%{}[]()&*^!@""'`\/#" character(1) COLLATE pg_catalog."C"; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_2_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_2_$%{}[]()&*^!@""'`\/#" SET STATISTICS 5; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS 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_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/default/alter_column_drop_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_drop_identity.msql 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/default/alter_column_drop_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_drop_identity.sql 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/default/alter_column_drop_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_drop_identity_by_default.msql 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/default/alter_column_drop_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_drop_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_drop_identity_by_default.sql 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/default/alter_column_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity.msql 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/default/alter_column_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity.sql 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/default/alter_column_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity_by_default.msql 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/default/alter_column_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity_by_default.sql 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/default/alter_column_identity_for_comb_start_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity_for_comb_start_seq.msql 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/default/alter_column_identity_for_comb_start_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_comb_start_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity_for_comb_start_seq.sql 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/default/alter_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity_for_restart_seq.msql 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/default/alter_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_identity_for_restart_seq.sql 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 index c54b18a36..31a650287 100644 --- 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 @@ -1,9 +1,9 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" RENAME "col_1_$%{}[]()&*^!@""'`\/#" TO "new_col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" ALTER COLUMN "new_col_1_$%{}[]()&*^!@""'`\/#" TYPE real; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/default/alter_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_int.sql index 1928d9123..207bc646f 100644 --- 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 @@ -1,11 +1,11 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "new_col_1_$%{}[]()&*^!@""'`\/#" real NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_1_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -GRANT ALL("new_col_1_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/default/alter_column_numeric.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.msql index 663cc4953..8f400900f 100644 --- 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 @@ -1,9 +1,9 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - RENAME "col_3_$%{}[]()&*^!@""'`\/#" TO "new_col_3_$%{}[]()&*^!@""'`\/#"; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + RENAME "col_4_$%{}[]()&*^!@""'`\/#" TO "new_col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric(15, 6); -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +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_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/default/alter_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_numeric.sql index 259de464e..45f6e03cf 100644 --- 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 @@ -1,15 +1,15 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric(15,6) NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" SET (n_distinct=1); -GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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/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 index aef4d94eb..e2ffd2c85 100644 --- 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 @@ -1,2 +1,2 @@ -ALTER TABLE testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" TYPE numeric; +ALTER TABLE testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" TYPE numeric; 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 index b3b732333..96a9438dc 100644 --- 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 @@ -1,15 +1,15 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "new_col_3_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "new_col_4_$%{}[]()&*^!@""'`\/#" numeric NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."new_col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."new_col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for alter'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "new_col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ALTER COLUMN "new_col_4_$%{}[]()&*^!@""'`\/#" SET (n_distinct=1); -GRANT ALL("new_col_3_$%{}[]()&*^!@""'`\/#") ON testschema."table_1_$%{}[]()&*^!@""'`\/#" TO PUBLIC; +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_text_with_default_value.msql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_text_with_default_value.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_text_with_default_value.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_text_with_default_value.msql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_text_with_default_value.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_text_with_default_value.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/alter_column_text_with_default_value.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/alter_column_text_with_default_value.sql 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 index 6c6a7203e..b07eb190e 100644 --- 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 @@ -1,5 +1,5 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" +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/default/create_column_char.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_char.sql index 41ab08a13..51559b69e 100644 --- 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 @@ -1,9 +1,9 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_2_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_2_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_2_$%{}[]()&*^!@""'`\/#" character varying(50) COLLATE pg_catalog."C"; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_2_$%{}[]()&*^!@""'`\/#" +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/default/create_column_identity_for_restart_seq.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_identity_for_restart_seq.msql 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/default/create_column_identity_for_restart_seq.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_identity_for_restart_seq.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_identity_for_restart_seq.sql 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 index e0c67ea38..ec7d70ac7 100644 --- 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 @@ -1,5 +1,5 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_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/default/create_column_int.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int.sql index 38da2b3d6..e62203d82 100644 --- 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 @@ -1,9 +1,9 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_1_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_1_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" ADD COLUMN IF NOT EXISTS "col_1_$%{}[]()&*^!@""'`\/#" bigint NOT NULL DEFAULT 1; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_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/default/create_column_int_identity.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int_identity.msql 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/default/create_column_int_identity.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int_identity.sql 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/default/create_column_int_identity_by_default.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.msql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int_identity_by_default.msql 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/default/create_column_int_identity_by_default.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/10_plus/create_column_int_identity_by_default.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_int_identity_by_default.sql 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 index cfda50c95..08d2390d8 100644 --- 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 @@ -1,9 +1,9 @@ -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_3_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10, 5) NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for create'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS 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/default/create_column_numeric.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/create_column_numeric.sql index b85cd3569..f14a91356 100644 --- 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 @@ -1,13 +1,13 @@ --- Column: testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" +-- Column: testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" --- ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_3_$%{}[]()&*^!@""'`\/#"; +-- ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" DROP COLUMN IF EXISTS "col_4_$%{}[]()&*^!@""'`\/#"; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ADD COLUMN IF NOT EXISTS "col_3_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; +ALTER TABLE IF EXISTS testschema."table_2_$%{}[]()&*^!@""'`\/#" + ADD COLUMN IF NOT EXISTS "col_4_$%{}[]()&*^!@""'`\/#" numeric(10,5) NOT NULL; -COMMENT ON COLUMN testschema."table_1_$%{}[]()&*^!@""'`\/#"."col_3_$%{}[]()&*^!@""'`\/#" +COMMENT ON COLUMN testschema."table_2_$%{}[]()&*^!@""'`\/#"."col_4_$%{}[]()&*^!@""'`\/#" IS 'Comment for create'; -ALTER TABLE IF EXISTS testschema."table_1_$%{}[]()&*^!@""'`\/#" - ALTER COLUMN "col_3_$%{}[]()&*^!@""'`\/#" +ALTER TABLE IF EXISTS 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/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/tests/ppas/default/test.json index 7882b4958..b242dd51d 100644 --- 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 @@ -2,11 +2,11 @@ "scenarios": [ { "type": "create", - "name": "Create Table for testing column node (Ver.default)", + "name": "Create Table for testing column node (v.10+)", "endpoint": "NODE-table.obj", "sql_endpoint": "NODE-table.sql_id", "data": { - "name": "table_1_$%{}[]()&*^!@\"'`\\/#", + "name": "table_2_$%{}[]()&*^!@\"'`\\/#", "is_partitioned": false, "columns": [], "schema": "testschema" @@ -50,7 +50,7 @@ "added": [ { "grantee": "PUBLIC", - "grantor": "enterprisedb", + "grantor": "enteprisedb", "privileges": [ { "privilege_type": "a", @@ -89,6 +89,7 @@ "data": { "attnum": 1, "name": "new_col_1_$%{}[]()&*^!@\"'`\\/#", + "cltype": "real", "attacl": { "changed": [ { @@ -198,13 +199,103 @@ }, { "type": "create", - "name": "Create Column (Numeric type with Length Precision & Variables)", + "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": "", + "attprecision": "", + "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", @@ -232,8 +323,8 @@ "sql_endpoint": "NODE-column.sql_id", "msql_endpoint": "NODE-column.msql_id", "data": { - "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#", - "attnum": 3, + "name": "new_col_4_$%{}[]()&*^!@\"'`\\/#", + "attnum": 4, "attlen": "15", "attprecision": "6", "description": "Comment for alter", @@ -290,7 +381,149 @@ "endpoint": "NODE-column.obj_id", "sql_endpoint": "NODE-column.sql_id", "data": { - "name": "new_col_3_$%{}[]()&*^!@\"'`\\/#" + "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": "", + "attprecision": "", + "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": "", + "attprecision": "", + "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/constraints/foreign_key/tests/9.3_plus/alter_name_comment_validation.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/alter_name_comment_validation.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/alter_name_comment_validation.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/alter_name_comment_validation.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/alter_name_comment_validation_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/alter_name_comment_validation_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/alter_name_comment_validation_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/alter_name_comment_validation_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_cascade.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_cascade.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_cascade.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_cascade.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_cascade_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_cascade_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_cascade_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_cascade_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_restrict.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_restrict.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_restrict.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_restrict.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_restrict_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_restrict_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_restrict_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_restrict_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setdefault.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setdefault.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setdefault.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setdefault.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setdefault_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setdefault_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setdefault_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setdefault_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setnull.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setnull.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setnull.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setnull.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setnull_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setnull_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_setnull_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_setnull_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_simple.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_simple.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_simple.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_simple.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_simple_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_simple_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_simple_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_simple_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_with_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_with_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_with_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_with_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/create_foreign_key_with_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/create_foreign_key_with_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/test_foreign_keys.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/test_foreign_keys.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/9.3_plus/test_foreign_keys.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/tests/default/test_foreign_keys.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_delete_policy_with_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_delete_policy_with_using.sql deleted file mode 100644 index befa16ad5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_delete_policy_with_using.sql +++ /dev/null @@ -1,10 +0,0 @@ --- POLICY: test_delete_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR DELETE - TO public - USING ((salary < '1000000000000'::bigint)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_delete_policy_with_using_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_delete_policy_with_using_msql.sql deleted file mode 100644 index 6aaa35aa4..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_delete_policy_with_using_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER POLICY "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - USING (salary < 1000000000000); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_select_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_select_policy.sql deleted file mode 100644 index 93b0a3fe2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_select_policy.sql +++ /dev/null @@ -1,10 +0,0 @@ --- POLICY: test_select_policy_rls_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS PERMISSIVE - FOR SELECT - TO public - USING ((name = (CURRENT_USER)::text)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_select_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_select_policy_msql.sql deleted file mode 100644 index 038fb0843..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_select_policy_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER POLICY "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - USING (name = current_user); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_all_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_all_policy.sql deleted file mode 100644 index bdeb6b0f3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_all_policy.sql +++ /dev/null @@ -1,11 +0,0 @@ --- POLICY: test_all_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR ALL - TO public - USING (true) - WITH CHECK (true); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_all_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_all_policy_msql.sql deleted file mode 100644 index 53f404cbd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_all_policy_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - USING (true); - -ALTER POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - WITH CHECK (true); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_insert_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_insert_policy.sql deleted file mode 100644 index 6c3dba682..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_insert_policy.sql +++ /dev/null @@ -1,10 +0,0 @@ --- POLICY: test_simple_insert_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS PERMISSIVE - FOR INSERT - TO public - WITH CHECK (((CURRENT_USER)::text = name)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_insert_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_insert_policy_msql.sql deleted file mode 100644 index 9b292234e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_simple_insert_policy_msql.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER POLICY "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - WITH CHECK (current_user = name); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_update_policy_with_check_and_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_update_policy_with_check_and_using.sql deleted file mode 100644 index d9e1b39a5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_update_policy_with_check_and_using.sql +++ /dev/null @@ -1,11 +0,0 @@ --- POLICY: test_update_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR UPDATE - TO public - USING (((CURRENT_USER)::text = name)) - WITH CHECK ((emp_id <> 0)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_update_policy_with_check_and_using_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_update_policy_with_check_and_using_msql.sql deleted file mode 100644 index e278b94da..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_update_policy_with_check_and_using_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - USING (current_user=name); - -ALTER POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - WITH CHECK (emp_id != 0); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_delete_policy_with_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_delete_policy_with_using.sql deleted file mode 100644 index 82e3f6c65..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_delete_policy_with_using.sql +++ /dev/null @@ -1,10 +0,0 @@ --- POLICY: test_delete_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR DELETE - TO public - USING (((CURRENT_USER)::text = name)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_delete_policy_with_using_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_delete_policy_with_using_msql.sql deleted file mode 100644 index fbacba3b6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_delete_policy_with_using_msql.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE POLICY "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR DELETE - TO public - USING (current_user = name); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_select_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_select_policy.sql deleted file mode 100644 index 0dcf0ee86..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_select_policy.sql +++ /dev/null @@ -1,9 +0,0 @@ --- POLICY: test_select_policy_rls_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS PERMISSIVE - FOR SELECT - TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_select_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_select_policy_msql.sql deleted file mode 100644 index a76d0818c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_select_policy_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE POLICY "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS PERMISSIVE - FOR SELECT - TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_all_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_all_policy.sql deleted file mode 100644 index 06e9ed7a5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_all_policy.sql +++ /dev/null @@ -1,9 +0,0 @@ --- POLICY: test_all_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR ALL - TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_all_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_all_policy_msql.sql deleted file mode 100644 index e0d2f6d7e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_all_policy_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR ALL - TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_insert_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_insert_policy.sql deleted file mode 100644 index 746062fda..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_insert_policy.sql +++ /dev/null @@ -1,9 +0,0 @@ --- POLICY: test_simple_insert_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS PERMISSIVE - FOR INSERT - TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_insert_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_insert_policy_msql.sql deleted file mode 100644 index ad1986a82..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_simple_insert_policy_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE POLICY "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS PERMISSIVE - FOR INSERT - TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_update_policy_with_check_and_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_update_policy_with_check_and_using.sql deleted file mode 100644 index d39be28bf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_update_policy_with_check_and_using.sql +++ /dev/null @@ -1,11 +0,0 @@ --- POLICY: test_update_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY IF EXISTS "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR UPDATE - TO public - USING (true) - WITH CHECK ((name <> NULL::text)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_update_policy_with_check_and_using_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_update_policy_with_check_and_using_msql.sql deleted file mode 100644 index 02fca09a0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_update_policy_with_check_and_using_msql.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - AS RESTRICTIVE - FOR UPDATE - TO public - USING (true) - WITH CHECK (name != null); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/test.json deleted file mode 100644 index fff033ad2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/test.json +++ /dev/null @@ -1,275 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Table For RLS policy", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "test_rls_policy", - "columns": [ - { - "name": "emp_id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "text" - }, - { - "name": "salary", - "cltype": "bigint" - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create simple select event RLS policy", - "endpoint": "NODE-row_security_policy.obj", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql", - "data": { - "name": "test_select_policy_rls_$%{}[]()&*^!@\"'`\\/#", - "event": "SELECT", - "policyowner": "public", - "schema": "public", - "type": "PERMISSIVE" - }, - "expected_sql_file": "create_select_policy.sql", - "expected_msql_file": "create_select_policy_msql.sql" - }, - { - "type": "alter", - "name": "Alter simple select event RLS policy with using clause", - "endpoint": "NODE-row_security_policy.obj_id", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql_id", - "data": { - "name": "test_select_policy_rls_$%{}[]()&*^!@\"'`\\/#", - "using": "name = current_user", - "schema": "public" - }, - "expected_sql_file": "alter_select_policy.sql", - "expected_msql_file": "alter_select_policy_msql.sql" - }, - { - "type": "delete", - "name": "Drop policy", - "endpoint": "NODE-row_security_policy.delete_id", - "data": { - "name": "test_select_rls_policy_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create simple insert event RLS policy", - "endpoint": "NODE-row_security_policy.obj", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql", - "data": { - "name": "test_simple_insert_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "policyowner": "public", - "event": "INSERT", - "withcheck": "", - "type": "PERMISSIVE", - "schema": "public" - }, - "expected_sql_file": "create_simple_insert_policy.sql", - "expected_msql_file": "create_simple_insert_policy_msql.sql" - }, - { - "type": "alter", - "name": "Alter simple insert event RLS policy by adding check", - "endpoint": "NODE-row_security_policy.obj_id", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql_id", - "data": { - "name": "test_simple_insert_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "withcheck": "current_user = name", - "schema": "public" - }, - "expected_sql_file": "alter_simple_insert_policy.sql", - "expected_msql_file": "alter_simple_insert_policy_msql.sql" - }, - { - "type": "delete", - "name": "Drop policy", - "endpoint": "NODE-row_security_policy.delete_id", - "data": { - "name": "test_simple_insert_rls_policy_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create update event restrictive RLS policy with check and using clause", - "endpoint": "NODE-row_security_policy.obj", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql", - "data": { - "name": "test_update_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "policyowner": "public", - "event": "UPDATE", - "using": "true", - "withcheck": "name != null", - "type": "RESTRICTIVE", - "schema": "public" - }, - "expected_sql_file": "create_update_policy_with_check_and_using.sql", - "expected_msql_file": "create_update_policy_with_check_and_using_msql.sql" - }, - { - "type": "alter", - "name": "Alter update event restrictive RLS policy with check and using clause", - "endpoint": "NODE-row_security_policy.obj_id", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql_id", - "data": { - "name": "test_update_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "withcheck": "emp_id != 0", - "using": "current_user=name" - }, - "expected_sql_file": "alter_update_policy_with_check_and_using.sql", - "expected_msql_file": "alter_update_policy_with_check_and_using_msql.sql" - }, - { - "type": "delete", - "name": "Drop policy", - "endpoint": "NODE-row_security_policy.delete_id", - "data": { - "name": "test_update_rls_policy_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create delete event restrictive RLS policy with check", - "endpoint": "NODE-row_security_policy.obj", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql", - "data": { - "name": "test_delete_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "policyowner": "public", - "event": "DELETE", - "using": "current_user = name", - "withcheck": "", - "type": "RESTRICTIVE", - "schema": "public" - }, - "expected_sql_file": "create_delete_policy_with_using.sql", - "expected_msql_file": "create_delete_policy_with_using_msql.sql" - }, - { - "type": "alter", - "name": "Alter delete event restrictive RLS policy by changing check clause", - "endpoint": "NODE-row_security_policy.obj_id", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql_id", - "data": { - "name": "test_delete_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "using": "salary < 1000000000000", - "schema": "public" - }, - "expected_sql_file": "alter_delete_policy_with_using.sql", - "expected_msql_file": "alter_delete_policy_with_using_msql.sql" - }, - { - "type": "delete", - "name": "Drop policy", - "endpoint": "NODE-row_security_policy.delete_id", - "data": { - "name": "test_delete_rls_policy_update_name_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create simple all event restrictive RLS policy", - "endpoint": "NODE-row_security_policy.obj", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql", - "data": { - "name": "test_all_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "policyowner": "public", - "event": "ALL", - "type": "RESTRICTIVE", - "schema": "public" - }, - "expected_sql_file": "create_simple_all_policy.sql", - "expected_msql_file": "create_simple_all_policy_msql.sql" - }, - { - "type": "alter", - "name": "Alter simple all event restrictive RLS policy with using & check clause", - "endpoint": "NODE-row_security_policy.obj_id", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql_id", - "data": { - "name": "test_all_rls_policy_$%{}[]()&*^!@\"'`\\/#", - "using": "true", - "withcheck": "true", - "schema": "public" - }, - "expected_sql_file": "alter_simple_all_policy.sql", - "expected_msql_file": "alter_simple_all_policy_msql.sql" - }, - { - "type": "delete", - "name": "Drop policy", - "endpoint": "NODE-row_security_policy.delete_id", - "data": { - "name": "test_all_rls_policy_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create RLS policy", - "endpoint": "NODE-row_security_policy.obj", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "data": { - "name": "test", - "schema": "public" - }, - "expected_sql_file": "create_public_policy.sql" - }, - { - "type": "alter", - "name": "Alter policy name", - "endpoint": "NODE-row_security_policy.obj_id", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "msql_endpoint": "NODE-row_security_policy.msql_id", - "data": { - "name": "policy_1" - }, - "expected_sql_file": "alter_policy.sql", - "expected_msql_file": "alter_policy_msql.sql" - }, - { - "type": "create", - "name": "Create RLS policy for event 'ALL'", - "endpoint": "NODE-row_security_policy.obj", - "sql_endpoint": "NODE-row_security_policy.sql_id", - "data": { - "name": "all_event_policy", - "event": "ALL", - "policyowner": "public", - "schema": "public", - "using": "true", - "withcheck": "true", - "type": "RESTRICTIVE" - }, - "expected_sql_file": "create_all_event_policy.sql" - }, - { - "type": "delete", - "name": "Drop policy", - "endpoint": "NODE-row_security_policy.delete_id", - "data": { - "name": "test_delete_policy_$%{}[]()&*^!@\"'`\\/#" - } - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_delete_policy_with_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_delete_policy_with_using.sql index 6adb34fde..befa16ad5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_delete_policy_with_using.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_delete_policy_with_using.sql @@ -4,6 +4,7 @@ CREATE POLICY "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR DELETE TO public USING ((salary < '1000000000000'::bigint)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_insert_policy_with_check.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_insert_policy_with_check.sql deleted file mode 100644 index 7b8f6911b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_insert_policy_with_check.sql +++ /dev/null @@ -1,9 +0,0 @@ --- POLICY: test_insert_rls_policy_update_name_$%{}[]()&*^!@"'`\/# - --- DROP POLICY "test_insert_rls_policy_update_name_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_insert_rls_policy_update_name_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - FOR INSERT - TO public - WITH CHECK (((salary <> 0) AND (salary < 100000))); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_insert_policy_with_check_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_insert_policy_with_check_msql.sql deleted file mode 100644 index fccf8d326..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_insert_policy_with_check_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER POLICY "test_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - WITH CHECK ((salary <> 0) AND (salary < 100000)); - -ALTER POLICY "test_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy - RENAME TO "test_insert_rls_policy_update_name_$%{}[]()&*^!@""'`\/#"; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_policy.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_policy.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_policy.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_policy_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/alter_policy_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_policy_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_select_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_select_policy.sql index dff804c8c..93b0a3fe2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_select_policy.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_select_policy.sql @@ -4,6 +4,7 @@ CREATE POLICY "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS PERMISSIVE FOR SELECT TO public - USING ((name = ("current_user"())::text)); + USING ((name = (CURRENT_USER)::text)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_all_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_all_policy.sql index 7cc807f7b..bdeb6b0f3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_all_policy.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_all_policy.sql @@ -4,6 +4,7 @@ CREATE POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR ALL TO public USING (true) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_insert_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_insert_policy.sql index dd95496d6..6c3dba682 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_insert_policy.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_simple_insert_policy.sql @@ -4,6 +4,7 @@ CREATE POLICY "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS PERMISSIVE FOR INSERT TO public - WITH CHECK ((("current_user"())::text = name)); + WITH CHECK (((CURRENT_USER)::text = name)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_update_policy_with_check_and_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_update_policy_with_check_and_using.sql index fc26c4fee..d9e1b39a5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_update_policy_with_check_and_using.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/alter_update_policy_with_check_and_using.sql @@ -4,7 +4,8 @@ CREATE POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR UPDATE TO public - USING ((("current_user"())::text = name)) + USING (((CURRENT_USER)::text = name)) WITH CHECK ((emp_id <> 0)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_all_event_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_all_event_policy.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_all_event_policy.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_all_event_policy.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using.sql index 874bf4bba..82e3f6c65 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using.sql @@ -4,6 +4,7 @@ CREATE POLICY "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR DELETE TO public - USING ((("current_user"())::text = name)); + USING (((CURRENT_USER)::text = name)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using_msql.sql index 1bf68d73c..fbacba3b6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_delete_policy_with_using_msql.sql @@ -1,5 +1,6 @@ CREATE POLICY "test_delete_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR DELETE TO public USING (current_user = name); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_insert_policy_with_check.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_insert_policy_with_check.sql deleted file mode 100644 index ff51b77e7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_insert_policy_with_check.sql +++ /dev/null @@ -1,9 +0,0 @@ --- POLICY: test_insert_rls_policy_$%{}[]()&*^!@"'`\/# - --- DROP POLICY "test_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy; - -CREATE POLICY "test_insert_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - FOR INSERT - TO public - WITH CHECK (((salary <> 0) AND (salary > 0))); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_insert_policy_with_check_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_insert_policy_with_check_msql.sql deleted file mode 100644 index d92bbac2f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_insert_policy_with_check_msql.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE POLICY "test_insert_rls_policy_$%{}[]()&*^!@""'`\/#" - ON public.test_rls_policy - FOR INSERT - TO public - WITH CHECK (salary != 0 and salary > 0); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_public_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_public_policy.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/10_plus/create_public_policy.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_public_policy.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy.sql index 59a715e5b..0dcf0ee86 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy.sql @@ -4,5 +4,6 @@ CREATE POLICY "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS PERMISSIVE FOR SELECT TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy_msql.sql index 7829ec2cf..a76d0818c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_select_policy_msql.sql @@ -1,4 +1,5 @@ CREATE POLICY "test_select_policy_rls_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS PERMISSIVE FOR SELECT TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy.sql index de2e37992..06e9ed7a5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy.sql @@ -4,5 +4,6 @@ CREATE POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR ALL TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy_msql.sql index b2f11a390..e0d2f6d7e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_all_policy_msql.sql @@ -1,4 +1,5 @@ CREATE POLICY "test_all_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR ALL TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy.sql index 07c2390fb..746062fda 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy.sql @@ -4,5 +4,6 @@ CREATE POLICY "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS PERMISSIVE FOR INSERT TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy_msql.sql index 6d3bb919c..ad1986a82 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_simple_insert_policy_msql.sql @@ -1,4 +1,5 @@ CREATE POLICY "test_simple_insert_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS PERMISSIVE FOR INSERT TO public; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using.sql index 65afeeeb7..d39be28bf 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using.sql @@ -4,6 +4,7 @@ CREATE POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR UPDATE TO public USING (true) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using_msql.sql index 0070865fa..02fca09a0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/create_update_policy_with_check_and_using_msql.sql @@ -1,5 +1,6 @@ CREATE POLICY "test_update_rls_policy_$%{}[]()&*^!@""'`\/#" ON public.test_rls_policy + AS RESTRICTIVE FOR UPDATE TO public USING (true) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/test.json index b7162b0a8..fff033ad2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/tests/default/test.json @@ -38,7 +38,8 @@ "name": "test_select_policy_rls_$%{}[]()&*^!@\"'`\\/#", "event": "SELECT", "policyowner": "public", - "schema": "public" + "schema": "public", + "type": "PERMISSIVE" }, "expected_sql_file": "create_select_policy.sql", "expected_msql_file": "create_select_policy_msql.sql" @@ -106,7 +107,7 @@ }, { "type": "create", - "name": "Create update event RLS policy with check and using clause", + "name": "Create update event restrictive RLS policy with check and using clause", "endpoint": "NODE-row_security_policy.obj", "sql_endpoint": "NODE-row_security_policy.sql_id", "msql_endpoint": "NODE-row_security_policy.msql", @@ -116,7 +117,7 @@ "event": "UPDATE", "using": "true", "withcheck": "name != null", - "type": "PERMISSIVE", + "type": "RESTRICTIVE", "schema": "public" }, "expected_sql_file": "create_update_policy_with_check_and_using.sql", @@ -124,7 +125,7 @@ }, { "type": "alter", - "name": "Alter update event RLS policy with check and using clause", + "name": "Alter update event restrictive RLS policy with check and using clause", "endpoint": "NODE-row_security_policy.obj_id", "sql_endpoint": "NODE-row_security_policy.sql_id", "msql_endpoint": "NODE-row_security_policy.msql_id", @@ -146,7 +147,7 @@ }, { "type": "create", - "name": "Create delete event RLS policy with check", + "name": "Create delete event restrictive RLS policy with check", "endpoint": "NODE-row_security_policy.obj", "sql_endpoint": "NODE-row_security_policy.sql_id", "msql_endpoint": "NODE-row_security_policy.msql", @@ -156,7 +157,7 @@ "event": "DELETE", "using": "current_user = name", "withcheck": "", - "type": "PERMISSIVE", + "type": "RESTRICTIVE", "schema": "public" }, "expected_sql_file": "create_delete_policy_with_using.sql", @@ -164,7 +165,7 @@ }, { "type": "alter", - "name": "Alter delete event RLS policy by changing check clause", + "name": "Alter delete event restrictive RLS policy by changing check clause", "endpoint": "NODE-row_security_policy.obj_id", "sql_endpoint": "NODE-row_security_policy.sql_id", "msql_endpoint": "NODE-row_security_policy.msql_id", @@ -186,7 +187,7 @@ }, { "type": "create", - "name": "Create simple all event RLS policy", + "name": "Create simple all event restrictive RLS policy", "endpoint": "NODE-row_security_policy.obj", "sql_endpoint": "NODE-row_security_policy.sql_id", "msql_endpoint": "NODE-row_security_policy.msql", @@ -194,7 +195,7 @@ "name": "test_all_rls_policy_$%{}[]()&*^!@\"'`\\/#", "policyowner": "public", "event": "ALL", - "type": "PERMISSIVE", + "type": "RESTRICTIVE", "schema": "public" }, "expected_sql_file": "create_simple_all_policy.sql", @@ -202,7 +203,7 @@ }, { "type": "alter", - "name": "Alter simple all event RLS policy with using & check clause", + "name": "Alter simple all event restrictive RLS policy with using & check clause", "endpoint": "NODE-row_security_policy.obj_id", "sql_endpoint": "NODE-row_security_policy.sql_id", "msql_endpoint": "NODE-row_security_policy.msql_id", @@ -222,6 +223,53 @@ "data": { "name": "test_all_rls_policy_$%{}[]()&*^!@\"'`\\/#" } + }, + { + "type": "create", + "name": "Create RLS policy", + "endpoint": "NODE-row_security_policy.obj", + "sql_endpoint": "NODE-row_security_policy.sql_id", + "data": { + "name": "test", + "schema": "public" + }, + "expected_sql_file": "create_public_policy.sql" + }, + { + "type": "alter", + "name": "Alter policy name", + "endpoint": "NODE-row_security_policy.obj_id", + "sql_endpoint": "NODE-row_security_policy.sql_id", + "msql_endpoint": "NODE-row_security_policy.msql_id", + "data": { + "name": "policy_1" + }, + "expected_sql_file": "alter_policy.sql", + "expected_msql_file": "alter_policy_msql.sql" + }, + { + "type": "create", + "name": "Create RLS policy for event 'ALL'", + "endpoint": "NODE-row_security_policy.obj", + "sql_endpoint": "NODE-row_security_policy.sql_id", + "data": { + "name": "all_event_policy", + "event": "ALL", + "policyowner": "public", + "schema": "public", + "using": "true", + "withcheck": "true", + "type": "RESTRICTIVE" + }, + "expected_sql_file": "create_all_event_policy.sql" + }, + { + "type": "delete", + "name": "Drop policy", + "endpoint": "NODE-row_security_policy.delete_id", + "data": { + "name": "test_delete_policy_$%{}[]()&*^!@\"'`\\/#" + } } ] } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/create.sql deleted file mode 100644 index 1e095dbd1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/create.sql +++ /dev/null @@ -1,11 +0,0 @@ -{% if data %} -ALTER TABLE IF EXISTS {{ conn|qtIdent(data.schema, data.table) }} - ADD{% if data.name %} CONSTRAINT {{ conn|qtIdent(data.name) }}{% endif%} CHECK ({{ data.consrc }}){% if data.convalidated %} - - NOT VALID{% endif %}{% if data.connoinherit %} NO INHERIT{% endif %}; -{% endif %} -{% if data.comment %} - -COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_name.sql deleted file mode 100644 index 2bd1c2ebe..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_name.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT conname as name, - NOT convalidated as convalidated -FROM pg_catalog.pg_constraint ct -WHERE contype = 'c' -AND ct.oid = {{cid}}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_oid.sql deleted file mode 100644 index 1970d96b2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_oid.sql +++ /dev/null @@ -1,8 +0,0 @@ -SELECT - oid, conname as name, - NOT convalidated as convalidated -FROM - pg_catalog.pg_constraint -WHERE - conrelid = {{tid}}::oid - AND conname={{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_oid_with_transaction.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_oid_with_transaction.sql deleted file mode 100644 index 7fca1ae37..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/get_oid_with_transaction.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT ct.oid, - ct.conname as name, - NOT convalidated as convalidated -FROM pg_catalog.pg_constraint ct -WHERE contype='c' AND - conrelid = {{tid}}::oid LIMIT 1; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/nodes.sql deleted file mode 100644 index c859975e9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/nodes.sql +++ /dev/null @@ -1,8 +0,0 @@ -SELECT c.oid, conname as name, - NOT convalidated as convalidated, conislocal - FROM pg_catalog.pg_constraint c -WHERE contype = 'c' - AND conrelid = {{ tid }}::oid -{% if cid %} - AND c.oid = {{ cid }}::oid -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/properties.sql deleted file mode 100644 index 5673b1312..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,14 +0,0 @@ -SELECT c.oid, conname as name, relname, nspname, description as comment, - pg_catalog.pg_get_expr(conbin, conrelid, true) as consrc, - connoinherit, NOT convalidated as convalidated, conislocal - FROM pg_catalog.pg_constraint c - JOIN pg_catalog.pg_class cl ON cl.oid=conrelid - JOIN pg_catalog.pg_namespace nl ON nl.oid=relnamespace -LEFT OUTER JOIN - pg_catalog.pg_description des ON (des.objoid=c.oid AND - des.classoid='pg_constraint'::regclass) -WHERE contype = 'c' - AND conrelid = {{ tid }}::oid -{% if cid %} - AND c.oid = {{ cid }}::oid -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql deleted file mode 100644 index 5a323c4d2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql +++ /dev/null @@ -1,13 +0,0 @@ -{% if data %} -{% if data.name != o_data.name %} -ALTER TABLE IF EXISTS {{ conn|qtIdent(o_data.nspname, data.table) }} - RENAME CONSTRAINT {{ conn|qtIdent(o_data.name) }} TO {{ conn|qtIdent(data.name) }};{% endif -%} -{% if 'convalidated' in data and o_data.convalidated != data.convalidated and not data.convalidated %} - -ALTER TABLE IF EXISTS {{ conn|qtIdent(o_data.nspname, data.table) }} - VALIDATE CONSTRAINT {{ conn|qtIdent(data.name) }};{% endif -%} -{% if data.comment is defined and data.comment != o_data.comment %} - -COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(o_data.nspname, data.table) }} - IS {{ data.comment|qtLiteral }};{% endif %} -{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/create.sql index 726a41ae6..1e095dbd1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/create.sql @@ -1,9 +1,11 @@ {% if data %} -ALTER TABLE {{ conn|qtIdent(data.schema, data.table) }} - ADD{% if data.name %} CONSTRAINT {{ conn|qtIdent(data.name) }}{% endif%} CHECK ({{ data.consrc }}); +ALTER TABLE IF EXISTS {{ conn|qtIdent(data.schema, data.table) }} + ADD{% if data.name %} CONSTRAINT {{ conn|qtIdent(data.name) }}{% endif%} CHECK ({{ data.consrc }}){% if data.convalidated %} + + NOT VALID{% endif %}{% if data.connoinherit %} NO INHERIT{% endif %}; {% endif %} {% if data.comment %} COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }} IS {{ data.comment|qtLiteral }}; -{% endif %} \ No newline at end of file +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_name.sql index 0f53bcfb7..2bd1c2ebe 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_name.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_name.sql @@ -1,4 +1,5 @@ -SELECT conname as name +SELECT conname as name, + NOT convalidated as convalidated FROM pg_catalog.pg_constraint ct WHERE contype = 'c' AND ct.oid = {{cid}}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid.sql index fe74be373..1970d96b2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid.sql @@ -1,5 +1,6 @@ SELECT - oid, conname as name + oid, conname as name, + NOT convalidated as convalidated FROM pg_catalog.pg_constraint WHERE diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid_with_transaction.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid_with_transaction.sql index e340a0c7f..7fca1ae37 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid_with_transaction.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/get_oid_with_transaction.sql @@ -1,5 +1,6 @@ SELECT ct.oid, - ct.conname as name + ct.conname as name, + NOT convalidated as convalidated FROM pg_catalog.pg_constraint ct WHERE contype='c' AND conrelid = {{tid}}::oid LIMIT 1; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/nodes.sql index 424706199..c859975e9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/nodes.sql @@ -1,4 +1,5 @@ -SELECT c.oid, conname as name, conislocal +SELECT c.oid, conname as name, + NOT convalidated as convalidated, conislocal FROM pg_catalog.pg_constraint c WHERE contype = 'c' AND conrelid = {{ tid }}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/properties.sql index 19bd6fba7..5673b1312 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/properties.sql @@ -1,5 +1,6 @@ -SELECT c.oid, conname as name, relname, nspname, description as comment , - pg_catalog.pg_get_expr(conbin, conrelid, true) as consrc, conislocal +SELECT c.oid, conname as name, relname, nspname, description as comment, + pg_catalog.pg_get_expr(conbin, conrelid, true) as consrc, + connoinherit, NOT convalidated as convalidated, conislocal FROM pg_catalog.pg_constraint c JOIN pg_catalog.pg_class cl ON cl.oid=conrelid JOIN pg_catalog.pg_namespace nl ON nl.oid=relnamespace diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/update.sql index 57d81c7fc..5a323c4d2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/update.sql @@ -1,4 +1,13 @@ +{% if data %} +{% if data.name != o_data.name %} +ALTER TABLE IF EXISTS {{ conn|qtIdent(o_data.nspname, data.table) }} + RENAME CONSTRAINT {{ conn|qtIdent(o_data.name) }} TO {{ conn|qtIdent(data.name) }};{% endif -%} +{% if 'convalidated' in data and o_data.convalidated != data.convalidated and not data.convalidated %} + +ALTER TABLE IF EXISTS {{ conn|qtIdent(o_data.nspname, data.table) }} + VALIDATE CONSTRAINT {{ conn|qtIdent(data.name) }};{% endif -%} {% if data.comment is defined and data.comment != o_data.comment %} -COMMENT ON CONSTRAINT {{ conn|qtIdent(o_data.name) }} ON {{ conn|qtIdent(o_data.nspname, o_data.relname) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} \ No newline at end of file + +COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(o_data.nspname, data.table) }} + IS {{ data.comment|qtLiteral }};{% endif %} +{% endif -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/validate.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/validate.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/validate.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/default/validate.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/create.sql deleted file mode 100644 index 03db79b45..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/create.sql +++ /dev/null @@ -1,60 +0,0 @@ -{% import 'columns/macros/security.macros' as SECLABEL %} -{% import 'columns/macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %} -{### Add column ###} -{% if data.name and data.cltype %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ADD COLUMN IF NOT EXISTS {{conn|qtIdent(data.name)}} {% if is_sql %}{{data.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, data.cltype, data.attlen, data.attprecision, data.hasSqrBracket) }}{% endif %}{% if data.collspcname %} - COLLATE {{data.collspcname}}{% endif %}{% if data.attnotnull %} - NOT NULL{% endif %}{% if data.defval is defined and data.defval is not none and data.defval != '' %} - DEFAULT {{data.defval}}{% endif %}{% if data.colconstype == 'i' %}{% if data.attidentity and data.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif data.attidentity and data.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %} -{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} ( {% endif %} -{% if data.seqcycle is defined and data.seqcycle %} -CYCLE {% endif %}{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %} -INCREMENT {{data.seqincrement|int}} {% endif %}{% if data.seqstart is defined and data.seqstart|int(-1) > -1%} -START {{data.seqstart|int}} {% endif %}{% if data.seqmin is defined and data.seqmin|int(-1) > -1%} -MINVALUE {{data.seqmin|int}} {% endif %}{% if data.seqmax is defined and data.seqmax|int(-1) > -1%} -MAXVALUE {{data.seqmax|int}} {% endif %}{% if data.seqcache is defined and data.seqcache|int(-1) > -1%} -CACHE {{data.seqcache|int}} {% endif %} -{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %}){% endif %} -{% endif %}{% endif %}; - -{### Add comments ###} -{% if data and data.description and data.description != None %} -COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}} - IS {{data.description|qtLiteral}}; - -{% endif %} -{### Add variables to column ###} -{% if data.attoptions %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - {{ VARIABLE.SET(conn, 'COLUMN', data.name, data.attoptions) }} - -{% endif %} -{### Alter column statistics value ###} -{% if data.attstattarget is defined and data.attstattarget > -1 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {{conn|qtTypeIdent(data.name)}} SET STATISTICS {{data.attstattarget}}; - -{% endif %} -{### Alter column storage value ###} -{% if data.attstorage is defined and data.attstorage != data.defaultstorage %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {{conn|qtTypeIdent(data.name)}} SET STORAGE {%if data.attstorage == 'p' %} -PLAIN{% elif data.attstorage == 'm'%}MAIN{% elif data.attstorage == 'e'%} -EXTERNAL{% elif data.attstorage == 'x'%}EXTENDED{% endif %}; - -{% endif %} -{### ACL ###} -{% if data.attacl %} -{% for priv in data.attacl %} -{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{### Security Lables ###} -{% if data.seclabels %} -{% for r in data.seclabels %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/properties.sql deleted file mode 100644 index 3a28b5eaf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/properties.sql +++ /dev/null @@ -1,41 +0,0 @@ -SELECT DISTINCT ON (att.attnum) att.attname as name, att.atttypid, att.attlen, att.attnum, att.attndims, - att.atttypmod, att.attacl, att.attnotnull, att.attoptions, att.attstattarget, - att.attstorage, att.attidentity, - pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, - pg_catalog.format_type(ty.oid,NULL) AS typname, - pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname, - pg_catalog.format_type(ty.oid,att.atttypmod) AS cltype, - CASE WHEN ty.typelem > 0 THEN ty.typelem ELSE ty.oid END as elemoid, - (SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = ty.typnamespace) as typnspname, - ty.typstorage AS defaultstorage, - description, pi.indkey, - (SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup, - CASE WHEN length(coll.collname::text) > 0 AND length(nspc.nspname::text) > 0 THEN - pg_catalog.concat(pg_catalog.quote_ident(nspc.nspname),'.',pg_catalog.quote_ident(coll.collname)) - ELSE '' END AS collspcname, - EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels, - (CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column, - (CASE WHEN (att.attidentity in ('a', 'd')) THEN 'i' ELSE 'n' END) AS colconstype, tab.relname as relname, - (CASE WHEN tab.relkind = 'v' THEN true ELSE false END) AS is_view_only, - seq.* -FROM pg_catalog.pg_attribute att - JOIN pg_catalog.pg_type ty ON ty.oid=atttypid - LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN (pg_catalog.pg_depend dep JOIN pg_catalog.pg_class cs ON dep.classid='pg_class'::regclass AND dep.objid=cs.oid AND cs.relkind='S') ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum - LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary - LEFT OUTER JOIN pg_catalog.pg_collation coll ON att.attcollation=coll.oid - LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid - LEFT OUTER JOIN pg_catalog.pg_sequence seq ON cs.oid=seq.seqrelid - LEFT OUTER JOIN pg_catalog.pg_class tab on tab.oid = att.attrelid -WHERE att.attrelid = {{tid}}::oid -{% if clid %} - AND att.attnum = {{clid}}::int -{% endif %} -{### To show system objects ###} -{% if not show_sys_objects %} - AND att.attnum > 0 -{% endif %} - AND att.attisdropped IS FALSE - ORDER BY att.attnum; 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 deleted file mode 100644 index dc9c6d9ce..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/10_plus/update.sql +++ /dev/null @@ -1,209 +0,0 @@ -{% import 'columns/macros/security.macros' as SECLABEL %} -{% import 'columns/macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %} -{### Rename column name ###} -{% if data.name and data.name != o_data.name %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - RENAME {{conn|qtIdent(o_data.name)}} TO {{conn|qtIdent(data.name)}}; - -{% endif %} -{### Alter column type and collation ###} -{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) or (data.collspcname and data.collspcname != o_data.collspcname) or data.col_type_conversion is defined %} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} --- WARNING: --- The SQL statement below would normally be used to alter the datatype for the {{o_data.name}} column, however, --- the current datatype cannot be cast to the target datatype so this conversion cannot be made automatically. - -{% endif %} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %}ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname %} - COLLATE {{data.collspcname}}{% elif o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %}; -{% endif %} -{### Alter column default value ###} -{% if is_view_only and data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} -ALTER VIEW {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}}; - -{% elif data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}}; - -{% endif %} -{### Drop column default value ###} -{% if data.defval is defined and (data.defval == '' or data.defval is none) and data.defval != o_data.defval %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP DEFAULT; - -{% endif %} -{### Alter column not null value ###} -{% if 'attnotnull' in data and data.attnotnull != o_data.attnotnull %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} {% if data.attnotnull %}SET{% else %}DROP{% endif %} NOT NULL; - -{% endif %} -{% if data.seqincrement or (data.seqcycle or (data.seqcycle == False and data.seqcycle != o_data.seqcycle)) or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} -{% set attidentity_params = true %}{% else %} -{% set attidentity_params = false %}{% endif %} -{### Alter column - add identity ###} -{% if data.colconstype == 'i' and 'attidentity' in data and o_data.attidentity == '' and data.attidentity != o_data.attidentity %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} {% if data.attidentity == 'a' %}ADD GENERATED ALWAYS AS IDENTITY{% else%}ADD GENERATED BY DEFAULT AS IDENTITY{% endif %} -{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} ( {% endif %} -{% if data.seqcycle is defined and data.seqcycle %} -CYCLE {% endif %}{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %} -INCREMENT {{data.seqincrement|int}} {% endif %}{% if data.seqstart is defined and data.seqstart|int(-1) > -1%} -START {{data.seqstart|int}} {% endif %}{% if data.seqmin is defined and data.seqmin|int(-1) > -1%} -MINVALUE {{data.seqmin|int}} {% endif %}{% if data.seqmax is defined and data.seqmax|int(-1) > -1%} -MAXVALUE {{data.seqmax|int}} {% endif %}{% if data.seqcache is defined and data.seqcache|int(-1) > -1%} -CACHE {{data.seqcache|int}} {% endif %} -{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %}){% endif %}; - -{### Alter column - change identity - sequence options ###} -{% elif 'attidentity' in data or attidentity_params %} -{% if 'attidentity' in data and data.attidentity != '' and o_data.attidentity != '' and data.attidentity != o_data.attidentity %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET GENERATED {% if data.attidentity == 'a' %}ALWAYS{% else%}BY DEFAULT{% endif %}{% if attidentity_params == false %};{% endif %} -{% elif attidentity_params %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %}{% endif %} -{% if data.seqcycle %} SET CYCLE{% elif (data.seqcycle == False and o_data.seqcycle and data.seqcycle != o_data.seqcycle) %} SET NO CYCLE{% endif %} -{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %} SET INCREMENT {{data.seqincrement|int}}{% endif %} -{% if data.seqstart is defined and data.seqstart|int(-1) > -1%} RESTART SET START {{data.seqstart|int}}{% endif %} -{% if data.seqmin is defined and data.seqmin|int(-1) > -1%} SET MINVALUE {{data.seqmin|int}}{% endif %} -{% if data.seqmax is defined and data.seqmax|int(-1) > -1%} SET MAXVALUE {{data.seqmax|int}}{% endif %} -{% if data.seqcache is defined and data.seqcache|int(-1) > -1%} SET CACHE {{data.seqcache|int}}{% endif %}{% if attidentity_params == true %};{% endif %} - - -{% endif %} -{### Alter column - drop identity when column constraint is changed###} -{% if 'colconstype' in data and data.colconstype == 'n' and 'colconstype' in o_data and o_data.colconstype == 'i' %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP IDENTITY; - -{% endif %} -{### Alter column statistics value ###} -{% if data.attstattarget is defined and data.attstattarget != o_data.attstattarget %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET STATISTICS {{data.attstattarget}}; - -{% endif %} -{### Alter column storage value ###} -{% if data.attstorage is defined and data.attstorage != o_data.attstorage %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET STORAGE {%if data.attstorage == 'p' %} -PLAIN{% elif data.attstorage == 'm'%}MAIN{% elif data.attstorage == 'e'%} -EXTERNAL{% elif data.attstorage == 'x'%}EXTENDED{% endif %}; - -{% endif %} -{% if data.description is defined and data.description != None %} -{% if data.name %} -COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}} -{% else %} -COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, o_data.name)}} -{% endif %} - IS {{data.description|qtLiteral}}; - -{% endif %} -{### Update column variables ###} -{% if 'attoptions' in data and data.attoptions != None and data.attoptions|length > 0 %} -{% set variables = data.attoptions %} -{% if 'deleted' in variables and variables.deleted|length > 0 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -{% if data.name %} - {{ VARIABLE.UNSET(conn, 'COLUMN', data.name, variables.deleted) }} -{% else %} - {{ VARIABLE.UNSET(conn, 'COLUMN', o_data.name, variables.deleted) }} -{% endif %} -{% endif %} -{% if 'added' in variables and variables.added|length > 0 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -{% if data.name %} - {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.added) }} -{% else %} - {{ VARIABLE.SET(conn, 'COLUMN', o_data.name, variables.added) }} -{% endif %} -{% endif %} -{% if 'changed' in variables and variables.changed|length > 0 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -{% if data.name %} - {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.changed) }} -{% else %} - {{ VARIABLE.SET(conn, 'COLUMN', o_data.name, variables.changed) }} -{% endif %} -{% endif %} -{% endif %} -{### Update column privileges ###} -{# Change the privileges #} -{% if data.attacl %} -{% if 'deleted' in data.attacl %} -{% for priv in data.attacl.deleted %} -{% if data.name %} -{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} -{% else %} -{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} -{% endif %} -{% endfor %} -{% 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 %} -{% endif %} -{% if 'added' in data.attacl %} -{% for priv in data.attacl.added %} -{% if data.name %} -{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} -{% else %} -{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} -{### Uppdate tablespace securitylabel ###} -{# The SQL generated below will change Security Label #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{% if data.name %} -{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, data.name, r.provider) }} -{% else %} -{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, o_data.name, r.provider) }} -{% endif %} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{% if data.name %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }} -{% else %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, o_data.name, r.provider, r.label) }} -{% endif %} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{% if data.name %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }} -{% else %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, o_data.name, r.provider, r.label) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/acl.sql deleted file mode 100644 index fa9c3c5ef..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/acl.sql +++ /dev/null @@ -1,39 +0,0 @@ -SELECT 'attacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type order by privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT attacl - FROM pg_catalog.pg_attribute att - WHERE att.attrelid = {{tid}}::oid - AND att.attnum = {{clid}}::int - ) acl, - (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable - AS is_grantable, (d).privilege_type AS privilege_type FROM (SELECT - pg_catalog.aclexplode(attacl) as d FROM pg_catalog.pg_attribute att - WHERE att.attrelid = {{tid}}::oid - AND att.attnum = {{clid}}::int) a) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname -ORDER BY grantee diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/properties.sql deleted file mode 100644 index 172eaaf5d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.1_plus/properties.sql +++ /dev/null @@ -1,46 +0,0 @@ -SELECT DISTINCT ON (att.attnum) att.attname as name, att.*, def.*, pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, - CASE WHEN att.attndims > 0 THEN 1 ELSE 0 END AS isarray, - pg_catalog.format_type(ty.oid,NULL) AS typname, - pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname, - CASE WHEN ty.typelem > 0 THEN ty.typelem ELSE ty.oid END as elemoid, - tn.nspname as typnspname, et.typname as elemtypname, - ty.typstorage AS defaultstorage, cl.relname, na.nspname, - pg_catalog.concat(pg_catalog.quote_ident(na.nspname) ,'.', pg_catalog.quote_ident(cl.relname)) AS parent_tbl, - att.attstattarget, description, cs.relname AS sername, - ns.nspname AS serschema, - (SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup, - indkey, coll.collname, nspc.nspname as collnspname , attoptions, - -- Start pgAdmin4, added to save time on client side parsing - CASE WHEN length(coll.collname::text) > 0 AND length(nspc.nspname::text) > 0 THEN - pg_catalog.concat(pg_catalog.quote_ident(nspc.nspname),'.',pg_catalog.quote_ident(coll.collname)) - ELSE '' END AS collspcname, - CASE WHEN pg_catalog.strpos(pg_catalog.format_type(ty.oid,att.atttypmod), '.') > 0 THEN - pg_catalog.split_part(pg_catalog.format_type(ty.oid,att.atttypmod), '.', 2) - ELSE pg_catalog.format_type(ty.oid,att.atttypmod) END AS cltype, - -- End pgAdmin4 - EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels, - (CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column -FROM pg_catalog.pg_attribute att - JOIN pg_catalog.pg_type ty ON ty.oid=atttypid - JOIN pg_catalog.pg_namespace tn ON tn.oid=ty.typnamespace - JOIN pg_catalog.pg_class cl ON cl.oid=att.attrelid - JOIN pg_catalog.pg_namespace na ON na.oid=cl.relnamespace - LEFT OUTER JOIN pg_catalog.pg_type et ON et.oid=ty.typelem - LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN (pg_catalog.pg_depend JOIN pg_catalog.pg_class cs ON classid='pg_class'::regclass AND objid=cs.oid AND cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum - LEFT OUTER JOIN pg_catalog.pg_namespace ns ON ns.oid=cs.relnamespace - LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary - LEFT OUTER JOIN pg_catalog.pg_collation coll ON att.attcollation=coll.oid - LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid -WHERE att.attrelid = {{tid}}::oid -{% if clid %} - AND att.attnum = {{clid}}::int -{% endif %} -{### To show system objects ###} -{% if not show_sys_objects %} - AND att.attnum > 0 -{% endif %} - AND att.attisdropped IS FALSE - ORDER BY att.attnum diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/get_collations.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/get_collations.sql deleted file mode 100644 index b6b436d69..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/get_collations.sql +++ /dev/null @@ -1,7 +0,0 @@ -SELECT --nspname, collname, - CASE WHEN length(nspname::text) > 0 AND length(collname::text) > 0 THEN - pg_catalog.concat(pg_catalog.quote_ident(nspname), '.', pg_catalog.quote_ident(collname)) - ELSE '' END AS collation -FROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n - WHERE c.collnamespace=n.oid - ORDER BY nspname, collname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/nodes.sql deleted file mode 100644 index 128eb6d63..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/nodes.sql +++ /dev/null @@ -1,27 +0,0 @@ -SELECT DISTINCT att.attname as name, att.attnum as OID, pg_catalog.format_type(ty.oid,NULL) AS datatype, -att.attnotnull as not_null, att.atthasdef as has_default_val -FROM pg_catalog.pg_attribute att - JOIN pg_catalog.pg_type ty ON ty.oid=atttypid - JOIN pg_catalog.pg_namespace tn ON tn.oid=ty.typnamespace - JOIN pg_catalog.pg_class cl ON cl.oid=att.attrelid - JOIN pg_catalog.pg_namespace na ON na.oid=cl.relnamespace - LEFT OUTER JOIN pg_catalog.pg_type et ON et.oid=ty.typelem - LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum - LEFT OUTER JOIN (pg_catalog.pg_depend JOIN pg_catalog.pg_class cs ON classid='pg_class'::regclass AND objid=cs.oid AND cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum - LEFT OUTER JOIN pg_catalog.pg_namespace ns ON ns.oid=cs.relnamespace - LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary -WHERE - att.attrelid = {{ tid|qtLiteral }}::oid -{% if clid %} - AND att.attnum = {{ clid|qtLiteral }} -{% endif %} -{### To show system objects ###} -{% if not show_sys_objects and not has_oids %} - AND att.attnum > 0 -{% endif %} -{### To show oids in view data ###} -{% if has_oids %} - AND (att.attnum > 0 OR (att.attname = 'oid' AND att.attnum < 0)) -{% endif %} - AND att.attisdropped IS FALSE -ORDER BY att.attnum diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/properties.sql deleted file mode 100644 index c8642aa1e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,37 +0,0 @@ -SELECT DISTINCT ON (att.attnum) att.attname as name, att.atttypid, att.attlen, att.attnum, att.attndims, - att.atttypmod, att.attacl, att.attnotnull, att.attoptions, att.attstattarget, - att.attstorage, pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, - pg_catalog.format_type(ty.oid,NULL) AS typname, - pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname, - pg_catalog.format_type(ty.oid,att.atttypmod) AS cltype, - CASE WHEN ty.typelem > 0 THEN ty.typelem ELSE ty.oid END as elemoid, - (SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = ty.typnamespace) as typnspname, - ty.typstorage AS defaultstorage, - description, pi.indkey, - (SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup, - CASE WHEN length(coll.collname::text) > 0 AND length(nspc.nspname::text) > 0 THEN - pg_catalog.concat(pg_catalog.quote_ident(nspc.nspname),'.',pg_catalog.quote_ident(coll.collname)) - ELSE '' END AS collspcname, - EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels, - (CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column, tab.relname as relname, - (CASE WHEN tab.relkind = 'v' THEN true ELSE false END) AS is_view_only -FROM pg_catalog.pg_attribute att - JOIN pg_catalog.pg_type ty ON ty.oid=atttypid - LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN (pg_depend dep JOIN pg_catalog.pg_class cs ON dep.classid='pg_class'::regclass AND dep.objid=cs.oid AND cs.relkind='S') ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum - LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary - LEFT OUTER JOIN pg_catalog.pg_collation coll ON att.attcollation=coll.oid - LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid - LEFT OUTER JOIN pg_catalog.pg_class tab on tab.oid = att.attrelid -WHERE att.attrelid = {{tid}}::oid -{% if clid %} - AND att.attnum = {{clid}}::int -{% endif %} -{### To show system objects ###} -{% if not show_sys_objects %} - AND att.attnum > 0 -{% endif %} - AND att.attisdropped IS FALSE - ORDER BY att.attnum; 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 deleted file mode 100644 index 7443eeffd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/9.2_plus/update.sql +++ /dev/null @@ -1,169 +0,0 @@ -{% import 'columns/macros/security.macros' as SECLABEL %} -{% import 'columns/macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %} -{### Rename column name ###} -{% if data.name and data.name != o_data.name %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - RENAME {{conn|qtIdent(o_data.name)}} TO {{conn|qtIdent(data.name)}}; - -{% endif %} -{### Alter column type and collation ###} -{% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) or (data.collspcname and data.collspcname != o_data.collspcname) or data.col_type_conversion is defined %} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} --- WARNING: --- The SQL statement below would normally be used to alter the datatype for the {{o_data.name}} column, however, --- the current datatype cannot be cast to the target datatype so this conversion cannot be made automatically. - -{% endif %} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %}ALTER TABLE {{conn|qtIdent(data.schema, data.table)}} -{% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- {% endif %} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} TYPE {{ GET_TYPE.UPDATE_TYPE_SQL(conn, data, o_data) }}{% if data.collspcname and data.collspcname != o_data.collspcname %} - COLLATE {{data.collspcname}}{% elif o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %}; -{% endif %} -{### Alter column default value ###} -{% if is_view_only and data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} -ALTER VIEW IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}}; - -{% elif data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}}; - -{% endif %} -{### Drop column default value ###} -{% if data.defval is defined and (data.defval == '' or data.defval is none) and data.defval != o_data.defval %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP DEFAULT; - -{% endif %} -{### Alter column not null value ###} -{% if 'attnotnull' in data and data.attnotnull != o_data.attnotnull %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} {% if data.attnotnull %}SET{% else %}DROP{% endif %} NOT NULL; - -{% endif %} -{### Alter column statistics value ###} -{% if data.attstattarget is defined and data.attstattarget != o_data.attstattarget %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET STATISTICS {{data.attstattarget}}; - -{% endif %} -{### Alter column storage value ###} -{% if data.attstorage is defined and data.attstorage != o_data.attstorage %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} - ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET STORAGE {%if data.attstorage == 'p' %} -PLAIN{% elif data.attstorage == 'm'%}MAIN{% elif data.attstorage == 'e'%} -EXTERNAL{% elif data.attstorage == 'x'%}EXTENDED{% endif %}; - -{% endif %} -{% if data.description is defined and data.description != None %} -{% if data.name %} -COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}} -{% else %} -COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, o_data.name)}} -{% endif %} - IS {{data.description|qtLiteral}}; - -{% endif %} -{### Update column variables ###} -{% if 'attoptions' in data and data.attoptions != None and data.attoptions|length > 0 %} -{% set variables = data.attoptions %} -{% if 'deleted' in variables and variables.deleted|length > 0 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -{% if data.name %} - {{ VARIABLE.UNSET(conn, 'COLUMN', data.name, variables.deleted) }} -{% else %} - {{ VARIABLE.UNSET(conn, 'COLUMN', o_data.name, variables.deleted) }} -{% endif %} -{% endif %} -{% if 'added' in variables and variables.added|length > 0 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -{% if data.name %} - {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.added) }} -{% else %} - {{ VARIABLE.SET(conn, 'COLUMN', o_data.name, variables.added) }} -{% endif %} -{% endif %} -{% if 'changed' in variables and variables.changed|length > 0 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} -{% if data.name %} - {{ VARIABLE.SET(conn, 'COLUMN', data.name, variables.changed) }} -{% else %} - {{ VARIABLE.SET(conn, 'COLUMN', o_data.name, variables.changed) }} -{% endif %} -{% endif %} -{% endif %} -{### Update column privileges ###} -{# Change the privileges #} -{% if data.attacl %} -{% if 'deleted' in data.attacl %} -{% for priv in data.attacl.deleted %} -{% if data.name %} -{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, data.name, priv.grantee) }} -{% else %} -{{ PRIVILEGE.RESETALL(conn, data.schema, data.table, o_data.name, priv.grantee) }} -{% endif %} -{% endfor %} -{% 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 %} -{% endif %} -{% if 'added' in data.attacl %} -{% for priv in data.attacl.added %} -{% if data.name %} -{{ PRIVILEGE.APPLY(conn, data.schema, data.table, data.name, priv.grantee, priv.without_grant, priv.with_grant) }} -{% else %} -{{ PRIVILEGE.APPLY(conn, data.schema, data.table, o_data.name, priv.grantee, priv.without_grant, priv.with_grant) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} -{### Uppdate tablespace securitylabel ###} -{# The SQL generated below will change Security Label #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{% if data.name %} -{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, data.name, r.provider) }} -{% else %} -{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, o_data.name, r.provider) }} -{% endif %} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{% if data.name %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }} -{% else %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, o_data.name, r.provider, r.label) }} -{% endif %} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{% if data.name %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }} -{% else %} -{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, o_data.name, r.provider, r.label) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/acl.sql index 1ee5e63f8..fa9c3c5ef 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/acl.sql @@ -1 +1,39 @@ -SELECT NULL LIMIT 0 \ No newline at end of file +SELECT 'attacl' as deftype, + COALESCE(gt.rolname, 'PUBLIC') grantee, + g.rolname grantor, + pg_catalog.array_agg(privilege_type order by privilege_type) as privileges, + pg_catalog.array_agg(is_grantable) as grantable +FROM + (SELECT + d.grantee, d.grantor, d.is_grantable, + CASE d.privilege_type + WHEN 'CONNECT' THEN 'c' + WHEN 'CREATE' THEN 'C' + WHEN 'DELETE' THEN 'd' + WHEN 'EXECUTE' THEN 'X' + WHEN 'INSERT' THEN 'a' + WHEN 'REFERENCES' THEN 'x' + WHEN 'SELECT' THEN 'r' + WHEN 'TEMPORARY' THEN 'T' + WHEN 'TRIGGER' THEN 't' + WHEN 'TRUNCATE' THEN 'D' + WHEN 'UPDATE' THEN 'w' + WHEN 'USAGE' THEN 'U' + ELSE 'UNKNOWN' + END AS privilege_type + FROM + (SELECT attacl + FROM pg_catalog.pg_attribute att + WHERE att.attrelid = {{tid}}::oid + AND att.attnum = {{clid}}::int + ) acl, + (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable + AS is_grantable, (d).privilege_type AS privilege_type FROM (SELECT + pg_catalog.aclexplode(attacl) as d FROM pg_catalog.pg_attribute att + WHERE att.attrelid = {{tid}}::oid + AND att.attnum = {{clid}}::int) a) d + ) d + LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) + LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) +GROUP BY g.rolname, gt.rolname +ORDER BY grantee diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/create.sql index a0aa19db3..03db79b45 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/create.sql @@ -8,9 +8,18 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} ADD COLUMN IF NOT EXISTS {{conn|qtIdent(data.name)}} {% if is_sql %}{{data.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, data.cltype, data.attlen, data.attprecision, data.hasSqrBracket) }}{% endif %}{% if data.collspcname %} COLLATE {{data.collspcname}}{% endif %}{% if data.attnotnull %} NOT NULL{% endif %}{% if data.defval is defined and data.defval is not none and data.defval != '' %} - DEFAULT {{data.defval}}{% endif %}; + DEFAULT {{data.defval}}{% endif %}{% if data.colconstype == 'i' %}{% if data.attidentity and data.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif data.attidentity and data.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %} +{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} ( {% endif %} +{% if data.seqcycle is defined and data.seqcycle %} +CYCLE {% endif %}{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %} +INCREMENT {{data.seqincrement|int}} {% endif %}{% if data.seqstart is defined and data.seqstart|int(-1) > -1%} +START {{data.seqstart|int}} {% endif %}{% if data.seqmin is defined and data.seqmin|int(-1) > -1%} +MINVALUE {{data.seqmin|int}} {% endif %}{% if data.seqmax is defined and data.seqmax|int(-1) > -1%} +MAXVALUE {{data.seqmax|int}} {% endif %}{% if data.seqcache is defined and data.seqcache|int(-1) > -1%} +CACHE {{data.seqcache|int}} {% endif %} +{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %}){% endif %} +{% endif %}{% endif %}; -{% endif %} {### Add comments ###} {% if data and data.description and data.description != None %} COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, data.name)}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/properties.sql index cf0d7ab76..5ac870ab7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/columns/sql/default/properties.sql @@ -1,30 +1,34 @@ -SELECT att.attname as name, att.*, def.*, pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, - CASE WHEN att.attndims > 0 THEN 1 ELSE 0 END AS isarray, - pg_catalog.format_type(ty.oid,NULL) AS typname, +SELECT att.attname as name, att.atttypid, att.attlen, att.attnum, att.attndims, + att.atttypmod, att.attacl, att.attnotnull, att.attoptions, att.attstattarget, + att.attstorage, att.attidentity, + pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, + pg_catalog.format_type(ty.oid,NULL) AS typname, pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname, + pg_catalog.format_type(ty.oid,att.atttypmod) AS cltype, CASE WHEN ty.typelem > 0 THEN ty.typelem ELSE ty.oid END as elemoid, - tn.nspname as typnspname, et.typname as elemtypname, - ty.typstorage AS defaultstorage, cl.relname, na.nspname, - pg_catalog.quote_ident(na.nspname) || '.' || pg_catalog.quote_ident(cl.relname) AS parent_tbl, - att.attstattarget, description, cs.relname AS sername, - ns.nspname AS serschema, + (SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = ty.typnamespace) as typnspname, + ty.typstorage AS defaultstorage, + description, pi.indkey, (SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup, - indkey, NULL as attoptions, - pg_catalog.format_type(ty.oid,att.atttypmod) AS cltype, + CASE WHEN length(coll.collname::text) > 0 AND length(nspc.nspname::text) > 0 THEN + pg_catalog.concat(pg_catalog.quote_ident(nspc.nspname),'.',pg_catalog.quote_ident(coll.collname)) + ELSE '' END AS collspcname, EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk, - NULL AS seclabels, - (CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column + (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels, + (CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column, + (CASE WHEN (att.attidentity in ('a', 'd')) THEN 'i' ELSE 'n' END) AS colconstype, tab.relname as relname, + (CASE WHEN tab.relkind = 'v' THEN true ELSE false END) AS is_view_only, + seq.* FROM pg_catalog.pg_attribute att JOIN pg_catalog.pg_type ty ON ty.oid=atttypid - JOIN pg_catalog.pg_namespace tn ON tn.oid=ty.typnamespace - JOIN pg_catalog.pg_class cl ON cl.oid=att.attrelid - JOIN pg_catalog.pg_namespace na ON na.oid=cl.relnamespace - LEFT OUTER JOIN pg_catalog.pg_type et ON et.oid=ty.typelem LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN (pg_catalog.pg_depend JOIN pg_catalog.pg_class cs ON classid='pg_class'::regclass AND objid=cs.oid AND cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum - LEFT OUTER JOIN pg_catalog.pg_namespace ns ON ns.oid=cs.relnamespace + LEFT OUTER JOIN (pg_catalog.pg_depend dep JOIN pg_catalog.pg_class cs ON dep.classid='pg_class'::regclass AND dep.objid=cs.oid AND cs.relkind='S') ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary + LEFT OUTER JOIN pg_catalog.pg_collation coll ON att.attcollation=coll.oid + LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid + LEFT OUTER JOIN pg_catalog.pg_sequence seq ON cs.oid=seq.seqrelid + LEFT OUTER JOIN pg_catalog.pg_class tab on tab.oid = att.attrelid WHERE att.attrelid = {{tid}}::oid {% if clid %} AND att.attnum = {{clid}}::int 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 6a0741ecb..dc9c6d9ce 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 @@ -12,7 +12,7 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} {% if (data.cltype and data.cltype != o_data.cltype) or (data.attlen is defined and data.attlen != o_data.attlen) or (data.attprecision is defined and data.attprecision != o_data.attprecision) or (data.collspcname and data.collspcname != o_data.collspcname) or data.col_type_conversion is defined %} {% if data.col_type_conversion is defined and data.col_type_conversion == False %} -- WARNING: --- The SQL statement below would normally be used to alter the datatype for the XXX column, however, +-- The SQL statement below would normally be used to alter the datatype for the {{o_data.name}} column, however, -- the current datatype cannot be cast to the target datatype so this conversion cannot be made automatically. {% endif %} @@ -21,13 +21,17 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} COLLATE {{data.collspcname}}{% elif o_data.collspcname %} COLLATE {{o_data.collspcname}}{% endif %}; {% endif %} {### Alter column default value ###} -{% if data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} +{% if is_view_only and data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} +ALTER VIEW {{conn|qtIdent(data.schema, data.table)}} + ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}}; + +{% elif data.defval is defined and data.defval is not none and data.defval != '' and data.defval != o_data.defval %} ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET DEFAULT {{data.defval}}; {% endif %} {### Drop column default value ###} -{% if data.defval is defined and data.defval == '' and data.defval != o_data.defval %} +{% if data.defval is defined and (data.defval == '' or data.defval is none) and data.defval != o_data.defval %} ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP DEFAULT; @@ -37,6 +41,46 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} {% if data.attnotnull %}SET{% else %}DROP{% endif %} NOT NULL; +{% endif %} +{% if data.seqincrement or (data.seqcycle or (data.seqcycle == False and data.seqcycle != o_data.seqcycle)) or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} +{% set attidentity_params = true %}{% else %} +{% set attidentity_params = false %}{% endif %} +{### Alter column - add identity ###} +{% if data.colconstype == 'i' and 'attidentity' in data and o_data.attidentity == '' and data.attidentity != o_data.attidentity %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} + ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} {% if data.attidentity == 'a' %}ADD GENERATED ALWAYS AS IDENTITY{% else%}ADD GENERATED BY DEFAULT AS IDENTITY{% endif %} +{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %} ( {% endif %} +{% if data.seqcycle is defined and data.seqcycle %} +CYCLE {% endif %}{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %} +INCREMENT {{data.seqincrement|int}} {% endif %}{% if data.seqstart is defined and data.seqstart|int(-1) > -1%} +START {{data.seqstart|int}} {% endif %}{% if data.seqmin is defined and data.seqmin|int(-1) > -1%} +MINVALUE {{data.seqmin|int}} {% endif %}{% if data.seqmax is defined and data.seqmax|int(-1) > -1%} +MAXVALUE {{data.seqmax|int}} {% endif %}{% if data.seqcache is defined and data.seqcache|int(-1) > -1%} +CACHE {{data.seqcache|int}} {% endif %} +{% if data.seqincrement or data.seqcycle or data.seqincrement or data.seqstart or data.seqmin or data.seqmax or data.seqcache %}){% endif %}; + +{### Alter column - change identity - sequence options ###} +{% elif 'attidentity' in data or attidentity_params %} +{% if 'attidentity' in data and data.attidentity != '' and o_data.attidentity != '' and data.attidentity != o_data.attidentity %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} + ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} SET GENERATED {% if data.attidentity == 'a' %}ALWAYS{% else%}BY DEFAULT{% endif %}{% if attidentity_params == false %};{% endif %} +{% elif attidentity_params %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} + ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %}{% endif %} +{% if data.seqcycle %} SET CYCLE{% elif (data.seqcycle == False and o_data.seqcycle and data.seqcycle != o_data.seqcycle) %} SET NO CYCLE{% endif %} +{% if data.seqincrement is defined and data.seqincrement|int(-1) > -1 %} SET INCREMENT {{data.seqincrement|int}}{% endif %} +{% if data.seqstart is defined and data.seqstart|int(-1) > -1%} RESTART SET START {{data.seqstart|int}}{% endif %} +{% if data.seqmin is defined and data.seqmin|int(-1) > -1%} SET MINVALUE {{data.seqmin|int}}{% endif %} +{% if data.seqmax is defined and data.seqmax|int(-1) > -1%} SET MAXVALUE {{data.seqmax|int}}{% endif %} +{% if data.seqcache is defined and data.seqcache|int(-1) > -1%} SET CACHE {{data.seqcache|int}}{% endif %}{% if attidentity_params == true %};{% endif %} + + +{% endif %} +{### Alter column - drop identity when column constraint is changed###} +{% if 'colconstype' in data and data.colconstype == 'n' and 'colconstype' in o_data and o_data.colconstype == 'i' %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} + ALTER COLUMN {% if data.name %}{{conn|qtTypeIdent(data.name)}}{% else %}{{conn|qtTypeIdent(o_data.name)}}{% endif %} DROP IDENTITY; + {% endif %} {### Alter column statistics value ###} {% if data.attstattarget is defined and data.attstattarget != o_data.attstattarget %} @@ -62,7 +106,7 @@ COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.table, o_data.name)}} {% endif %} {### Update column variables ###} -{% if 'attoptions' in data and data.attoptions|length > 0 %} +{% if 'attoptions' in data and data.attoptions != None and data.attoptions|length > 0 %} {% set variables = data.attoptions %} {% if 'deleted' in variables and variables.deleted|length > 0 %} ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} @@ -88,7 +132,6 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} {{ VARIABLE.SET(conn, 'COLUMN', o_data.name, variables.changed) }} {% endif %} {% endif %} - {% endif %} {### Update column privileges ###} {# Change the privileges #} @@ -163,5 +206,4 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.table)}} {% endif %} {% endfor %} {% endif %} - {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/get_oid_with_transaction.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/get_oid_with_transaction.sql deleted file mode 100644 index fd7ac3953..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/get_oid_with_transaction.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT ct.conindid AS oid, - ct.conname AS name, - NOT convalidated AS convalidated -FROM pg_catalog.pg_constraint ct -WHERE contype='x' AND - conrelid = {{tid}}::oid LIMIT 1; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/nodes.sql deleted file mode 100644 index 2c09229ce..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/nodes.sql +++ /dev/null @@ -1,10 +0,0 @@ -SELECT conindid as oid, - conname as name, - NOT convalidated as convalidated -FROM pg_catalog.pg_constraint ct -WHERE contype='x' AND - conrelid = {{tid}}::oid -{% if exid %} - AND conindid = {{exid}}::oid -{% endif %} -ORDER BY conname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/get_constraint_cols.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/get_constraint_cols.sql deleted file mode 100644 index 56f830362..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/get_constraint_cols.sql +++ /dev/null @@ -1,23 +0,0 @@ -{% for n in range(colcnt|int) %} -{% if loop.index != 1 %} -UNION -{% endif %} -SELECT - i.indoption[{{loop.index -1}}] AS options, - pg_catalog.pg_get_indexdef(i.indexrelid, {{loop.index}}, true) AS coldef, - op.oprname, - CASE WHEN (o.opcdefault = FALSE) THEN o.opcname ELSE null END AS opcname -, - coll.collname, - nspc.nspname as collnspname, - pg_catalog.format_type(ty.oid,NULL) AS datatype, - CASE WHEN pg_catalog.pg_get_indexdef(i.indexrelid, {{loop.index}}, true) = a.attname THEN FALSE ELSE TRUE END AS is_exp -FROM pg_catalog.pg_index i -JOIN pg_catalog.pg_attribute a ON (a.attrelid = i.indexrelid AND attnum = {{loop.index}}) -JOIN pg_catalog.pg_type ty ON ty.oid=a.atttypid -LEFT OUTER JOIN pg_catalog.pg_opclass o ON (o.oid = i.indclass[{{loop.index -1}}]) -LEFT OUTER JOIN pg_catalog.pg_constraint c ON (c.conindid = i.indexrelid) LEFT OUTER JOIN pg_catalog.pg_operator op ON (op.oid = c.conexclop[{{loop.index}}]) -LEFT OUTER JOIN pg_catalog.pg_collation coll ON a.attcollation=coll.oid -LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid -WHERE i.indexrelid = {{cid}}::oid -{% endfor %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/get_operator.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/get_operator.sql deleted file mode 100644 index eb0c72fd2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.2_plus/get_operator.sql +++ /dev/null @@ -1,36 +0,0 @@ -{% if type is not none %} -SELECT DISTINCT op.oprname as oprname -FROM pg_catalog.pg_operator op, -( SELECT oid - FROM (SELECT pg_catalog.format_type(t.oid,NULL) AS typname, - t.oid as oid - FROM pg_catalog.pg_type t - JOIN pg_catalog.pg_namespace nsp ON typnamespace=nsp.oid - WHERE (NOT (typname = 'unknown' AND nspname = 'pg_catalog')) AND - typisdefined AND - typtype IN ('b', 'c', 'd', 'e', 'r') AND - NOT EXISTS (SELECT 1 - FROM pg_catalog.pg_class - WHERE relnamespace=typnamespace AND - relname = typname AND - relkind != 'c') AND - (typname NOT LIKE '_%' OR - NOT EXISTS (SELECT 1 - FROM pg_catalog.pg_class - WHERE relnamespace=typnamespace AND - relname = SUBSTRING(typname FROM 2)::name AND - relkind != 'c')) - {% if not show_sysobj %} - AND nsp.nspname != 'information_schema' - {% endif %} - UNION SELECT 'smallserial', 0 - UNION SELECT 'bigserial', 0 - UNION SELECT 'serial', 0) t1 - WHERE typname = {{type|qtLiteral}}) AS types -WHERE oprcom > 0 AND - (op.oprleft=types.oid OR op.oprright=types.oid) -{% else %} -SELECT DISTINCT op.oprname as oprname -FROM pg_catalog.pg_operator op -WHERE oprcom > 0 -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.6_plus/get_access_methods.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.6_plus/get_access_methods.sql deleted file mode 100644 index e46955433..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.6_plus/get_access_methods.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT amname -FROM pg_catalog.pg_am -WHERE EXISTS (SELECT 1 - FROM pg_catalog.pg_proc - WHERE oid=amhandler) -ORDER BY amname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_access_methods.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_access_methods.sql index b47abe738..e46955433 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_access_methods.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_access_methods.sql @@ -2,5 +2,5 @@ SELECT amname FROM pg_catalog.pg_am WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_proc - WHERE oid=amgettuple) + WHERE oid=amhandler) ORDER BY amname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_constraint_cols.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_constraint_cols.sql index 0a2e3f6d6..56f830362 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_constraint_cols.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_constraint_cols.sql @@ -16,8 +16,7 @@ FROM pg_catalog.pg_index i JOIN pg_catalog.pg_attribute a ON (a.attrelid = i.indexrelid AND attnum = {{loop.index}}) JOIN pg_catalog.pg_type ty ON ty.oid=a.atttypid LEFT OUTER JOIN pg_catalog.pg_opclass o ON (o.oid = i.indclass[{{loop.index -1}}]) -LEFT OUTER JOIN pg_catalog.pg_constraint c ON (c.conindid = i.indexrelid) -LEFT OUTER JOIN pg_catalog.pg_operator op ON (op.oid = c.conexclop[{{loop.index}}]) +LEFT OUTER JOIN pg_catalog.pg_constraint c ON (c.conindid = i.indexrelid) LEFT OUTER JOIN pg_catalog.pg_operator op ON (op.oid = c.conexclop[{{loop.index}}]) LEFT OUTER JOIN pg_catalog.pg_collation coll ON a.attcollation=coll.oid LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid WHERE i.indexrelid = {{cid}}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_oid_with_transaction.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_oid_with_transaction.sql index 52024fe30..fd7ac3953 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_oid_with_transaction.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_oid_with_transaction.sql @@ -1,6 +1,6 @@ SELECT ct.conindid AS oid, ct.conname AS name, - true AS convalidated + NOT convalidated AS convalidated FROM pg_catalog.pg_constraint ct WHERE contype='x' AND conrelid = {{tid}}::oid LIMIT 1; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_operator.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_operator.sql index a1ad0d3d3..eb0c72fd2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_operator.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/get_operator.sql @@ -23,6 +23,7 @@ FROM pg_catalog.pg_operator op, {% if not show_sysobj %} AND nsp.nspname != 'information_schema' {% endif %} + UNION SELECT 'smallserial', 0 UNION SELECT 'bigserial', 0 UNION SELECT 'serial', 0) t1 WHERE typname = {{type|qtLiteral}}) AS types diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/nodes.sql index 8d13cb899..2c09229ce 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/default/nodes.sql @@ -1,3 +1,10 @@ -SELECT '' AS oid, '' AS conname, '' AS convalidated +SELECT conindid as oid, + conname as name, + NOT convalidated as convalidated FROM pg_catalog.pg_constraint ct -WHERE false +WHERE contype='x' AND + conrelid = {{tid}}::oid +{% if exid %} + AND conindid = {{exid}}::oid +{% endif %} +ORDER BY conname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/get_oid.sql deleted file mode 100644 index 5b0b42132..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/get_oid.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT ct.oid, - NOT convalidated as convalidated -FROM pg_catalog.pg_constraint ct -WHERE contype='f' AND -ct.conname = {{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/get_oid_with_transaction.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/get_oid_with_transaction.sql deleted file mode 100644 index 1a700e62e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/get_oid_with_transaction.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT ct.oid, - ct.conname as name, - NOT convalidated as convalidated -FROM pg_catalog.pg_constraint ct -WHERE contype='f' AND - conrelid = {{tid}}::oid LIMIT 1; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/nodes.sql deleted file mode 100644 index 765c0391a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/nodes.sql +++ /dev/null @@ -1,7 +0,0 @@ -SELECT ct.oid, - conname as name, - NOT convalidated as convalidated -FROM pg_catalog.pg_constraint ct -WHERE contype='f' AND - conrelid = {{tid}}::oid -ORDER BY conname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/properties.sql deleted file mode 100644 index 610100093..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/9.1_plus/properties.sql +++ /dev/null @@ -1,32 +0,0 @@ -SELECT ct.oid, - conname as name, - condeferrable, - condeferred, - confupdtype, - confdeltype, - CASE confmatchtype - WHEN 's' THEN FALSE - WHEN 'f' THEN TRUE - END AS confmatchtype, - conkey, - confkey, - confrelid, - nl.nspname as fknsp, - cl.relname as fktab, - nr.nspname as refnsp, - cr.relname as reftab, - description as comment, - convalidated, - conislocal -FROM pg_catalog.pg_constraint ct -JOIN pg_catalog.pg_class cl ON cl.oid=conrelid -JOIN pg_catalog.pg_namespace nl ON nl.oid=cl.relnamespace -JOIN pg_catalog.pg_class cr ON cr.oid=confrelid -JOIN pg_catalog.pg_namespace nr ON nr.oid=cr.relnamespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=ct.oid AND des.classoid='pg_constraint'::regclass) -WHERE contype='f' AND -conrelid = {{tid}}::oid -{% if cid %} -AND ct.oid = {{cid}}::oid -{% endif %} -ORDER BY conname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid.sql index eda42e318..5b0b42132 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid.sql @@ -1,5 +1,5 @@ SELECT ct.oid, - true as convalidated + NOT convalidated as convalidated FROM pg_catalog.pg_constraint ct WHERE contype='f' AND ct.conname = {{ name|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid_with_transaction.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid_with_transaction.sql index 7d01b1598..1a700e62e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid_with_transaction.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/get_oid_with_transaction.sql @@ -1,6 +1,6 @@ SELECT ct.oid, ct.conname as name, - true as convalidated + NOT convalidated as convalidated FROM pg_catalog.pg_constraint ct WHERE contype='f' AND conrelid = {{tid}}::oid LIMIT 1; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/nodes.sql index 51e2861cd..765c0391a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/nodes.sql @@ -1,6 +1,6 @@ SELECT ct.oid, conname as name, - true as convalidated + NOT convalidated as convalidated FROM pg_catalog.pg_constraint ct WHERE contype='f' AND conrelid = {{tid}}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/properties.sql index a827b783f..610100093 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/foreign_key/sql/default/properties.sql @@ -1,6 +1,4 @@ -SELECT - convalidated, - ct.oid, +SELECT ct.oid, conname as name, condeferrable, condeferred, @@ -18,6 +16,7 @@ SELECT nr.nspname as refnsp, cr.relname as reftab, description as comment, + convalidated, conislocal FROM pg_catalog.pg_constraint ct JOIN pg_catalog.pg_class cl ON cl.oid=conrelid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/attach.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/attach.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/attach.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/attach.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/backend_support.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/backend_support.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/backend_support.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/backend_support.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/detach.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/detach.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/detach.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/detach.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/get_attach_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/get_attach_tables.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/get_attach_tables.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/get_attach_tables.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/partition_diff.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/partition_diff.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/partition_diff.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/partition_diff.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/10_plus/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/default/properties.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/attach.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/attach.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/attach.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/attach.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/backend_support.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/backend_support.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/backend_support.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/backend_support.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/detach.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/detach.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/detach.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/detach.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/get_attach_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/get_attach_tables.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/get_attach_tables.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/get_attach_tables.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/partition_diff.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/partition_diff.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/partition_diff.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/partition_diff.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/10_plus/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/default/properties.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/10_plus/create.sql deleted file mode 100644 index 27c7c3741..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/10_plus/create.sql +++ /dev/null @@ -1,27 +0,0 @@ -{% set add_semicolon_after = 'to' %} -{% if data.withcheck is defined and data.withcheck != None and data.withcheck != '' %} -{% set add_semicolon_after = 'with_check' %} -{% elif data.using is defined and data.using != None and data.using != '' %} -{% set add_semicolon_after = 'using' %} -{% endif %} -CREATE POLICY {{ conn|qtIdent(data.name) }} - ON {{conn|qtIdent(data.schema, data.table)}} -{%if data.type %} - AS {{ data.type|upper }} -{% endif %} -{% if data.event %} - FOR {{ data.event|upper }} -{% endif %} -{% if data.policyowner %} - TO {{ conn|qtTypeIdent(data.policyowner) }}{% if add_semicolon_after == 'to' %};{% endif %} -{% else %} - TO public{% if add_semicolon_after == 'to' %};{% endif %} -{% endif %} -{% if data.using %} - - USING ({{ data.using }}){% if add_semicolon_after == 'using' %};{% endif %} -{% endif %} -{% if data.withcheck %} - - WITH CHECK ({{ data.withcheck }}); -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/10_plus/properties.sql deleted file mode 100644 index 8a672967c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/10_plus/properties.sql +++ /dev/null @@ -1,23 +0,0 @@ -SELECT - pl.oid AS oid, - pl.polname AS name, - rw.permissive as type, - rw.cmd AS event, - rw.qual AS using, - rw.qual AS using_orig, - rw.with_check AS withcheck, - rw.with_check AS withcheck_orig, - - pg_catalog.array_to_string(rw.roles::name[], ', ') AS policyowner -FROM - pg_catalog.pg_policy pl -JOIN pg_catalog.pg_policies rw ON pl.polname=rw.policyname -JOIN pg_catalog.pg_namespace n ON n.nspname=rw.schemaname -JOIN pg_catalog.pg_class rel on rel.relname=rw.tablename -WHERE -{% if plid %} - pl.oid = {{ plid }} and n.oid = {{ scid }} and rel.oid = {{ policy_table_id }}; -{% endif %} -{% if tid %} - pl.polrelid = {{ tid }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/create.sql deleted file mode 100644 index 67c03794e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/create.sql +++ /dev/null @@ -1,24 +0,0 @@ -{% set add_semicolon_after = 'to' %} -{% if data.withcheck is defined and data.withcheck != None and data.withcheck != '' %} -{% set add_semicolon_after = 'with_check' %} -{% elif data.using is defined and data.using != None and data.using != '' %} -{% set add_semicolon_after = 'using' %} -{% endif %} -CREATE POLICY {{ conn|qtIdent(data.name) }} - ON {{conn|qtIdent(data.schema, data.table)}} -{% if data.event %} - FOR {{ data.event|upper }} -{% endif %} -{% if data.policyowner %} - TO {{ conn|qtTypeIdent(data.policyowner) }}{% if add_semicolon_after == 'to' %};{% endif %} -{% else %} - TO public{% if add_semicolon_after == 'to' %};{% endif %} -{% endif %} -{% if data.using %} - - USING ({{ data.using }}){% if add_semicolon_after == 'using' %};{% endif %} -{% endif %} -{% if data.withcheck %} - - WITH CHECK ({{ data.withcheck }}); -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/delete.sql deleted file mode 100644 index ffe32a05f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/delete.sql +++ /dev/null @@ -1 +0,0 @@ -DROP POLICY IF EXISTS {{ conn|qtIdent(policy_name) }} ON {{conn|qtIdent(result.schema, result.table)}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_parent.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_parent.sql deleted file mode 100644 index 0c46d743c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_parent.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT nsp.nspname AS schema ,rel.relname AS table -FROM pg_catalog.pg_class rel - JOIN pg_catalog.pg_namespace nsp - ON rel.relnamespace = nsp.oid::oid - WHERE rel.oid = {{tid}}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_policy_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_policy_name.sql deleted file mode 100644 index 90fe16bd2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_policy_name.sql +++ /dev/null @@ -1,9 +0,0 @@ -{% if plid %} -SELECT - pl.oid AS oid, - pl.polname AS name -FROM - pg_catalog.pg_policy pl -WHERE - pl.oid = {{ plid }} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_position.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_position.sql deleted file mode 100644 index 851d504d9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/get_position.sql +++ /dev/null @@ -1,2 +0,0 @@ -SELECT pl.oid FROM pg_catalog.pg_policy pl -WHERE pl.polrelid = {{tid}}::oid AND pl.polname = {{data.name|qtLiteral}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/nodes.sql deleted file mode 100644 index 8aeba94ae..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - pl.oid AS oid, - pl.polname AS name -FROM - pg_catalog.pg_policy pl -WHERE -{% if tid %} - pl.polrelid = {{ tid }} -{% elif plid %} - pl.oid = {{ plid }} -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = pl.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - pl.polname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/properties.sql deleted file mode 100644 index 3098b5c83..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/properties.sql +++ /dev/null @@ -1,22 +0,0 @@ -SELECT - pl.oid AS oid, - pl.polname AS name, - rw.cmd AS event, - rw.qual AS using, - rw.qual AS using_orig, - rw.with_check AS withcheck, - rw.with_check AS withcheck_orig, - - pg_catalog.array_to_string(rw.roles::name[], ', ') AS policyowner -FROM - pg_catalog.pg_policy pl -JOIN pg_catalog.pg_policies rw ON pl.polname=rw.policyname -JOIN pg_catalog.pg_namespace n ON n.nspname=rw.schemaname -JOIN pg_catalog.pg_class rel on rel.relname=rw.tablename -WHERE -{% if plid %} - pl.oid = {{ plid }} and n.oid = {{ scid }} and rel.oid = {{ policy_table_id }}; -{% endif %} -{% if tid %} - pl.polrelid = {{ tid }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/update.sql deleted file mode 100644 index 7fa1e3f40..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/9.5_plus/update.sql +++ /dev/null @@ -1,33 +0,0 @@ -{#####################################################} -{## Change policy owner ##} -{#####################################################} -{% if data.policyowner and o_data.policyowner != data.policyowner %} -ALTER POLICY {{ conn|qtIdent(o_data.name) }} ON {{conn|qtIdent(o_data.schema, o_data.table)}} - TO {{ conn|qtTypeIdent(data.policyowner) }}; -{% endif %} - -{#####################################################} -{## Change policy using condition ##} -{#####################################################} -{% if data.using and o_data.using != data.using %} -ALTER POLICY {{ conn|qtIdent(o_data.name) }} ON {{conn|qtIdent(o_data.schema, o_data.table)}} - USING ({{ data.using }}); -{% endif %} - -{#####################################################} -{## Change policy with check condition ##} -{#####################################################} -{% if data.withcheck and o_data.withcheck != data.withcheck %} -ALTER POLICY {{ conn|qtIdent(o_data.name) }} ON {{conn|qtIdent(o_data.schema, o_data.table)}} - WITH CHECK ({{ data.withcheck }}); -{% endif %} - -{#####################################################} -{## Change policy name ##} -{#####################################################} -{% if data.name and o_data.name != data.name %} -ALTER POLICY {{ conn|qtIdent(o_data.name) }} ON {{conn|qtIdent(o_data.schema, o_data.table)}} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} - - diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/create.sql index 67c03794e..27c7c3741 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/create.sql @@ -6,6 +6,9 @@ {% endif %} CREATE POLICY {{ conn|qtIdent(data.name) }} ON {{conn|qtIdent(data.schema, data.table)}} +{%if data.type %} + AS {{ data.type|upper }} +{% endif %} {% if data.event %} FOR {{ data.event|upper }} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/properties.sql index 3098b5c83..8a672967c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/row_security_policies/sql/default/properties.sql @@ -1,6 +1,7 @@ SELECT pl.oid AS oid, pl.polname AS name, + rw.permissive as type, rw.cmd AS event, rw.qual AS using, rw.qual AS using_orig, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/acl.sql deleted file mode 100644 index 7c2e6d9d3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/acl.sql +++ /dev/null @@ -1,46 +0,0 @@ -{### SQL to fetch privileges for tablespace ###} -SELECT 'relacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT rel.relacl - FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid - WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid - AND rel.oid = {{ tid }}::oid - ) acl, - (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable - AS is_grantable, (d).privilege_type AS privilege_type FROM (SELECT - aclexplode(rel.relacl) as d - FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid - WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid - AND rel.oid = {{ tid }}::oid - ) a ORDER BY privilege_type) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/create.sql deleted file mode 100644 index c1eaedf7e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/create.sql +++ /dev/null @@ -1,208 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'columns/macros/security.macros' as COLUMN_SECLABEL %} -{% import 'columns/macros/privilege.macros' as COLUMN_PRIVILEGE %} -{% import 'tables/sql/macros/constraints.macro' as CONSTRAINTS %} -{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %} -{#===========================================#} -{#====== MAIN TABLE TEMPLATE STARTS HERE ======#} -{#===========================================#} -{# - If user has not provided any details but only name then - add empty bracket with table name -#} -{% set empty_bracket = ""%} -{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %} -{% set empty_bracket = "\n(\n)"%} -{% endif %} -CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}} -{% if data.typname %} - OF {{ data.typname }} -{% endif %} -{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} -( -{% endif %} -{% if data.like_relation %} - LIKE {{ data.like_relation }}{% if data.like_default_value %} - - INCLUDING DEFAULTS{% endif %}{% if data.like_constraints %} - - INCLUDING CONSTRAINTS{% endif %}{% if data.like_indexes %} - - INCLUDING INDEXES{% endif %}{% if data.like_storage %} - - INCLUDING STORAGE{% endif %}{% if data.like_comments %} - - INCLUDING COMMENTS{% endif %}{% if data.columns|length > 0 %}, -{% endif %} - -{% endif %} -{### Add columns ###} -{% if data.columns and data.columns|length > 0 %} -{% for c in data.columns %} -{% if c.name and c.cltype %} - {% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' %} DEFAULT {{c.defval}}{% endif %} -{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %} -{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %} -{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %} -{% if c.seqcycle is defined and c.seqcycle %} -CYCLE {% endif %}{% if c.seqincrement is defined and c.seqincrement|int(-1) > -1 %} -INCREMENT {{c.seqincrement|int}} {% endif %}{% if c.seqstart is defined and c.seqstart|int(-1) > -1%} -START {{c.seqstart|int}} {% endif %}{% if c.seqmin is defined and c.seqmin|int(-1) > -1%} -MINVALUE {{c.seqmin|int}} {% endif %}{% if c.seqmax is defined and c.seqmax|int(-1) > -1%} -MAXVALUE {{c.seqmax|int}} {% endif %}{% if c.seqcache is defined and c.seqcache|int(-1) > -1%} -CACHE {{c.seqcache|int}} {% endif %} -{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %}){% endif %} -{% endif %} -{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{# Macro to render for constraints #} -{% if data.primary_key|length > 0 %}{% if data.columns|length > 0 %},{% endif %} -{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 %},{% endif %} -{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 %},{% endif %} -{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 %},{% endif %} -{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}{% if data.exclude_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 %},{% endif %} -{{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %} -{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} - -){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }}{% endif %} - -{### If we are inheriting it from another table(s) ###} -{% if data.coll_inherits %} - INHERITS ({% for val in data.coll_inherits %}{% if loop.index != 1 %}, {% endif %}{{val}}{% endfor %}) -{% endif %} -WITH ( - OIDS = {% if data.relhasoids %}TRUE{% else %}FALSE{% endif %}{% if data.fillfactor %}, - FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.parallel_workers is defined and data.parallel_workers != '' and data.parallel_workers != None %}, - parallel_workers = {{ data.parallel_workers }}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %}, - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% endif %}{% if data.toast_autovacuum_enabled in ('t', 'f') %}, - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %} -{% endif %}{% if data.autovacuum_custom and data.vacuum_table|length > 0 %} -{% for opt in data.vacuum_table %}{% if opt.name and opt.value is defined %} -, - {{opt.name}} = {{opt.value}}{% endif %} -{% endfor %}{% endif %}{% if data.toast_autovacuum and data.vacuum_toast|length > 0 %} -{% for opt in data.vacuum_toast %}{% if opt.name and opt.value is defined %} -, - toast.{{opt.name}} = {{opt.value}}{% endif %} -{% endfor %}{% endif %} - -{### SQL for Tablespace ###} -{% if data.spcname %} -) -TABLESPACE {{ conn|qtIdent(data.spcname) }}; -{% else %} -); -{% endif %} -{### Alter SQL for Owner ###} -{% if data.relowner %} - -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - OWNER to {{conn|qtIdent(data.relowner)}}; -{% endif %} - -{#####################################################} -{## Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.rlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ENABLE ROW LEVEL SECURITY; -{% endif %} - -{#####################################################} -{## Force Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.forcerlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - FORCE ROW LEVEL SECURITY; -{% endif %} - -{### Security Labels on Table ###} -{% if data.seclabels and data.seclabels|length > 0 %} - -{% for r in data.seclabels %} -{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{### ACL on Table ###} -{% if data.revoke_all %} -{% for priv in data.revoke_all %} -{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}} -{% endfor %} -{% endif %} -{% if data.relacl %} - -{% for priv in data.relacl %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{### SQL for COMMENT ###} -{% if data.description %} -COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} - IS {{data.description|qtLiteral}}; -{% endif %} -{#===========================================#} -{#====== MAIN TABLE TEMPLATE ENDS HERE ======#} -{#===========================================#} -{#===========================================#} -{# COLUMN SPECIFIC TEMPLATES STARTS HERE #} -{#===========================================#} -{% if data.columns and data.columns|length > 0 %} -{% for c in data.columns %} -{% if c.description %} - -COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}} - IS {{c.description|qtLiteral}}; -{% endif %} -{### Add variables to column ###} -{% if c.attoptions and c.attoptions|length > 0 %} - -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - {{ VARIABLE.SET(conn, 'COLUMN', c.name, c.attoptions) }} - -{% endif %} -{### Alter column statistics value ###} -{% if c.attstattarget is defined and c.attstattarget > -1 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STATISTICS {{c.attstattarget}}; - -{% endif %} -{### Alter column storage value ###} -{% if c.attstorage is defined and c.attstorage != c.defaultstorage %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STORAGE {%if c.attstorage == 'p' %} -PLAIN{% elif c.attstorage == 'm'%}MAIN{% elif c.attstorage == 'e'%} -EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% endif %}; - -{% endif %} -{### ACL ###} -{% if c.attacl and c.attacl|length > 0 %} - -{% for priv in c.attacl %} -{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{### Security Lables ###} -{% if c.seclabels and c.seclabels|length > 0 %} - -{% for r in c.seclabels %} -{{ COLUMN_SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% endfor %} -{% endif %} -{#===========================================#} -{# COLUMN SPECIFIC TEMPLATES ENDS HERE #} -{#===========================================#} -{#======================================#} -{# CONSTRAINTS SPECIFIC TEMPLATES #} -{#======================================#} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.primary_key)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.unique_constraint)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.foreign_key)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.check_constraint)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.exclude_constraint)}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_columns_for_table.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_columns_for_table.sql deleted file mode 100644 index 2bb034c13..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_columns_for_table.sql +++ /dev/null @@ -1,19 +0,0 @@ -SELECT - a.attname AS name, pg_catalog.format_type(a.atttypid, NULL) AS cltype, - pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, a.attidentity as clidentity, - pg_catalog.quote_ident(n.nspname)||'.'||pg_catalog.quote_ident(c.relname) as inheritedfrom, - c.oid as inheritedid -FROM - pg_catalog.pg_class c -JOIN - pg_catalog.pg_namespace n ON c.relnamespace=n.oid -JOIN - pg_catalog.pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped AND a.attnum > 0 -LEFT OUTER JOIN - pg_catalog.pg_attrdef def ON adrelid=a.attrelid AND adnum=a.attnum -WHERE -{% if tid %} - c.oid = {{tid}}::OID -{% else %} - c.relname = {{tname|qtLiteral}} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_inherits.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_inherits.sql deleted file mode 100644 index 2e5df5f8f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_inherits.sql +++ /dev/null @@ -1,17 +0,0 @@ -{% import 'tables/sql/macros/db_catalogs.macro' as CATALOG %} -SELECT c.oid, c.relname , nspname, -CASE WHEN nspname NOT LIKE 'pg\_%' THEN - pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname) -ELSE pg_catalog.quote_ident(c.relname) -END AS inherits -FROM pg_catalog.pg_class c -JOIN pg_catalog.pg_namespace n -ON n.oid=c.relnamespace -WHERE relkind='r' AND NOT relispartition -{% if not show_system_objects %} -{{ CATALOG.VALID_CATALOGS(server_type) }} -{% endif %} -{% if tid %} -AND c.oid != tid -{% endif %} -ORDER BY relnamespace, c.relname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_oid.sql deleted file mode 100644 index 97ab5fef5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_oid.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT rel.oid as tid -FROM pg_catalog.pg_class rel -WHERE rel.relkind IN ('r','s','t','p') -AND rel.relnamespace = {{ scid }}::oid -AND rel.relname = {{data.name|qtLiteral}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_table.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_table.sql deleted file mode 100644 index df88c4791..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/get_table.sql +++ /dev/null @@ -1,8 +0,0 @@ -SELECT - rel.relname AS name -FROM - pg_catalog.pg_class rel -WHERE - rel.relkind IN ('r','s','t','p') - AND rel.relnamespace = {{ scid }}::oid - AND rel.oid = {{ tid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/nodes.sql deleted file mode 100644 index 75ffacabf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/nodes.sql +++ /dev/null @@ -1,15 +0,0 @@ -SELECT rel.oid, rel.relname AS name, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers, - (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned, - (SELECT count(1) FROM pg_catalog.pg_inherits WHERE inhrelid=rel.oid LIMIT 1) as is_inherits, - (SELECT count(1) FROM pg_catalog.pg_inherits WHERE inhparent=rel.oid LIMIT 1) as is_inherited -FROM pg_catalog.pg_class rel - WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid - AND NOT rel.relispartition - {% if tid %} AND rel.oid = {{tid}}::OID {% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = rel.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} - ORDER BY rel.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/properties.sql deleted file mode 100644 index 47e9a75dc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/properties.sql +++ /dev/null @@ -1,74 +0,0 @@ -SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE - (SELECT sp.spcname FROM pg_catalog.pg_database dtb - JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid - WHERE dtb.oid = {{ did }}::oid) - END) as spcname, - (CASE rel.relreplident - WHEN 'd' THEN 'default' - WHEN 'n' THEN 'nothing' - WHEN 'f' THEN 'full' - WHEN 'i' THEN 'index' - END) as replica_identity, - (select nspname FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid ) as schema, - pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, rel.relkind, - (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned, - rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey, - EXISTS(select 1 FROM pg_catalog.pg_trigger - JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger' - JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion' - WHERE tgrelid=rel.oid) AS isrepl, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount, - (SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN - pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname) - ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS coll_inherits, - (SELECT count(*) - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, - (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'parallel_workers=([0-9]*)') AS parallel_workers, - (substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, - rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, - CASE WHEN typ.typname IS NOT NULL THEN (select pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid )||'.'||pg_catalog.quote_ident(typ.typname) ELSE typ.typname END AS typname, - typ.typrelid AS typoid, rel.relrowsecurity as rlspolicy, rel.relforcerowsecurity as forcerlspolicy, - (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, - (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table - -- Added for partition table - {% if tid %}, (CASE WHEN rel.relkind = 'p' THEN pg_catalog.pg_get_partkeydef({{ tid }}::oid) ELSE '' END) AS partition_scheme {% endif %} -FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid -WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid -AND NOT rel.relispartition -{% if tid %} AND rel.oid = {{ tid }}::oid {% endif %} -ORDER BY rel.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/update.sql deleted file mode 100644 index fb1ffda31..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/10_plus/update.sql +++ /dev/null @@ -1,269 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% import 'macros/variable.macros' as VARIABLE %} -{#####################################################} -{## Rename table ##} -{#####################################################} -{% if data.name and data.name != o_data.name %} -ALTER TABLE IF EXISTS {{conn|qtIdent(o_data.schema, o_data.name)}} - RENAME TO {{conn|qtIdent(data.name)}}; - -{% endif %} -{#####################################################} -{## Change table schema ##} -{#####################################################} -{% if data.schema and data.schema != o_data.schema %} -ALTER TABLE IF EXISTS {{conn|qtIdent(o_data.schema, data.name)}} - SET SCHEMA {{conn|qtIdent(data.schema)}}; - -{% endif %} -{#####################################################} -{## Change table owner ##} -{#####################################################} -{% if data.relowner and data.relowner != o_data.relowner %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - OWNER TO {{conn|qtIdent(data.relowner)}}; - -{% endif %} -{#####################################################} -{## Update Inherits table definition ##} -{#####################################################} -{% if data.coll_inherits_added|length > 0 %} -{% for val in data.coll_inherits_added %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - INHERIT {{val}}; - -{% endfor %} -{% endif %} -{% if data.coll_inherits_removed|length > 0 %} -{% for val in data.coll_inherits_removed %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - NO INHERIT {{val}}; - -{% endfor %} -{% endif %} -{#####################################################} -{## Change hasOID attribute of table ##} -{#####################################################} -{% if data.relhasoids is defined and data.relhasoids != o_data.relhasoids %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - SET {% if data.relhasoids %}WITH{% else %}WITHOUT{% endif %} OIDS; - -{% endif %} -{#####################################################} -{## Change tablespace ##} -{#####################################################} -{% if data.spcname and data.spcname != o_data.spcname %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - SET TABLESPACE {{conn|qtIdent(data.spcname)}}; - -{% endif %} -{#####################################################} -{## change fillfactor settings ##} -{#####################################################} -{% if data.fillfactor and data.fillfactor != o_data.fillfactor %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - SET (FILLFACTOR={{data.fillfactor}}); -{% elif (data.fillfactor == '' or data.fillfactor == None) and data.fillfactor != o_data.fillfactor %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - RESET (FILLFACTOR); - -{% endif %} -{###############################} -{## Table AutoVacuum settings ##} -{###############################} -{% if data.vacuum_table is defined and data.vacuum_table.set_values|length > 0 %} -{% set has_vacuum_set = true %} -{% endif %} -{% if data.vacuum_table is defined and data.vacuum_table.reset_values|length > 0 %} -{% set has_vacuum_reset = true %} -{% endif %} -{% if o_data.autovacuum_custom and data.autovacuum_custom == false %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( - autovacuum_enabled, - autovacuum_analyze_scale_factor, - autovacuum_analyze_threshold, - autovacuum_freeze_max_age, - autovacuum_vacuum_cost_delay, - autovacuum_vacuum_cost_limit, - autovacuum_vacuum_scale_factor, - autovacuum_vacuum_threshold, - autovacuum_freeze_min_age, - autovacuum_freeze_table_age -); -{% else %} -{% if (data.autovacuum_enabled in ('t', 'f') and data.autovacuum_enabled != o_data.autovacuum_enabled) or has_vacuum_set %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} SET ( -{% if data.autovacuum_enabled in ('t', 'f') and data.autovacuum_enabled != o_data.autovacuum_enabled %} - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}true{% else %}false{% endif %}{% if has_vacuum_set %}, -{% endif %} -{% endif %} -{% if has_vacuum_set %} -{% for opt in data.vacuum_table.set_values %}{% if opt.name and opt.value is defined %} - {{opt.name}} = {{opt.value}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% if (data.autovacuum_enabled == 'x' and data.autovacuum_enabled != o_data.autovacuum_enabled) or has_vacuum_reset %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( -{% if data.autovacuum_enabled =='x' and data.autovacuum_enabled != o_data.autovacuum_enabled %} - autovacuum_enabled{% if has_vacuum_reset %}, -{% endif %} -{% endif %} -{% if has_vacuum_reset %} -{% for opt in data.vacuum_table.reset_values %}{% if opt.name %} - {{opt.name}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% endif %} - -{#####################################################} -{## Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.rlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ENABLE ROW LEVEL SECURITY; -{% elif data.rlspolicy is defined and data.rlspolicy != o_data.rlspolicy%} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - DISABLE ROW LEVEL SECURITY; - -{% endif %} - -{#####################################################} -{## Force Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.forcerlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - FORCE ROW LEVEL SECURITY; -{% elif data.forcerlspolicy is defined and data.forcerlspolicy != o_data.forcerlspolicy%} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - NO FORCE ROW LEVEL SECURITY; -{% endif %} - -{#####################################} -{## Toast table AutoVacuum settings ##} -{#####################################} -{% if data.vacuum_toast is defined and data.vacuum_toast.set_values|length > 0 %} -{% set has_vacuum_toast_set = true %} -{% endif %} -{% if data.vacuum_toast is defined and data.vacuum_toast.reset_values|length > 0 %} -{% set has_vacuum_toast_reset = true %} -{% endif %} -{% if o_data.toast_autovacuum and data.toast_autovacuum == false %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( - toast.autovacuum_enabled, - toast.autovacuum_freeze_max_age, - toast.autovacuum_vacuum_cost_delay, - toast.autovacuum_vacuum_cost_limit, - toast.autovacuum_vacuum_scale_factor, - toast.autovacuum_vacuum_threshold, - toast.autovacuum_freeze_min_age, - toast.autovacuum_freeze_table_age, - toast.autovacuum_analyze_threshold, - toast.autovacuum_analyze_scale_factor -); -{% else %} -{% if (data.toast_autovacuum_enabled in ('t', 'f') and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled) or has_vacuum_toast_set %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} SET ( -{% if data.toast_autovacuum_enabled in ('t', 'f') and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled %} - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}true{% else %}false{% endif %}{% if has_vacuum_toast_set %}, -{% endif %} -{% endif %} -{% if has_vacuum_toast_set %} -{% for opt in data.vacuum_toast.set_values %}{% if opt.name and opt.value is defined %} - toast.{{opt.name}} = {{opt.value}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% if (data.toast_autovacuum_enabled == 'x' and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled) or has_vacuum_toast_reset %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( -{% if data.toast_autovacuum_enabled == 'x' and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled %} - toast.autovacuum_enabled{% if has_vacuum_toast_reset %}, -{% endif %} -{% endif %} -{% if has_vacuum_toast_reset %} -{% for opt in data.vacuum_toast.reset_values %}{% if opt.name %} - toast.{{opt.name}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% endif %} -{#####################################################} -{## Change table comments ##} -{#####################################################} -{% if data.description is defined and data.description != o_data.description %} -COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} - IS {{data.description|qtLiteral}}; - -{% endif %} -{#####################################################} -{## Update table Privileges ##} -{#####################################################} -{% if data.relacl %} -{% if 'deleted' in data.relacl %} -{% for priv in data.relacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.relacl %} -{% for priv in data.relacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{#####################################################} -{## Update table SecurityLabel ##} -{#####################################################} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'TABLE', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} - -{% endif %} - -{#####################################################} -{## Change replica identity ##} -{#####################################################} -{% if data.replica_identity and data.replica_identity != o_data.replica_identity %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} REPLICA IDENTITY {{data.replica_identity }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/acl.sql deleted file mode 100644 index a79ee500c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/acl.sql +++ /dev/null @@ -1,46 +0,0 @@ -{### SQL to fetch privileges for tablespace ###} -SELECT 'relacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT rel.relacl - FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid - WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid - AND rel.oid = {{ tid }}::oid - ) acl, - (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable - AS is_grantable, (d).privilege_type AS privilege_type FROM (SELECT - pg_catalog.aclexplode(rel.relacl) as d - FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid - WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid - AND rel.oid = {{ tid }}::oid - ) a ORDER BY privilege_type) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/get_inherits.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/get_inherits.sql deleted file mode 100644 index 00ef9faaf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/get_inherits.sql +++ /dev/null @@ -1,17 +0,0 @@ -{% import 'tables/sql/macros/db_catalogs.macro' as CATALOG %} -SELECT c.oid, c.relname , nspname, -CASE WHEN nspname NOT LIKE 'pg\_%' THEN - pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname) -ELSE pg_catalog.quote_ident(c.relname) -END AS inherits -FROM pg_catalog.pg_class c -JOIN pg_catalog.pg_namespace n -ON n.oid=c.relnamespace -WHERE relkind='r' -{% if not show_system_objects %} -{{ CATALOG.VALID_CATALOGS(server_type) }} -{% endif %} -{% if tid %} -AND c.oid != tid -{% endif %} -ORDER BY relnamespace, c.relname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/nodes.sql deleted file mode 100644 index 6b8e0d8e3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/nodes.sql +++ /dev/null @@ -1,13 +0,0 @@ -SELECT rel.oid, rel.relname AS name, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers, - (SELECT count(1) FROM pg_catalog.pg_inherits WHERE inhrelid=rel.oid LIMIT 1) as is_inherits, - (SELECT count(1) FROM pg_catalog.pg_inherits WHERE inhparent=rel.oid LIMIT 1) as is_inherited -FROM pg_catalog.pg_class rel - WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid - {% if tid %} AND rel.oid = {{tid}}::OID {% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = rel.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} - ORDER BY rel.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/properties.sql deleted file mode 100644 index 2c5d559b7..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/properties.sql +++ /dev/null @@ -1,63 +0,0 @@ -SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE - (SELECT sp.spcname FROM pg_catalog.pg_database dtb - JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid - WHERE dtb.oid = {{ did }}::oid) - END) as spcname, - (select nspname FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid ) as schema, - pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, - rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey, - EXISTS(select 1 FROM pg_catalog.pg_trigger - JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger' - JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion' - WHERE tgrelid=rel.oid) AS isrepl, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount, - (SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN - pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname) - ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS coll_inherits, - (SELECT count(*) - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, - (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, - rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, - CASE WHEN typ.typname IS NOT NULL THEN (select pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid )||'.'||pg_catalog.quote_ident(typ.typname) ELSE typ.typname END AS typname, - typ.typrelid AS typoid, - (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, - (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table -FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid -WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid -{% if tid %} AND rel.oid = {{ tid }}::oid {% endif %} -ORDER BY rel.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/stats.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/stats.sql deleted file mode 100644 index e643f1bcf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.1_plus/stats.sql +++ /dev/null @@ -1,57 +0,0 @@ -SELECT - seq_scan AS {{ conn|qtIdent(_('Sequential scans')) }}, - seq_tup_read AS {{ conn|qtIdent(_('Sequential tuples read')) }}, - idx_scan AS {{ conn|qtIdent(_('Index scans')) }}, - idx_tup_fetch AS {{ conn|qtIdent(_('Index tuples fetched')) }}, - n_tup_ins AS {{ conn|qtIdent(_('Tuples inserted')) }}, - n_tup_upd AS {{ conn|qtIdent(_('Tuples updated')) }}, - n_tup_del AS {{ conn|qtIdent(_('Tuples deleted')) }}, - n_tup_hot_upd AS {{ conn|qtIdent(_('Tuples HOT updated')) }}, - n_live_tup AS {{ conn|qtIdent(_('Live tuples')) }}, - n_dead_tup AS {{ conn|qtIdent(_('Dead tuples')) }}, - heap_blks_read AS {{ conn|qtIdent(_('Heap blocks read')) }}, - heap_blks_hit AS {{ conn|qtIdent(_('Heap blocks hit')) }}, - idx_blks_read AS {{ conn|qtIdent(_('Index blocks read')) }}, - idx_blks_hit AS {{ conn|qtIdent(_('Index blocks hit')) }}, - toast_blks_read AS {{ conn|qtIdent(_('Toast blocks read')) }}, - toast_blks_hit AS {{ conn|qtIdent(_('Toast blocks hit')) }}, - tidx_blks_read AS {{ conn|qtIdent(_('Toast index blocks read')) }}, - tidx_blks_hit AS {{ conn|qtIdent(_('Toast index blocks hit')) }}, - last_vacuum AS {{ conn|qtIdent(_('Last vacuum')) }}, - last_autovacuum AS {{ conn|qtIdent(_('Last autovacuum')) }}, - last_analyze AS {{ conn|qtIdent(_('Last analyze')) }}, - last_autoanalyze AS {{ conn|qtIdent(_('Last autoanalyze')) }}, - pg_catalog.pg_stat_get_vacuum_count({{ tid }}::oid) AS {{ conn|qtIdent(_('Vacuum counter')) }}, - pg_catalog.pg_stat_get_autovacuum_count({{ tid }}::oid) AS {{ conn|qtIdent(_('Autovacuum counter')) }}, - pg_catalog.pg_stat_get_analyze_count({{ tid }}::oid) AS {{ conn|qtIdent(_('Analyze counter')) }}, - pg_catalog.pg_stat_get_autoanalyze_count({{ tid }}::oid) AS {{ conn|qtIdent(_('Autoanalyze counter')) }}, - pg_catalog.pg_relation_size(stat.relid) AS {{ conn|qtIdent(_('Table size')) }}, - CASE WHEN cl.reltoastrelid = 0 THEN NULL ELSE pg_catalog.pg_size_pretty(pg_relation_size(cl.reltoastrelid) - + COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) - FROM pg_catalog.pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0)) - END AS {{ conn|qtIdent(_('Toast table size')) }}, - COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) - FROM pg_catalog.pg_index WHERE indrelid=stat.relid)::int8, 0) - AS {{ conn|qtIdent(_('Indexes size')) }} -{% if is_pgstattuple %} -{#== EXTENDED STATS ==#} - ,tuple_count AS {{ conn|qtIdent(_('Tuple count')) }}, - tuple_len AS {{ conn|qtIdent(_('Tuple length')) }}, - tuple_percent AS {{ conn|qtIdent(_('Tuple percent')) }}, - dead_tuple_count AS {{ conn|qtIdent(_('Dead tuple count')) }}, - dead_tuple_len AS {{ conn|qtIdent(_('Dead tuple length')) }}, - dead_tuple_percent AS {{ conn|qtIdent(_('Dead tuple percent')) }}, - free_space AS {{ conn|qtIdent(_('Free space')) }}, - free_percent AS {{ conn|qtIdent(_('Free percent')) }} -FROM - pgstattuple('{{schema_name}}.{{table_name}}'), pg_catalog.pg_stat_all_tables stat -{% else %} -FROM - pg_catalog.pg_stat_all_tables stat -{% endif %} -JOIN - pg_catalog.pg_statio_all_tables statio ON stat.relid = statio.relid -JOIN - pg_catalog.pg_class cl ON cl.oid=stat.relid -WHERE - stat.relid = {{ tid }}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.2_plus/stats.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.2_plus/stats.sql deleted file mode 100644 index a3117a158..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.2_plus/stats.sql +++ /dev/null @@ -1,57 +0,0 @@ -SELECT - seq_scan AS {{ conn|qtIdent(_('Sequential scans')) }}, - seq_tup_read AS {{ conn|qtIdent(_('Sequential tuples read')) }}, - idx_scan AS {{ conn|qtIdent(_('Index scans')) }}, - idx_tup_fetch AS {{ conn|qtIdent(_('Index tuples fetched')) }}, - n_tup_ins AS {{ conn|qtIdent(_('Tuples inserted')) }}, - n_tup_upd AS {{ conn|qtIdent(_('Tuples updated')) }}, - n_tup_del AS {{ conn|qtIdent(_('Tuples deleted')) }}, - n_tup_hot_upd AS {{ conn|qtIdent(_('Tuples HOT updated')) }}, - n_live_tup AS {{ conn|qtIdent(_('Live tuples')) }}, - n_dead_tup AS {{ conn|qtIdent(_('Dead tuples')) }}, - heap_blks_read AS {{ conn|qtIdent(_('Heap blocks read')) }}, - heap_blks_hit AS {{ conn|qtIdent(_('Heap blocks hit')) }}, - idx_blks_read AS {{ conn|qtIdent(_('Index blocks read')) }}, - idx_blks_hit AS {{ conn|qtIdent(_('Index blocks hit')) }}, - toast_blks_read AS {{ conn|qtIdent(_('Toast blocks read')) }}, - toast_blks_hit AS {{ conn|qtIdent(_('Toast blocks hit')) }}, - tidx_blks_read AS {{ conn|qtIdent(_('Toast index blocks read')) }}, - tidx_blks_hit AS {{ conn|qtIdent(_('Toast index blocks hit')) }}, - last_vacuum AS {{ conn|qtIdent(_('Last vacuum')) }}, - last_autovacuum AS {{ conn|qtIdent(_('Last autovacuum')) }}, - last_analyze AS {{ conn|qtIdent(_('Last analyze')) }}, - last_autoanalyze AS {{ conn|qtIdent(_('Last autoanalyze')) }}, - vacuum_count AS {{ conn|qtIdent(_('Vacuum counter')) }}, - autovacuum_count AS {{ conn|qtIdent(_('Autovacuum counter')) }}, - analyze_count AS {{ conn|qtIdent(_('Analyze counter')) }}, - autoanalyze_count AS {{ conn|qtIdent(_('Autoanalyze counter')) }}, - pg_catalog.pg_relation_size(stat.relid) AS {{ conn|qtIdent(_('Table size')) }}, - CASE WHEN cl.reltoastrelid = 0 THEN NULL ELSE pg_catalog.pg_size_pretty(pg_catalog.pg_relation_size(cl.reltoastrelid) - + COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) - FROM pg_catalog.pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0)) - END AS {{ conn|qtIdent(_('Toast table size')) }}, - COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) - FROM pg_catalog.pg_index WHERE indrelid=stat.relid)::int8, 0) - AS {{ conn|qtIdent(_('Indexes size')) }} -{% if is_pgstattuple %} -{#== EXTENDED STATS ==#} - ,tuple_count AS {{ conn|qtIdent(_('Tuple count')) }}, - tuple_len AS {{ conn|qtIdent(_('Tuple length')) }}, - tuple_percent AS {{ conn|qtIdent(_('Tuple percent')) }}, - dead_tuple_count AS {{ conn|qtIdent(_('Dead tuple count')) }}, - dead_tuple_len AS {{ conn|qtIdent(_('Dead tuple length')) }}, - dead_tuple_percent AS {{ conn|qtIdent(_('Dead tuple percent')) }}, - free_space AS {{ conn|qtIdent(_('Free space')) }}, - free_percent AS {{ conn|qtIdent(_('Free percent')) }} -FROM - pgstattuple('{{schema_name}}.{{table_name}}'), pg_catalog.pg_stat_all_tables stat -{% else %} -FROM - pg_catalog.pg_stat_all_tables stat -{% endif %} -JOIN - pg_catalog.pg_statio_all_tables statio ON stat.relid = statio.relid -JOIN - pg_catalog.pg_class cl ON cl.oid=stat.relid -WHERE - stat.relid = {{ tid }}::oid diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/create.sql deleted file mode 100644 index 0911420cf..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/create.sql +++ /dev/null @@ -1,197 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'columns/macros/security.macros' as COLUMN_SECLABEL %} -{% import 'columns/macros/privilege.macros' as COLUMN_PRIVILEGE %} -{% import 'tables/sql/macros/constraints.macro' as CONSTRAINTS %} -{% import 'types/macros/get_full_type_sql_format.macros' as GET_TYPE %} -{#===========================================#} -{#====== MAIN TABLE TEMPLATE STARTS HERE ======#} -{#===========================================#} -{# - If user has not provided any details but only name then - add empty bracket with table name -#} -{% set empty_bracket = ""%} -{% if data.coll_inherits|length == 0 and data.columns|length == 0 and not data.typname and not data.like_relation and data.primary_key|length == 0 and data.unique_constraint|length == 0 and data.foreign_key|length == 0 and data.check_constraint|length == 0 and data.exclude_constraint|length == 0 %} -{% set empty_bracket = "\n(\n)"%} -{% endif %} -CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}} -{% if data.typname %} - OF {{ data.typname }} -{% endif %} -{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} -( -{% endif %} -{% if data.like_relation %} - LIKE {{ data.like_relation }}{% if data.like_default_value %} - - INCLUDING DEFAULTS{% endif %}{% if data.like_constraints %} - - INCLUDING CONSTRAINTS{% endif %}{% if data.like_indexes %} - - INCLUDING INDEXES{% endif %}{% if data.like_storage %} - - INCLUDING STORAGE{% endif %}{% if data.like_comments %} - - INCLUDING COMMENTS{% endif %}{% if data.columns|length > 0 %}, -{% endif %} - -{% endif %} -{### Add columns ###} -{% if data.columns and data.columns|length > 0 %} -{% for c in data.columns %} -{% if c.name and c.cltype %} - {% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' %} DEFAULT {{c.defval}}{% endif %} -{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} -{# Macro to render for constraints #} -{% if data.primary_key|length > 0 %}{% if data.columns|length > 0 %},{% endif %} -{{CONSTRAINTS.PRIMARY_KEY(conn, data.primary_key[0])}}{% endif %}{% if data.unique_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 %},{% endif %} -{{CONSTRAINTS.UNIQUE(conn, data.unique_constraint)}}{% endif %}{% if data.foreign_key|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 %},{% endif %} -{{CONSTRAINTS.FOREIGN_KEY(conn, data.foreign_key)}}{% endif %}{% if data.check_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 %},{% endif %} -{{CONSTRAINTS.CHECK(conn, data.check_constraint)}}{% endif %}{% if data.exclude_constraint|length > 0 %}{% if data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 %},{% endif %} -{{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %} -{% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} - -){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }} {% endif %} - -{### If we are inheriting it from another table(s) ###} -{% if data.coll_inherits %} - INHERITS ({% for val in data.coll_inherits %}{% if loop.index != 1 %}, {% endif %}{{val}}{% endfor %}) -{% endif %} -WITH ( - OIDS = {% if data.relhasoids %}TRUE{% else %}FALSE{% endif %}{% if data.fillfactor %}, - FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.parallel_workers is defined and data.parallel_workers != '' and data.parallel_workers != None %}, - parallel_workers = {{ data.parallel_workers }}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %}, - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% endif %}{% if data.toast_autovacuum_enabled in ('t', 'f') %}, - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %} -{% endif %}{% if data.autovacuum_custom and data.vacuum_table|length > 0 %} -{% for opt in data.vacuum_table %}{% if opt.name and opt.value is defined %} -, - {{opt.name}} = {{opt.value}}{% endif %} -{% endfor %}{% endif %}{% if data.toast_autovacuum and data.vacuum_toast|length > 0 %} -{% for opt in data.vacuum_toast %}{% if opt.name and opt.value is defined %} -, - toast.{{opt.name}} = {{opt.value}}{% endif %} -{% endfor %}{% endif %} - -{### SQL for Tablespace ###} -{% if data.spcname %} -) -TABLESPACE {{ conn|qtIdent(data.spcname) }}; -{% else %} -); -{% endif %} -{### Alter SQL for Owner ###} -{% if data.relowner %} - -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - OWNER to {{conn|qtIdent(data.relowner)}}; -{% endif %} - - -{#####################################################} -{## Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.rlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ENABLE ROW LEVEL SECURITY; -{% endif %} - -{#####################################################} -{## Force Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.forcerlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - FORCE ROW LEVEL SECURITY; -{% endif %} - -{### Security Labels on Table ###} -{% if data.seclabels and data.seclabels|length > 0 %} - -{% for r in data.seclabels %} -{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{### ACL on Table ###} -{% if data.revoke_all %} -{% for priv in data.revoke_all %} -{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}} -{% endfor %} -{% endif %} -{% if data.relacl %} - -{% for priv in data.relacl %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{### SQL for COMMENT ###} -{% if data.description %} -COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} - IS {{data.description|qtLiteral}}; -{% endif %} -{#===========================================#} -{#====== MAIN TABLE TEMPLATE ENDS HERE ======#} -{#===========================================#} -{#===========================================#} -{# COLUMN SPECIFIC TEMPLATES STARTS HERE #} -{#===========================================#} -{% if data.columns and data.columns|length > 0 %} -{% for c in data.columns %} -{% if c.description %} - -COMMENT ON COLUMN {{conn|qtIdent(data.schema, data.name, c.name)}} - IS {{c.description|qtLiteral}}; -{% endif %} -{### Add variables to column ###} -{% if c.attoptions and c.attoptions|length > 0 %} - -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - {{ VARIABLE.SET(conn, 'COLUMN', c.name, c.attoptions) }} - -{% endif %} -{### Alter column statistics value ###} -{% if c.attstattarget is defined and c.attstattarget > -1 %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STATISTICS {{c.attstattarget}}; - -{% endif %} -{### Alter column storage value ###} -{% if c.attstorage is defined and c.attstorage != c.defaultstorage %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ALTER COLUMN {{conn|qtTypeIdent(c.name)}} SET STORAGE {%if c.attstorage == 'p' %} -PLAIN{% elif c.attstorage == 'm'%}MAIN{% elif c.attstorage == 'e'%} -EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% endif %}; - -{% endif %} -{### ACL ###} -{% if c.attacl and c.attacl|length > 0 %} - -{% for priv in c.attacl %} - {{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{### Security Lables ###} -{% if c.seclabels and c.seclabels|length > 0 %} - -{% for r in c.seclabels %} -{{ COLUMN_SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% endfor %} -{% endif %} -{#===========================================#} -{# COLUMN SPECIFIC TEMPLATES ENDS HERE #} -{#===========================================#} -{#======================================#} -{# CONSTRAINTS SPECIFIC TEMPLATES #} -{#======================================#} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.primary_key)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.unique_constraint)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.foreign_key)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.check_constraint)}} -{{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.exclude_constraint)}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/properties.sql deleted file mode 100644 index b53de46ab..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/properties.sql +++ /dev/null @@ -1,64 +0,0 @@ -SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE - (SELECT sp.spcname FROM pg_catalog.pg_database dtb - JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid - WHERE dtb.oid = {{ did }}::oid) - END) as spcname, - (select nspname FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid ) as schema, - pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, - rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey, - EXISTS(select 1 FROM pg_catalog.pg_trigger - JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger' - JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion' - WHERE tgrelid=rel.oid) AS isrepl, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount, - (SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN - pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname) - ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS coll_inherits, - (SELECT count(*) - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, - (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'parallel_workers=([0-9]*)') AS parallel_workers, - (substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, - rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, - CASE WHEN typ.typname IS NOT NULL THEN (select pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid )||'.'||pg_catalog.quote_ident(typ.typname) ELSE typ.typname END AS typname, - typ.typrelid AS typoid,rel.relrowsecurity as rlspolicy, rel.relforcerowsecurity as forcerlspolicy, - (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, - (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table -FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid -WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid -{% if tid %} AND rel.oid = {{ tid }}::oid {% endif %} -ORDER BY rel.relname; 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 deleted file mode 100644 index cac02fc90..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/9.6_plus/update.sql +++ /dev/null @@ -1,274 +0,0 @@ -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% import 'macros/variable.macros' as VARIABLE %} -{#####################################################} -{## Rename table ##} -{#####################################################} -{% if data.name and data.name != o_data.name %} -ALTER TABLE IF EXISTS {{conn|qtIdent(o_data.schema, o_data.name)}} - RENAME TO {{conn|qtIdent(data.name)}}; - -{% endif %} -{#####################################################} -{## Change table schema ##} -{#####################################################} -{% if data.schema and data.schema != o_data.schema %} -ALTER TABLE IF EXISTS {{conn|qtIdent(o_data.schema, data.name)}} - SET SCHEMA {{conn|qtIdent(data.schema)}}; - -{% endif %} -{#####################################################} -{## Change table owner ##} -{#####################################################} -{% if data.relowner and data.relowner != o_data.relowner %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - OWNER TO {{conn|qtIdent(data.relowner)}}; - -{% endif %} -{#####################################################} -{## Update Inherits table definition ##} -{#####################################################} -{% if data.coll_inherits_added|length > 0 %} -{% for val in data.coll_inherits_added %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - INHERIT {{val}}; - -{% endfor %} -{% endif %} -{% if data.coll_inherits_removed|length > 0 %} -{% for val in data.coll_inherits_removed %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - NO INHERIT {{val}}; - -{% endfor %} -{% endif %} - -{#####################################################} -{## Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.rlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ENABLE ROW LEVEL SECURITY; -{% elif data.rlspolicy is defined and data.rlspolicy != o_data.rlspolicy%} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - DISABLE ROW LEVEL SECURITY; - -{% endif %} - -{#####################################################} -{## Force Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.forcerlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - FORCE ROW LEVEL SECURITY; -{% elif data.forcerlspolicy is defined and data.forcerlspolicy != o_data.forcerlspolicy%} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - NO FORCE ROW LEVEL SECURITY; - -{% endif %} - -{#####################################################} -{## Change hasOID attribute of table ##} -{#####################################################} -{% if data.relhasoids is defined and data.relhasoids != o_data.relhasoids %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - SET {% if data.relhasoids %}WITH{% else %}WITHOUT{% endif %} OIDS; - -{% endif %} -{#####################################################} -{## Change tablespace ##} -{#####################################################} -{% if data.spcname and data.spcname != o_data.spcname %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - SET TABLESPACE {{conn|qtIdent(data.spcname)}}; - -{% endif %} -{#####################################################} -{## change fillfactor settings ##} -{#####################################################} -{% if data.fillfactor and data.fillfactor != o_data.fillfactor %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - SET (FILLFACTOR={{data.fillfactor}}); -{% elif (data.fillfactor == '' or data.fillfactor == None) and data.fillfactor != o_data.fillfactor %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - RESET (FILLFACTOR); - -{% endif %} - -{## change parallel_workers settings ##} -{#####################################################} -{% if (data.parallel_workers == '' or data.parallel_workers == None) and data.parallel_workers != o_data.parallel_workers %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - RESET (parallel_workers); -{% elif data.parallel_workers is defined and data.parallel_workers != o_data.parallel_workers %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - SET (parallel_workers={{data.parallel_workers}}); - -{% endif %} -{###############################} -{## Table AutoVacuum settings ##} -{###############################} -{% if data.vacuum_table is defined and data.vacuum_table.set_values|length > 0 %} -{% set has_vacuum_set = true %} -{% endif %} -{% if data.vacuum_table is defined and data.vacuum_table.reset_values|length > 0 %} -{% set has_vacuum_reset = true %} -{% endif %} -{% if o_data.autovacuum_custom and data.autovacuum_custom == false %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( - autovacuum_enabled, - autovacuum_analyze_scale_factor, - autovacuum_analyze_threshold, - autovacuum_freeze_max_age, - autovacuum_vacuum_cost_delay, - autovacuum_vacuum_cost_limit, - autovacuum_vacuum_scale_factor, - autovacuum_vacuum_threshold, - autovacuum_freeze_min_age, - autovacuum_freeze_table_age -); -{% else %} -{% if (data.autovacuum_enabled in ('t', 'f') and data.autovacuum_enabled != o_data.autovacuum_enabled) or has_vacuum_set %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} SET ( -{% if data.autovacuum_enabled in ('t', 'f') and data.autovacuum_enabled != o_data.autovacuum_enabled %} - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}true{% else %}false{% endif %}{% if has_vacuum_set %}, -{% endif %} -{% endif %} -{% if has_vacuum_set %} -{% for opt in data.vacuum_table.set_values %}{% if opt.name and opt.value is defined %} - {{opt.name}} = {{opt.value}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% if (data.autovacuum_enabled == 'x' and data.autovacuum_enabled != o_data.autovacuum_enabled) or has_vacuum_reset %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( -{% if data.autovacuum_enabled =='x' and data.autovacuum_enabled != o_data.autovacuum_enabled %} - autovacuum_enabled{% if has_vacuum_reset %}, -{% endif %} -{% endif %} -{% if has_vacuum_reset %} -{% for opt in data.vacuum_table.reset_values %}{% if opt.name %} - {{opt.name}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% endif %} -{#####################################} -{## Toast table AutoVacuum settings ##} -{#####################################} -{% if data.vacuum_toast is defined and data.vacuum_toast.set_values|length > 0 %} -{% set has_vacuum_toast_set = true %} -{% endif %} -{% if data.vacuum_toast is defined and data.vacuum_toast.reset_values|length > 0 %} -{% set has_vacuum_toast_reset = true %} -{% endif %} -{% if o_data.toast_autovacuum and data.toast_autovacuum == false %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( - toast.autovacuum_enabled, - toast.autovacuum_freeze_max_age, - toast.autovacuum_vacuum_cost_delay, - toast.autovacuum_vacuum_cost_limit, - toast.autovacuum_vacuum_scale_factor, - toast.autovacuum_vacuum_threshold, - toast.autovacuum_freeze_min_age, - toast.autovacuum_freeze_table_age, - toast.autovacuum_analyze_threshold, - toast.autovacuum_analyze_scale_factor -); -{% else %} -{% if (data.toast_autovacuum_enabled in ('t', 'f') and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled) or has_vacuum_toast_set %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} SET ( -{% if data.toast_autovacuum_enabled in ('t', 'f') and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled %} - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}true{% else %}false{% endif %}{% if has_vacuum_toast_set %}, -{% endif %} -{% endif %} -{% if has_vacuum_toast_set %} -{% for opt in data.vacuum_toast.set_values %}{% if opt.name and opt.value is defined %} - toast.{{opt.name}} = {{opt.value}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% if (data.toast_autovacuum_enabled == 'x' and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled) or has_vacuum_toast_reset %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( -{% if data.toast_autovacuum_enabled == 'x' and data.toast_autovacuum_enabled != o_data.toast_autovacuum_enabled %} - toast.autovacuum_enabled{% if has_vacuum_toast_reset %}, -{% endif %} -{% endif %} -{% if has_vacuum_toast_reset %} -{% for opt in data.vacuum_toast.reset_values %}{% if opt.name %} - toast.{{opt.name}}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} -{% endif %} - -); -{% endif %} -{% endif %} -{#####################################################} -{## Change table comments ##} -{#####################################################} -{% if data.description is defined and data.description != o_data.description %} -COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} - IS {{data.description|qtLiteral}}; - -{% endif %} -{#####################################################} -{## Update table Privileges ##} -{#####################################################} -{% if data.relacl %} -{% if 'deleted' in data.relacl %} -{% for priv in data.relacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.relacl %} -{% for priv in data.relacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{#####################################################} -{## Update table SecurityLabel ##} -{#####################################################} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'TABLE', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/acl.sql index 8cb9d5728..7c2e6d9d3 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/acl.sql @@ -1,35 +1,46 @@ -SELECT 'relacl' as deftype, COALESCE(privileges_information.grantee, 'PUBLIC') grantee, privileges_information.grantor, +{### SQL to fetch privileges for tablespace ###} +SELECT 'relacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(privilege_type) as privileges, pg_catalog.array_agg(is_grantable) as grantable -from ( - SELECT - acls.grantee, acls.grantor, CASE WHEN acls.is_grantable = 'YES' THEN TRUE ELSE FALSE END as is_grantable, - CASE acls.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT rel.relacl, rel.relname - FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid - AND rel.oid = {{ tid }}::OID - ) rel - LEFT JOIN information_schema.table_privileges acls ON (table_name = rel.relname) -) as privileges_information - - -GROUP BY privileges_information.grantee,privileges_information.grantor -ORDER BY privileges_information.grantee +FROM + (SELECT + d.grantee, d.grantor, d.is_grantable, + CASE d.privilege_type + WHEN 'CONNECT' THEN 'c' + WHEN 'CREATE' THEN 'C' + WHEN 'DELETE' THEN 'd' + WHEN 'EXECUTE' THEN 'X' + WHEN 'INSERT' THEN 'a' + WHEN 'REFERENCES' THEN 'x' + WHEN 'SELECT' THEN 'r' + WHEN 'TEMPORARY' THEN 'T' + WHEN 'TRIGGER' THEN 't' + WHEN 'TRUNCATE' THEN 'D' + WHEN 'UPDATE' THEN 'w' + WHEN 'USAGE' THEN 'U' + ELSE 'UNKNOWN' + END AS privilege_type + FROM + (SELECT rel.relacl + FROM pg_catalog.pg_class rel + LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace + LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' + LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid + LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid + WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid + AND rel.oid = {{ tid }}::oid + ) acl, + (SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable + AS is_grantable, (d).privilege_type AS privilege_type FROM (SELECT + aclexplode(rel.relacl) as d + FROM pg_catalog.pg_class rel + LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace + LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' + LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid + LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid + WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid + AND rel.oid = {{ tid }}::oid + ) a ORDER BY privilege_type) d + ) d + LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) + LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) +GROUP BY g.rolname, gt.rolname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/create.sql index 32caa5c8f..c1eaedf7e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/create.sql @@ -43,6 +43,18 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists {% for c in data.columns %} {% if c.name and c.cltype %} {% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}: {% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}: {% endif %}{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval is defined and c.defval is not none and c.defval != '' %} DEFAULT {{c.defval}}{% endif %} +{% if c.colconstype == 'i' and c.attidentity and c.attidentity != '' %} +{% if c.attidentity == 'a' %} GENERATED ALWAYS AS IDENTITY{% elif c.attidentity == 'd' %} GENERATED BY DEFAULT AS IDENTITY{% endif %} +{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %} ( {% endif %} +{% if c.seqcycle is defined and c.seqcycle %} +CYCLE {% endif %}{% if c.seqincrement is defined and c.seqincrement|int(-1) > -1 %} +INCREMENT {{c.seqincrement|int}} {% endif %}{% if c.seqstart is defined and c.seqstart|int(-1) > -1%} +START {{c.seqstart|int}} {% endif %}{% if c.seqmin is defined and c.seqmin|int(-1) > -1%} +MINVALUE {{c.seqmin|int}} {% endif %}{% if c.seqmax is defined and c.seqmax|int(-1) > -1%} +MAXVALUE {{c.seqmax|int}} {% endif %}{% if c.seqcache is defined and c.seqcache|int(-1) > -1%} +CACHE {{c.seqcache|int}} {% endif %} +{% if c.seqincrement or c.seqcycle or c.seqincrement or c.seqstart or c.seqmin or c.seqmax or c.seqcache %}){% endif %} +{% endif %} {% if not loop.last %}, {% endif %} {% endif %} @@ -57,7 +69,7 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists {{CONSTRAINTS.EXCLUDE(conn, data.exclude_constraint)}}{% endif %} {% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %} -){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }} {% endif %} +){% endif %}{% if data.relkind is defined and data.relkind == 'p' %} PARTITION BY {{ data.partition_scheme }}{% endif %} {### If we are inheriting it from another table(s) ###} {% if data.coll_inherits %} @@ -65,7 +77,8 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE{% if add_not_exists {% endif %} WITH ( OIDS = {% if data.relhasoids %}TRUE{% else %}FALSE{% endif %}{% if data.fillfactor %}, - FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %}, + FILLFACTOR = {{ data.fillfactor }}{% endif %}{% if data.parallel_workers is defined and data.parallel_workers != '' and data.parallel_workers != None %}, + parallel_workers = {{ data.parallel_workers }}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %}, autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% endif %}{% if data.toast_autovacuum_enabled in ('t', 'f') %}, toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %} {% endif %}{% if data.autovacuum_custom and data.vacuum_table|length > 0 %} @@ -91,6 +104,23 @@ TABLESPACE {{ conn|qtIdent(data.spcname) }}; ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} OWNER to {{conn|qtIdent(data.relowner)}}; {% endif %} + +{#####################################################} +{## Enable Row Level Security Policy on table ##} +{#####################################################} +{% if data.rlspolicy %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + ENABLE ROW LEVEL SECURITY; +{% endif %} + +{#####################################################} +{## Force Enable Row Level Security Policy on table ##} +{#####################################################} +{% if data.forcerlspolicy %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + FORCE ROW LEVEL SECURITY; +{% endif %} + {### Security Labels on Table ###} {% if data.seclabels and data.seclabels|length > 0 %} @@ -99,6 +129,11 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} {% endfor %} {% endif %} {### ACL on Table ###} +{% if data.revoke_all %} +{% for priv in data.revoke_all %} +{{ PRIVILEGE.UNSETALL(conn, "TABLE", priv, data.name, data.schema)}} +{% endfor %} +{% endif %} {% if data.relacl %} {% for priv in data.relacl %} @@ -148,7 +183,7 @@ EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% endif %}; {% if c.attacl and c.attacl|length > 0 %} {% for priv in c.attacl %} - {{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }} +{{ COLUMN_PRIVILEGE.APPLY(conn, data.schema, data.name, c.name, priv.grantee, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} {### Security Lables ###} @@ -171,18 +206,3 @@ EXTERNAL{% elif c.attstorage == 'x'%}EXTENDED{% endif %}; {{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.foreign_key)}} {{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.check_constraint)}} {{CONSTRAINTS.CONSTRAINT_COMMENTS(conn, data.schema, data.name, data.exclude_constraint)}} -{#####################################################} -{## Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.rlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - ENABLE ROW LEVEL SECURITY; -{% endif %} - -{#####################################################} -{## Force Enable Row Level Security Policy on table ##} -{#####################################################} -{% if data.forcerlspolicy %} -ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} - FORCE ROW LEVEL SECURITY; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_columns_for_table.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_columns_for_table.sql index 6cad94f31..2bb034c13 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_columns_for_table.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_columns_for_table.sql @@ -1,6 +1,6 @@ SELECT a.attname AS name, pg_catalog.format_type(a.atttypid, NULL) AS cltype, - pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, + pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval, a.attidentity as clidentity, pg_catalog.quote_ident(n.nspname)||'.'||pg_catalog.quote_ident(c.relname) as inheritedfrom, c.oid as inheritedid FROM diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_inherits.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_inherits.sql index 664406340..2e5df5f8f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_inherits.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_inherits.sql @@ -7,12 +7,11 @@ END AS inherits FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace -WHERE relkind='r' +WHERE relkind='r' AND NOT relispartition {% if not show_system_objects %} {{ CATALOG.VALID_CATALOGS(server_type) }} {% endif %} {% if tid %} AND c.oid != tid {% endif %} -AND c.relnamespace = {{ scid }} ORDER BY relnamespace, c.relname diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_oid.sql index 2477a5f00..97ab5fef5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_oid.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_oid.sql @@ -1,5 +1,5 @@ SELECT rel.oid as tid FROM pg_catalog.pg_class rel -WHERE rel.relkind IN ('r','s','t') +WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid AND rel.relname = {{data.name|qtLiteral}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_table.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_table.sql index 4b91526f4..df88c4791 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_table.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/get_table.sql @@ -3,6 +3,6 @@ SELECT FROM pg_catalog.pg_class rel WHERE - rel.relkind IN ('r','s','t') + rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid AND rel.oid = {{ tid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql index 6c20a8fa5..75ffacabf 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/nodes.sql @@ -1,9 +1,15 @@ SELECT rel.oid, rel.relname AS name, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid) AS triggercount, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgenabled = 'O') AS has_enable_triggers, + (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount, + (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers, + (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned, (SELECT count(1) FROM pg_catalog.pg_inherits WHERE inhrelid=rel.oid LIMIT 1) as is_inherits, (SELECT count(1) FROM pg_catalog.pg_inherits WHERE inhparent=rel.oid LIMIT 1) as is_inherited FROM pg_catalog.pg_class rel - WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }}::oid + WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid + AND NOT rel.relispartition {% if tid %} AND rel.oid = {{tid}}::OID {% endif %} +{% if schema_diff %} + AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = rel.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END +{% endif %} ORDER BY rel.relname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/properties.sql index 25c4e84c9..47e9a75dc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/properties.sql @@ -1,67 +1,74 @@ -SELECT *, - (CASE when pre_coll_inherits is NULL then ARRAY[]::varchar[] else pre_coll_inherits END) as coll_inherits -FROM ( - SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE - (SELECT sp.spcname FROM pg_catalog.pg_database dtb - JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid - WHERE dtb.oid = {{ did }}::oid) - END) as spcname, - (select nspname FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid ) as schema, - pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, - rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey, - EXISTS(select 1 FROM pg_catalog.pg_trigger - JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger' - JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion' - WHERE tgrelid=rel.oid) AS isrepl, - (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid) AS triggercount, - (SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN - pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname) - ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS pre_coll_inherits, - (SELECT count(*) - FROM pg_catalog.pg_inherits i - JOIN pg_catalog.pg_class c ON c.oid = i.inhparent - JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace - WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, - false AS relpersistence, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, - rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, NULL AS reloftype, NULL AS typname, - typ.typrelid AS typoid, rel.relrowsecurity as rlspolicy, rel.relforcerowsecurity as forcerlspolicy, - (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, - ARRAY[]::varchar[] AS seclabels, - (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table - - FROM pg_catalog.pg_class rel - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass) - LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' - LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid - - WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = {{ scid }} - {% if tid %} AND rel.oid = {{ tid }}::oid {% endif %} -) AS TableInformation - ORDER BY name +SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str, + (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE + (SELECT sp.spcname FROM pg_catalog.pg_database dtb + JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid + WHERE dtb.oid = {{ did }}::oid) + END) as spcname, + (CASE rel.relreplident + WHEN 'd' THEN 'default' + WHEN 'n' THEN 'nothing' + WHEN 'f' THEN 'full' + WHEN 'i' THEN 'index' + END) as replica_identity, + (select nspname FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid ) as schema, + pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, rel.relkind, + (CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned, + rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey, + EXISTS(select 1 FROM pg_catalog.pg_trigger + JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger' + JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion' + WHERE tgrelid=rel.oid) AS isrepl, + (SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount, + (SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN + pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname) + ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables + FROM pg_catalog.pg_inherits i + JOIN pg_catalog.pg_class c ON c.oid = i.inhparent + JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace + WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS coll_inherits, + (SELECT count(*) + FROM pg_catalog.pg_inherits i + JOIN pg_catalog.pg_class c ON c.oid = i.inhparent + JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace + WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, + (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'parallel_workers=([0-9]*)') AS parallel_workers, + (substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, + substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, + (substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age, + substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, + rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, + CASE WHEN typ.typname IS NOT NULL THEN (select pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace WHERE oid = {{scid}}::oid )||'.'||pg_catalog.quote_ident(typ.typname) ELSE typ.typname END AS typname, + typ.typrelid AS typoid, rel.relrowsecurity as rlspolicy, rel.relforcerowsecurity as forcerlspolicy, + (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, + (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, + (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table + -- Added for partition table + {% if tid %}, (CASE WHEN rel.relkind = 'p' THEN pg_catalog.pg_get_partkeydef({{ tid }}::oid) ELSE '' END) AS partition_scheme {% endif %} +FROM pg_catalog.pg_class rel + LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace + LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass) + LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p' + LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid + LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid +WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = {{ scid }}::oid +AND NOT rel.relispartition +{% if tid %} AND rel.oid = {{ tid }}::oid {% endif %} +ORDER BY rel.relname; 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 7ba883b7a..fb1ffda31 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 @@ -126,6 +126,28 @@ ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} RESET ( {% endif %} {% endif %} +{#####################################################} +{## Enable Row Level Security Policy on table ##} +{#####################################################} +{% if data.rlspolicy %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + ENABLE ROW LEVEL SECURITY; +{% elif data.rlspolicy is defined and data.rlspolicy != o_data.rlspolicy%} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + DISABLE ROW LEVEL SECURITY; + +{% endif %} + +{#####################################################} +{## Force Enable Row Level Security Policy on table ##} +{#####################################################} +{% if data.forcerlspolicy %} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + FORCE ROW LEVEL SECURITY; +{% elif data.forcerlspolicy is defined and data.forcerlspolicy != o_data.forcerlspolicy%} +ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} + NO FORCE ROW LEVEL SECURITY; +{% endif %} {#####################################} {## Toast table AutoVacuum settings ##} @@ -245,4 +267,3 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}} {% if data.replica_identity and data.replica_identity != o_data.replica_identity %} ALTER TABLE IF EXISTS {{conn|qtIdent(data.schema, data.name)}} REPLICA IDENTITY {{data.replica_identity }}; {% endif %} - diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/10_plus/create.sql deleted file mode 100644 index 7676c1332..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/10_plus/create.sql +++ /dev/null @@ -1,37 +0,0 @@ -{### Set a flag which allows us to put OR between events ###} -{% set or_flag = False %} -{% if data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL' %} -CREATE OR REPLACE TRIGGER {{ conn|qtIdent(data.name) }} -{% else %} -CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn|qtIdent(data.name) }} -{% endif %} - {{data.fires}} {% if data.evnt_insert %}INSERT{% set or_flag = True %} -{% endif %}{% if data.evnt_delete %} -{% if or_flag %} OR {% endif %}DELETE{% set or_flag = True %} -{% endif %}{% if data.evnt_truncate %} -{% if or_flag %} OR {% endif %}TRUNCATE{% set or_flag = True %} -{% endif %}{% if data.evnt_update %} -{% if or_flag %} OR {% endif %}UPDATE {% if data.columns|length > 0 %}OF {% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{{ conn|qtIdent(c) }}{% endfor %}{% endif %} -{% endif %} - - ON {{ conn|qtIdent(data.schema, data.table) }} -{% if data.tgdeferrable %} - DEFERRABLE{% if data.tginitdeferred %} INITIALLY DEFERRED{% endif %} - -{% endif %} -{% if data.tgoldtable or data.tgnewtable %} - REFERENCING{% if data.tgnewtable %} NEW TABLE AS {{ conn|qtIdent(data.tgnewtable) }}{% endif %}{% if data.tgoldtable %} OLD TABLE AS {{ conn|qtIdent(data.tgoldtable) }}{% endif %} - -{% endif %} - FOR EACH{% if data.is_row_trigger %} ROW{% else %} STATEMENT{% endif %} -{% if data.whenclause %} - - WHEN {% if not data.oid %}({% endif %}{{ data.whenclause }}{% if not data.oid %}){% endif %}{% endif %} - - {% if data.prosrc is defined and - (data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL') %}{{ data.prosrc }}{% else %}EXECUTE PROCEDURE {{ data.tfunction }}{% if data.tgargs %}({{ data.tgargs }}){% else %}(){% endif%}{% endif%}; - -{% if data.description %} -COMMENT ON TRIGGER {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }} - IS {{data.description|qtLiteral}}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/10_plus/properties.sql deleted file mode 100644 index 48dbeffc1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/10_plus/properties.sql +++ /dev/null @@ -1,24 +0,0 @@ -SELECT t.oid,t.tgname AS name, t.xmin, t.tgenabled AS is_enable_trigger, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, - nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, - COALESCE(pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) EXECUTE (PROCEDURE|FUNCTION)'), - pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) \$trigger')) AS whenclause, - -- We need to convert tgargs column bytea datatype to array datatype - (pg_catalog.string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, -{% if datlastsysoid %} - (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, -{% endif %} - (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger, - tgoldtable, - tgnewtable -FROM pg_catalog.pg_trigger t - JOIN pg_catalog.pg_class cl ON cl.oid=tgrelid - JOIN pg_catalog.pg_namespace na ON na.oid=relnamespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) - LEFT OUTER JOIN pg_catalog.pg_proc p ON p.oid=t.tgfoid - LEFT OUTER JOIN pg_catalog.pg_language l ON l.oid=p.prolang -WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID -{% if trid %} - AND t.oid = {{trid}}::OID -{% endif %} -ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/get_oid.sql deleted file mode 100644 index fcaddc964..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/get_oid.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT t.oid -FROM pg_catalog.pg_trigger t - WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID - AND tgname = {{data.name|qtLiteral}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/nodes.sql deleted file mode 100644 index 20e9e6aef..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/nodes.sql +++ /dev/null @@ -1,12 +0,0 @@ -SELECT t.oid, t.tgname as name, t.tgenabled AS is_enable_trigger -FROM pg_catalog.pg_trigger t - WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID -{% if trid %} - AND t.oid = {{trid}}::OID -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} - ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/properties.sql deleted file mode 100644 index 4181ce250..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/properties.sql +++ /dev/null @@ -1,22 +0,0 @@ -SELECT t.oid,t.tgname AS name, t.xmin, t.tgenabled AS is_enable_trigger, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, - nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, - COALESCE(pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) EXECUTE PROCEDURE'), - pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) \$trigger')) AS whenclause, - -- We need to convert tgargs column bytea datatype to array datatype - (pg_catalog.string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, -{% if datlastsysoid %} - (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, -{% endif %} - (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger -FROM pg_catalog.pg_trigger t - JOIN pg_catalog.pg_class cl ON cl.oid=tgrelid - JOIN pg_catalog.pg_namespace na ON na.oid=relnamespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) - LEFT OUTER JOIN pg_catalog.pg_proc p ON p.oid=t.tgfoid - LEFT OUTER JOIN pg_catalog.pg_language l ON l.oid=p.prolang -WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID -{% if trid %} - AND t.oid = {{trid}}::OID -{% endif %} -ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/create.sql index bd571145e..7676c1332 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/create.sql @@ -18,6 +18,10 @@ CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn| {% if data.tgdeferrable %} DEFERRABLE{% if data.tginitdeferred %} INITIALLY DEFERRED{% endif %} +{% endif %} +{% if data.tgoldtable or data.tgnewtable %} + REFERENCING{% if data.tgnewtable %} NEW TABLE AS {{ conn|qtIdent(data.tgnewtable) }}{% endif %}{% if data.tgoldtable %} OLD TABLE AS {{ conn|qtIdent(data.tgoldtable) }}{% endif %} + {% endif %} FOR EACH{% if data.is_row_trigger %} ROW{% else %} STATEMENT{% endif %} {% if data.whenclause %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/get_function_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/get_function_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/9.1_plus/get_function_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/get_function_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/get_oid.sql index ff66a7f27..fcaddc964 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/get_oid.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/get_oid.sql @@ -1,4 +1,5 @@ SELECT t.oid FROM pg_catalog.pg_trigger t - WHERE tgrelid = {{tid}}::OID + WHERE NOT tgisinternal + AND tgrelid = {{tid}}::OID AND tgname = {{data.name|qtLiteral}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/nodes.sql index 7bfa00834..20e9e6aef 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/nodes.sql @@ -1,7 +1,12 @@ SELECT t.oid, t.tgname as name, t.tgenabled AS is_enable_trigger FROM pg_catalog.pg_trigger t - WHERE tgrelid = {{tid}}::OID + WHERE NOT tgisinternal + AND tgrelid = {{tid}}::OID {% if trid %} AND t.oid = {{trid}}::OID +{% endif %} +{% if schema_diff %} + AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END {% endif %} ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/properties.sql index 9af811859..48dbeffc1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/pg/default/properties.sql @@ -1 +1,24 @@ -SELECT 1 WHERE 1 = 2; +SELECT t.oid,t.tgname AS name, t.xmin, t.tgenabled AS is_enable_trigger, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, + nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, + COALESCE(pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) EXECUTE (PROCEDURE|FUNCTION)'), + pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) \$trigger')) AS whenclause, + -- We need to convert tgargs column bytea datatype to array datatype + (pg_catalog.string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, +{% if datlastsysoid %} + (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, +{% endif %} + (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger, + tgoldtable, + tgnewtable +FROM pg_catalog.pg_trigger t + JOIN pg_catalog.pg_class cl ON cl.oid=tgrelid + JOIN pg_catalog.pg_namespace na ON na.oid=relnamespace + LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) + LEFT OUTER JOIN pg_catalog.pg_proc p ON p.oid=t.tgfoid + LEFT OUTER JOIN pg_catalog.pg_language l ON l.oid=p.prolang +WHERE NOT tgisinternal + AND tgrelid = {{tid}}::OID +{% if trid %} + AND t.oid = {{trid}}::OID +{% endif %} +ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/10_plus/create.sql deleted file mode 100644 index 7676c1332..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/10_plus/create.sql +++ /dev/null @@ -1,37 +0,0 @@ -{### Set a flag which allows us to put OR between events ###} -{% set or_flag = False %} -{% if data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL' %} -CREATE OR REPLACE TRIGGER {{ conn|qtIdent(data.name) }} -{% else %} -CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn|qtIdent(data.name) }} -{% endif %} - {{data.fires}} {% if data.evnt_insert %}INSERT{% set or_flag = True %} -{% endif %}{% if data.evnt_delete %} -{% if or_flag %} OR {% endif %}DELETE{% set or_flag = True %} -{% endif %}{% if data.evnt_truncate %} -{% if or_flag %} OR {% endif %}TRUNCATE{% set or_flag = True %} -{% endif %}{% if data.evnt_update %} -{% if or_flag %} OR {% endif %}UPDATE {% if data.columns|length > 0 %}OF {% for c in data.columns %}{% if loop.index != 1 %}, {% endif %}{{ conn|qtIdent(c) }}{% endfor %}{% endif %} -{% endif %} - - ON {{ conn|qtIdent(data.schema, data.table) }} -{% if data.tgdeferrable %} - DEFERRABLE{% if data.tginitdeferred %} INITIALLY DEFERRED{% endif %} - -{% endif %} -{% if data.tgoldtable or data.tgnewtable %} - REFERENCING{% if data.tgnewtable %} NEW TABLE AS {{ conn|qtIdent(data.tgnewtable) }}{% endif %}{% if data.tgoldtable %} OLD TABLE AS {{ conn|qtIdent(data.tgoldtable) }}{% endif %} - -{% endif %} - FOR EACH{% if data.is_row_trigger %} ROW{% else %} STATEMENT{% endif %} -{% if data.whenclause %} - - WHEN {% if not data.oid %}({% endif %}{{ data.whenclause }}{% if not data.oid %}){% endif %}{% endif %} - - {% if data.prosrc is defined and - (data.lanname == 'edbspl' or data.tfunction == 'Inline EDB-SPL') %}{{ data.prosrc }}{% else %}EXECUTE PROCEDURE {{ data.tfunction }}{% if data.tgargs %}({{ data.tgargs }}){% else %}(){% endif%}{% endif%}; - -{% if data.description %} -COMMENT ON TRIGGER {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(data.schema, data.table) }} - IS {{data.description|qtLiteral}}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/10_plus/properties.sql deleted file mode 100644 index 48dbeffc1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/10_plus/properties.sql +++ /dev/null @@ -1,24 +0,0 @@ -SELECT t.oid,t.tgname AS name, t.xmin, t.tgenabled AS is_enable_trigger, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, - nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, - COALESCE(pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) EXECUTE (PROCEDURE|FUNCTION)'), - pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) \$trigger')) AS whenclause, - -- We need to convert tgargs column bytea datatype to array datatype - (pg_catalog.string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, -{% if datlastsysoid %} - (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, -{% endif %} - (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger, - tgoldtable, - tgnewtable -FROM pg_catalog.pg_trigger t - JOIN pg_catalog.pg_class cl ON cl.oid=tgrelid - JOIN pg_catalog.pg_namespace na ON na.oid=relnamespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) - LEFT OUTER JOIN pg_catalog.pg_proc p ON p.oid=t.tgfoid - LEFT OUTER JOIN pg_catalog.pg_language l ON l.oid=p.prolang -WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID -{% if trid %} - AND t.oid = {{trid}}::OID -{% endif %} -ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/get_oid.sql deleted file mode 100644 index fcaddc964..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/get_oid.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT t.oid -FROM pg_catalog.pg_trigger t - WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID - AND tgname = {{data.name|qtLiteral}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/nodes.sql deleted file mode 100644 index 20e9e6aef..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/nodes.sql +++ /dev/null @@ -1,12 +0,0 @@ -SELECT t.oid, t.tgname as name, t.tgenabled AS is_enable_trigger -FROM pg_catalog.pg_trigger t - WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID -{% if trid %} - AND t.oid = {{trid}}::OID -{% endif %} -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} - ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/properties.sql deleted file mode 100644 index 79be092cb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/properties.sql +++ /dev/null @@ -1,22 +0,0 @@ -SELECT t.oid,t.tgname AS name, t.xmin, t.tgenabled AS is_enable_trigger, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, - nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, - COALESCE(substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) EXECUTE PROCEDURE'), - pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) \$trigger')) AS whenclause, - -- We need to convert tgargs column bytea datatype to array datatype - (pg_catalog.string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, -{% if datlastsysoid %} - (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, -{% endif %} - (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger -FROM pg_catalog.pg_trigger t - JOIN pg_catalog.pg_class cl ON cl.oid=tgrelid - JOIN pg_catalog.pg_namespace na ON na.oid=relnamespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) - LEFT OUTER JOIN pg_catalog.pg_proc p ON p.oid=t.tgfoid - LEFT OUTER JOIN pg_catalog.pg_language l ON l.oid=p.prolang -WHERE NOT tgisinternal - AND tgrelid = {{tid}}::OID -{% if trid %} - AND t.oid = {{trid}}::OID -{% endif %} -ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/create.sql index bd571145e..7676c1332 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/create.sql @@ -18,6 +18,10 @@ CREATE{% if data.is_constraint_trigger %} CONSTRAINT{% endif %} TRIGGER {{ conn| {% if data.tgdeferrable %} DEFERRABLE{% if data.tginitdeferred %} INITIALLY DEFERRED{% endif %} +{% endif %} +{% if data.tgoldtable or data.tgnewtable %} + REFERENCING{% if data.tgnewtable %} NEW TABLE AS {{ conn|qtIdent(data.tgnewtable) }}{% endif %}{% if data.tgoldtable %} OLD TABLE AS {{ conn|qtIdent(data.tgoldtable) }}{% endif %} + {% endif %} FOR EACH{% if data.is_row_trigger %} ROW{% else %} STATEMENT{% endif %} {% if data.whenclause %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/get_function_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/get_function_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/9.1_plus/get_function_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/get_function_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/get_oid.sql index ff66a7f27..fcaddc964 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/get_oid.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/get_oid.sql @@ -1,4 +1,5 @@ SELECT t.oid FROM pg_catalog.pg_trigger t - WHERE tgrelid = {{tid}}::OID + WHERE NOT tgisinternal + AND tgrelid = {{tid}}::OID AND tgname = {{data.name|qtLiteral}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/nodes.sql index 7bfa00834..20e9e6aef 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/nodes.sql @@ -1,7 +1,12 @@ SELECT t.oid, t.tgname as name, t.tgenabled AS is_enable_trigger FROM pg_catalog.pg_trigger t - WHERE tgrelid = {{tid}}::OID + WHERE NOT tgisinternal + AND tgrelid = {{tid}}::OID {% if trid %} AND t.oid = {{trid}}::OID +{% endif %} +{% if schema_diff %} + AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend + WHERE objid = t.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END {% endif %} ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/properties.sql index 9af811859..48dbeffc1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/triggers/sql/ppas/default/properties.sql @@ -1 +1,24 @@ -SELECT 1 WHERE 1 = 2; +SELECT t.oid,t.tgname AS name, t.xmin, t.tgenabled AS is_enable_trigger, t.*, relname, CASE WHEN relkind = 'r' THEN TRUE ELSE FALSE END AS parentistable, + nspname, des.description, l.lanname, p.prosrc, p.proname AS tfunction, + COALESCE(pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) EXECUTE (PROCEDURE|FUNCTION)'), + pg_catalog.substring(pg_catalog.pg_get_triggerdef(t.oid, true), 'WHEN (.*) \$trigger')) AS whenclause, + -- We need to convert tgargs column bytea datatype to array datatype + (pg_catalog.string_to_array(encode(tgargs, 'escape'), E'\\000')::text[])[1:tgnargs] AS custom_tgargs, +{% if datlastsysoid %} + (CASE WHEN t.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_trigger, +{% endif %} + (CASE WHEN tgconstraint != 0::OID THEN true ElSE false END) AS is_constraint_trigger, + tgoldtable, + tgnewtable +FROM pg_catalog.pg_trigger t + JOIN pg_catalog.pg_class cl ON cl.oid=tgrelid + JOIN pg_catalog.pg_namespace na ON na.oid=relnamespace + LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=t.oid AND des.classoid='pg_trigger'::regclass) + LEFT OUTER JOIN pg_catalog.pg_proc p ON p.oid=t.tgfoid + LEFT OUTER JOIN pg_catalog.pg_language l ON l.oid=p.prolang +WHERE NOT tgisinternal + AND tgrelid = {{tid}}::OID +{% if trid %} + AND t.oid = {{trid}}::OID +{% endif %} +ORDER BY tgname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/alter_table_with_toast_table.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/alter_table_with_toast_table.sql deleted file mode 100644 index 70c567d27..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/alter_table_with_toast_table.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Table: public.table_with_custom_autovaccum_$%{}[]()&*^!@"'`\/# - --- DROP TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#"; - -CREATE TABLE IF NOT EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" -( - col1 character varying(10)[] COLLATE pg_catalog."default", - col2 date -) -WITH ( - OIDS = FALSE, - toast.autovacuum_enabled = FALSE, - autovacuum_analyze_scale_factor = 0.2, - autovacuum_analyze_threshold = 60, - autovacuum_freeze_max_age = 20000000, - autovacuum_vacuum_cost_delay = 25, - autovacuum_vacuum_cost_limit = 100, - autovacuum_vacuum_scale_factor = 0.3, - autovacuum_vacuum_threshold = 60, - autovacuum_freeze_min_age = 500000, - autovacuum_freeze_table_age = 1300000, - toast.autovacuum_freeze_max_age = 2000000, - toast.autovacuum_vacuum_cost_delay = 50, - toast.autovacuum_vacuum_cost_limit = 13, - toast.autovacuum_vacuum_threshold = 70 -) -TABLESPACE pg_default; - -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" - OWNER to postgres; - -COMMENT ON TABLE public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" - IS 'custom auto vacuum'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/alter_table_with_toast_table_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/alter_table_with_toast_table_msql.sql deleted file mode 100644 index 89a93aceb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/alter_table_with_toast_table_msql.sql +++ /dev/null @@ -1,15 +0,0 @@ -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" SET ( - autovacuum_analyze_threshold = 60, - autovacuum_vacuum_cost_limit = 100 -); -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" RESET ( - autovacuum_enabled -); - -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" SET ( - toast.autovacuum_enabled = false, - toast.autovacuum_freeze_max_age = 2000000, - toast.autovacuum_vacuum_cost_delay = 50, - toast.autovacuum_vacuum_cost_limit = 13, - toast.autovacuum_vacuum_threshold = 70 -); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/test.json deleted file mode 100644 index e9020c2f8..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/test.json +++ /dev/null @@ -1,1947 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Table without primary key", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "boolean", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col4", - "cltype": "character varying", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 30, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col5", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": 20, - "attprecision": 10, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col6", - "cltype": "timestamp with time zone", - "attacl": [], - "min_val_attlen": 0, - "max_val_attlen": 6, - "is_primary_key": false, - "attnotnull": false, - "attlen": 5, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_without_primary_key.sql", - "expected_msql_file": "create_table_without_primary_key_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table to change column data types", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "cltype": "bigint" - }, - { - "attnum": 2, - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "cltype": "character varying" - }, - { - "attnum": 6, - "attlen": null, - "cltype": "time without time zone" - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_change_col_data_type.sql", - "expected_msql_file": "alter_table_change_col_data_type_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add pk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "attnotnull": true, - "is_primary_key": true - } - ] - }, - "primary_key": { - "added": [ - { - "columns": [ - { - "column": "col1" - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_pk_not_null_constraint.sql", - "expected_msql_file": "alter_table_add_pk_not_null_constraint_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add null constraint, rename column", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "name": "col1_rename", - "is_primary_key": false - }, - { - "attnum": 4, - "attnotnull": true - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_null_constraint_rename_col.sql", - "expected_msql_file": "alter_table_add_null_constraint_rename_col_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table add pk", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with primary key", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "integer", - "attacl": [], - "is_primary_key": true, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "json", - "attacl": [], - "is_primary_key": false, - "attnotnull": true, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_pk.sql", - "expected_msql_file": "create_table_with_pk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add columns", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "columns": { - "added": [ - { - "name": "col3_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": 5, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col4_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_cols.sql", - "expected_msql_file": "alter_table_add_cols_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete columns", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "columns": { - "deleted": [ - { - "attoptions": [], - "attacl": [], - "seclabels": [], - "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", - "atttypid": 114, - "attnum": 2, - "cltype": "json", - "collspcname": "", - "description": null, - "edit_types": [ - "json", - "jsonb" - ], - "is_primary_key": false, - "attstattarget": -1, - "attnotnull": true, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attndims": 0, - "atttypmod": -1, - "attstorage": "x", - "defval": null, - "typname": "json", - "displaytypname": "json", - "elemoid": 114, - "typnspname": "pg_catalog", - "defaultstorage": "x", - "indkey": "1", - "isdup": false, - "is_fk": false, - "is_sys_column": false, - "relname": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "is_view_only": false, - "is_pk": false, - "old_attidentity": "a" - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_delete_cols.sql", - "expected_msql_file": "alter_table_delete_cols_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table delete columns", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with pk & check constraint", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "create table comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [ - { - "name": "custom_pk", - "comment": "custom pk created", - "fillfactor": "11", - "condeferrable": true, - "condeferred": true, - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "time with time zone", - "attacl": [], - "min_val_attlen": 0, - "max_val_attlen": 6, - "is_primary_key": false, - "attnotnull": false, - "attlen": 5, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "character", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 12, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [ - { - "name": "chk_const", - "consrc": "col2 != null", - "convalidated": false, - "comment": "chk const comment" - } - ], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_pk_chk.sql", - "expected_msql_file": "create_table_with_pk_chk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add unique constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "unique_constraint": { - "added": [ - { - "name": "unique", - "fillfactor": "13", - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ] - } - }, - "expected_sql_file": "alter_table_add_unique_const.sql", - "expected_msql_file": "alter_table_add_unique_const_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete constraints", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "check_constraint": { - "deleted": [ - { - "name": "chk_const", - "consrc": "col2 <> NULL::bpchar", - "connoinherit": false, - "convalidated": false, - "relname": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "nspname": "public", - "comment": "chk const comment", - "conislocal": true - } - ] - }, - "unique_constraint": { - "deleted": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"\"'`\\\\/#" - } - ], - "name": "unique", - "comment": null, - "spcname": "pg_default", - "fillfactor": "13", - "condeferrable": false, - "condeferred": false, - "include": [], - "col_count": 1, - "conislocal": true - } - ] - } - }, - "expected_sql_file": "alter_table_delete_constraints.sql", - "expected_msql_file": "alter_table_delete_constraints_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with pk & chk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for FK reference", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "fk_reference_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "bigint" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table with fk constraint", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [ - { - "name": "fk_test", - "comment": "fk comment", - "condeferrable": true, - "confmatchtype": true, - "columns": [ - { - "local_column": "col1", - "references": "", - "referenced": "id" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_fk.sql", - "expected_msql_file": "create_table_with_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add one more fk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "foreign_key": { - "added": [ - { - "name": "fk2", - "columns": [ - { - "local_column": "col2", - "references": "", - "referenced": "name" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_another_fk.sql", - "expected_msql_file": "alter_table_add_another_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add exclude constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "exclude_constraint": { - "added": [ - { - "name": "ex_constr", - "amname": "gist", - "columns": [ - { - "column": "col1", - "is_exp": false, - "order": false, - "nulls_order": false, - "operator": "<>", - "is_sort_nulls_applicable": false - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_exclude_constraint.sql", - "expected_msql_file": "alter_table_add_exclude_constraint_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with custom auto-vacuum", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "custom auto vacuum", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "t", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "character varying[]", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "date", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor", - "value": 0.2 - }, - { - "name": "autovacuum_analyze_threshold", - "value": 55 - }, - { - "name": "autovacuum_freeze_max_age", - "value": 20000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 25 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 10 - }, - { - "name": "autovacuum_vacuum_scale_factor", - "value": 0.3 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 60 - }, - { - "name": "autovacuum_freeze_min_age", - "value": 500000 - }, - { - "name": "autovacuum_freeze_table_age", - "value": 1300000 - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_custom_autovacuum.sql", - "expected_msql_file": "create_table_with_custom_autovacuum_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add toast table", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "autovacuum_enabled": "x", - "toast_autovacuum": true, - "toast_autovacuum_enabled": "f", - "vacuum_table": { - "changed": [ - { - "name": "autovacuum_analyze_threshold", - "value": 60 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 100 - } - ] - }, - "vacuum_toast": { - "changed": [ - { - "name": "autovacuum_freeze_max_age", - "value": 2000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 50 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 13 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 70 - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_with_toast_table.sql", - "expected_msql_file": "alter_table_with_toast_table_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with advanced options", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "relhasoids": true, - "description": "test comment", - "relpersistence": true, - "fillfactor": "50", - "parallel_workers": "", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "double precision", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "numrange", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": true, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "rlspolicy": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_advanced_options.sql", - "expected_msql_file": "create_table_with_advanced_options_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table update grants", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "rlspolicy": false, - "forcerlspolicy": false, - "relacl": { - "added": [ - { - "grantee": "PUBLIC", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "r", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_update_grants.sql", - "expected_msql_file": "alter_table_update_grants_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "like_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "text" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table using like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test ", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": true, - "like_constraints": true, - "like_indexes": true, - "like_storage": true, - "like_comments": true, - "like_relation": "public.like_tbl" - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_lik_tbl.sql", - "expected_msql_file": "create_table_with_lik_tbl_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with list partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_active", - "values_in": "'ACTIVE'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "list", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_partition.sql", - "expected_msql_file": "create_table_with_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small PARTITION", - "values_from": "20", - "values_to": "25", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "arr" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_range_partition.sql", - "expected_msql_file": "create_table_with_range_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition with collate and opclass", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small", - "values_from": "'20'", - "values_to": "'25'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status", - "collationame": "\"C\"", - "op_class": "text_pattern_ops" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_partition_table_with_collate.sql", - "expected_msql_file": "create_partition_table_with_collate_msql.sql" - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/test.json index 809b147da..d8fb1e51d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/11_plus/test.json @@ -655,1443 +655,6 @@ "store_object_id": true, "expected_sql_file": "create_table_with_pk_chk.sql", "expected_msql_file": "create_table_with_pk_chk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add unique constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "unique_constraint": { - "added": [ - { - "name": "unique", - "fillfactor": "13", - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ] - } - }, - "expected_sql_file": "alter_table_add_unique_const.sql", - "expected_msql_file": "alter_table_add_unique_const_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete constraints", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "check_constraint": { - "deleted": [ - { - "name": "chk_const", - "consrc": "col2 <> NULL::bpchar", - "connoinherit": false, - "convalidated": false, - "relname": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "nspname": "public", - "comment": "chk const comment", - "conislocal": true - } - ] - }, - "unique_constraint": { - "deleted": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"\"'`\\\\/#" - } - ], - "name": "unique", - "comment": null, - "spcname": "pg_default", - "fillfactor": "13", - "condeferrable": false, - "condeferred": false, - "include": [], - "col_count": 1, - "conislocal": true - } - ] - } - }, - "expected_sql_file": "alter_table_delete_constraints.sql", - "expected_msql_file": "alter_table_delete_constraints_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with pk & chk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for FK reference", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "fk_reference_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "bigint" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table with fk constraint", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [ - { - "name": "fk_test", - "comment": "fk comment", - "condeferrable": true, - "confmatchtype": true, - "columns": [ - { - "local_column": "col1", - "references": "", - "referenced": "id" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_fk.sql", - "expected_msql_file": "create_table_with_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add one more fk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "foreign_key": { - "added": [ - { - "name": "fk2", - "columns": [ - { - "local_column": "col2", - "references": "", - "referenced": "name" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_another_fk.sql", - "expected_msql_file": "alter_table_add_another_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add exclude constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "exclude_constraint": { - "added": [ - { - "name": "ex_constr", - "amname": "gist", - "columns": [ - { - "column": "col1", - "is_exp": false, - "order": false, - "nulls_order": false, - "operator": "<>", - "is_sort_nulls_applicable": false - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_exclude_constraint.sql", - "expected_msql_file": "alter_table_add_exclude_constraint_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with custom auto-vacuum", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "custom auto vacuum", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "t", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "character varying[]", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "date", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor", - "value": 0.2 - }, - { - "name": "autovacuum_analyze_threshold", - "value": 55 - }, - { - "name": "autovacuum_freeze_max_age", - "value": 20000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 25 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 10 - }, - { - "name": "autovacuum_vacuum_scale_factor", - "value": 0.3 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 60 - }, - { - "name": "autovacuum_freeze_min_age", - "value": 500000 - }, - { - "name": "autovacuum_freeze_table_age", - "value": 1300000 - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_custom_autovacuum.sql", - "expected_msql_file": "create_table_with_custom_autovacuum_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add toast table", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "autovacuum_enabled": "x", - "toast_autovacuum": true, - "toast_autovacuum_enabled": "f", - "vacuum_table": { - "changed": [ - { - "name": "autovacuum_analyze_threshold", - "value": 60 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 100 - } - ] - }, - "vacuum_toast": { - "changed": [ - { - "name": "autovacuum_freeze_max_age", - "value": 2000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 50 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 13 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 70 - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_with_toast_table.sql", - "expected_msql_file": "alter_table_with_toast_table_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with advanced options", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "relhasoids": true, - "description": "test comment", - "relpersistence": true, - "fillfactor": "50", - "parallel_workers": "", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "double precision", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "numrange", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": true, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "rlspolicy": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_advanced_options.sql", - "expected_msql_file": "create_table_with_advanced_options_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table update grants", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "rlspolicy": false, - "forcerlspolicy": false, - "relacl": { - "added": [ - { - "grantee": "PUBLIC", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "r", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_update_grants.sql", - "expected_msql_file": "alter_table_update_grants_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "like_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "text" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table using like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test ", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": true, - "like_constraints": true, - "like_indexes": true, - "like_storage": true, - "like_comments": true, - "like_relation": "public.like_tbl" - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_lik_tbl.sql", - "expected_msql_file": "create_table_with_lik_tbl_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with list partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_active", - "values_in": "'ACTIVE'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "list", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_partition.sql", - "expected_msql_file": "create_table_with_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small PARTITION", - "values_from": "20", - "values_to": "25", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "arr" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_range_partition.sql", - "expected_msql_file": "create_table_with_range_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with hash partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#", - "relowner": "postgres", - "relacl": [], - "description": "hash partition", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_part11", - "values_modulus": "2", - "values_remainder": "1", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "hash", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "name", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "id" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_hash_partition.sql", - "expected_msql_file": "create_table_with_hash_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition with collate and opclass", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small", - "values_from": "'20'", - "values_to": "'25'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status", - "collationame": "\"C\"", - "op_class": "text_pattern_ops" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_partition_table_with_collate.sql", - "expected_msql_file": "create_partition_table_with_collate_msql.sql" } ] } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json index 809b147da..d8fb1e51d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/12_plus/test.json @@ -655,1443 +655,6 @@ "store_object_id": true, "expected_sql_file": "create_table_with_pk_chk.sql", "expected_msql_file": "create_table_with_pk_chk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add unique constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "unique_constraint": { - "added": [ - { - "name": "unique", - "fillfactor": "13", - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ] - } - }, - "expected_sql_file": "alter_table_add_unique_const.sql", - "expected_msql_file": "alter_table_add_unique_const_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete constraints", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "check_constraint": { - "deleted": [ - { - "name": "chk_const", - "consrc": "col2 <> NULL::bpchar", - "connoinherit": false, - "convalidated": false, - "relname": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "nspname": "public", - "comment": "chk const comment", - "conislocal": true - } - ] - }, - "unique_constraint": { - "deleted": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"\"'`\\\\/#" - } - ], - "name": "unique", - "comment": null, - "spcname": "pg_default", - "fillfactor": "13", - "condeferrable": false, - "condeferred": false, - "include": [], - "col_count": 1, - "conislocal": true - } - ] - } - }, - "expected_sql_file": "alter_table_delete_constraints.sql", - "expected_msql_file": "alter_table_delete_constraints_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with pk & chk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for FK reference", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "fk_reference_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "bigint" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table with fk constraint", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [ - { - "name": "fk_test", - "comment": "fk comment", - "condeferrable": true, - "confmatchtype": true, - "columns": [ - { - "local_column": "col1", - "references": "", - "referenced": "id" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_fk.sql", - "expected_msql_file": "create_table_with_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add one more fk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "foreign_key": { - "added": [ - { - "name": "fk2", - "columns": [ - { - "local_column": "col2", - "references": "", - "referenced": "name" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_another_fk.sql", - "expected_msql_file": "alter_table_add_another_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add exclude constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "exclude_constraint": { - "added": [ - { - "name": "ex_constr", - "amname": "gist", - "columns": [ - { - "column": "col1", - "is_exp": false, - "order": false, - "nulls_order": false, - "operator": "<>", - "is_sort_nulls_applicable": false - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_exclude_constraint.sql", - "expected_msql_file": "alter_table_add_exclude_constraint_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with custom auto-vacuum", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "custom auto vacuum", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "t", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "character varying[]", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "date", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor", - "value": 0.2 - }, - { - "name": "autovacuum_analyze_threshold", - "value": 55 - }, - { - "name": "autovacuum_freeze_max_age", - "value": 20000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 25 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 10 - }, - { - "name": "autovacuum_vacuum_scale_factor", - "value": 0.3 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 60 - }, - { - "name": "autovacuum_freeze_min_age", - "value": 500000 - }, - { - "name": "autovacuum_freeze_table_age", - "value": 1300000 - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_custom_autovacuum.sql", - "expected_msql_file": "create_table_with_custom_autovacuum_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add toast table", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "autovacuum_enabled": "x", - "toast_autovacuum": true, - "toast_autovacuum_enabled": "f", - "vacuum_table": { - "changed": [ - { - "name": "autovacuum_analyze_threshold", - "value": 60 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 100 - } - ] - }, - "vacuum_toast": { - "changed": [ - { - "name": "autovacuum_freeze_max_age", - "value": 2000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 50 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 13 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 70 - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_with_toast_table.sql", - "expected_msql_file": "alter_table_with_toast_table_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with advanced options", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "relhasoids": true, - "description": "test comment", - "relpersistence": true, - "fillfactor": "50", - "parallel_workers": "", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "double precision", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "numrange", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": true, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "rlspolicy": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_advanced_options.sql", - "expected_msql_file": "create_table_with_advanced_options_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table update grants", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "rlspolicy": false, - "forcerlspolicy": false, - "relacl": { - "added": [ - { - "grantee": "PUBLIC", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "r", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_update_grants.sql", - "expected_msql_file": "alter_table_update_grants_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "like_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "text" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table using like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "test ", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": true, - "like_constraints": true, - "like_indexes": true, - "like_storage": true, - "like_comments": true, - "like_relation": "public.like_tbl" - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_lik_tbl.sql", - "expected_msql_file": "create_table_with_lik_tbl_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with list partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_active", - "values_in": "'ACTIVE'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "list", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_partition.sql", - "expected_msql_file": "create_table_with_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small PARTITION", - "values_from": "20", - "values_to": "25", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "arr" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_range_partition.sql", - "expected_msql_file": "create_table_with_range_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with hash partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#", - "relowner": "postgres", - "relacl": [], - "description": "hash partition", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_part11", - "values_modulus": "2", - "values_remainder": "1", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "hash", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "name", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "id" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_hash_partition.sql", - "expected_msql_file": "create_table_with_hash_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition with collate and opclass", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", - "relowner": "postgres", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small", - "values_from": "'20'", - "values_to": "'25'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status", - "collationame": "\"C\"", - "op_class": "text_pattern_ops" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_partition_table_with_collate.sql", - "expected_msql_file": "create_partition_table_with_collate_msql.sql" } ] } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/alter_table_with_toast_table_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/alter_table_with_toast_table_msql.sql index f8cf5a968..89a93aceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/alter_table_with_toast_table_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/alter_table_with_toast_table_msql.sql @@ -5,6 +5,7 @@ ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" RESET ( autovacuum_enabled ); + ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" SET ( toast.autovacuum_enabled = false, toast.autovacuum_freeze_max_age = 2000000, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_partition_table_with_collate.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_partition_table_with_collate.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_partition_table_with_collate_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_partition_table_with_collate_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_partition_table_with_collate_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_partition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_partition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_partition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_partition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_partition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_partition_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_range_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_range_partition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_range_partition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_range_partition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_range_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_range_partition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/10_plus/create_table_with_range_partition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/create_table_with_range_partition_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/test.json index d0af0acfb..e9020c2f8 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/pg/default/test.json @@ -1492,6 +1492,456 @@ "data": { "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" } + }, + { + "type": "create", + "name": "Create Table with list partition", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_active", + "values_in": "'ACTIVE'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "list", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_partition.sql", + "expected_msql_file": "create_table_with_partition_msql.sql" + }, + { + "type": "create", + "name": "Create Table with range partition", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small PARTITION", + "values_from": "20", + "values_to": "25", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "arr" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_range_partition.sql", + "expected_msql_file": "create_table_with_range_partition_msql.sql" + }, + { + "type": "create", + "name": "Create Table with range partition with collate and opclass", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", + "relowner": "postgres", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small", + "values_from": "'20'", + "values_to": "'25'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status", + "collationame": "\"C\"", + "op_class": "text_pattern_ops" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_partition_table_with_collate.sql", + "expected_msql_file": "create_partition_table_with_collate_msql.sql" } ] } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/alter_table_with_toast_table.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/alter_table_with_toast_table.sql deleted file mode 100644 index 2fc4a5516..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/alter_table_with_toast_table.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Table: public.table_with_custom_autovaccum_$%{}[]()&*^!@"'`\/# - --- DROP TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#"; - -CREATE TABLE IF NOT EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" -( - col1 character varying(10)[] COLLATE pg_catalog."default", - col2 timestamp without time zone -) -WITH ( - OIDS = FALSE, - toast.autovacuum_enabled = FALSE, - autovacuum_analyze_scale_factor = 0.2, - autovacuum_analyze_threshold = 60, - autovacuum_freeze_max_age = 20000000, - autovacuum_vacuum_cost_delay = 25, - autovacuum_vacuum_cost_limit = 100, - autovacuum_vacuum_scale_factor = 0.3, - autovacuum_vacuum_threshold = 60, - autovacuum_freeze_min_age = 500000, - autovacuum_freeze_table_age = 1300000, - toast.autovacuum_freeze_max_age = 2000000, - toast.autovacuum_vacuum_cost_delay = 50, - toast.autovacuum_vacuum_cost_limit = 13, - toast.autovacuum_vacuum_threshold = 70 -) -TABLESPACE pg_default; - -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" - OWNER to enterprisedb; - -COMMENT ON TABLE public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" - IS 'custom auto vacuum'; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/alter_table_with_toast_table_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/alter_table_with_toast_table_msql.sql deleted file mode 100644 index 89a93aceb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/alter_table_with_toast_table_msql.sql +++ /dev/null @@ -1,15 +0,0 @@ -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" SET ( - autovacuum_analyze_threshold = 60, - autovacuum_vacuum_cost_limit = 100 -); -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" RESET ( - autovacuum_enabled -); - -ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" SET ( - toast.autovacuum_enabled = false, - toast.autovacuum_freeze_max_age = 2000000, - toast.autovacuum_vacuum_cost_delay = 50, - toast.autovacuum_vacuum_cost_limit = 13, - toast.autovacuum_vacuum_threshold = 70 -); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/test.json deleted file mode 100644 index c079c472a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/test.json +++ /dev/null @@ -1,1947 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Table without primary key", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "boolean", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col4", - "cltype": "character varying", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 30, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col5", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": 20, - "attprecision": 10, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col6", - "cltype": "timestamp with time zone", - "attacl": [], - "min_val_attlen": 0, - "max_val_attlen": 6, - "is_primary_key": false, - "attnotnull": false, - "attlen": 5, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_without_primary_key.sql", - "expected_msql_file": "create_table_without_primary_key_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table to change column data types", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "cltype": "bigint" - }, - { - "attnum": 2, - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "cltype": "character varying" - }, - { - "attnum": 6, - "attlen": null, - "cltype": "time without time zone" - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_change_col_data_type.sql", - "expected_msql_file": "alter_table_change_col_data_type_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add pk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "attnotnull": true, - "is_primary_key": true - } - ] - }, - "primary_key": { - "added": [ - { - "columns": [ - { - "column": "col1" - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_pk_not_null_constraint.sql", - "expected_msql_file": "alter_table_add_pk_not_null_constraint_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add null constraint, rename column", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "name": "col1_rename", - "is_primary_key": false - }, - { - "attnum": 4, - "attnotnull": true - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_null_constraint_rename_col.sql", - "expected_msql_file": "alter_table_add_null_constraint_rename_col_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table add pk", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with primary key", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "integer", - "attacl": [], - "is_primary_key": true, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "json", - "attacl": [], - "is_primary_key": false, - "attnotnull": true, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_pk.sql", - "expected_msql_file": "create_table_with_pk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add columns", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "columns": { - "added": [ - { - "name": "col3_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": 5, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col4_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_cols.sql", - "expected_msql_file": "alter_table_add_cols_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete columns", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "columns": { - "deleted": [ - { - "attoptions": [], - "attacl": [], - "seclabels": [], - "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", - "atttypid": 114, - "attnum": 2, - "cltype": "json", - "collspcname": "", - "description": null, - "edit_types": [ - "json", - "jsonb" - ], - "is_primary_key": false, - "attstattarget": -1, - "attnotnull": true, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attndims": 0, - "atttypmod": -1, - "attstorage": "x", - "defval": null, - "typname": "json", - "displaytypname": "json", - "elemoid": 114, - "typnspname": "pg_catalog", - "defaultstorage": "x", - "indkey": "1", - "isdup": false, - "is_fk": false, - "is_sys_column": false, - "relname": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "is_view_only": false, - "is_pk": false, - "old_attidentity": "a" - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_delete_cols.sql", - "expected_msql_file": "alter_table_delete_cols_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table delete columns", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with pk & check constraint", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "create table comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [ - { - "name": "custom_pk", - "comment": "custom pk created", - "fillfactor": "11", - "condeferrable": true, - "condeferred": true, - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "time with time zone", - "attacl": [], - "min_val_attlen": 0, - "max_val_attlen": 6, - "is_primary_key": false, - "attnotnull": false, - "attlen": 5, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "character", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 12, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [ - { - "name": "chk_const", - "consrc": "col2 != null", - "convalidated": false, - "comment": "chk const comment" - } - ], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_pk_chk.sql", - "expected_msql_file": "create_table_with_pk_chk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add unique constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "unique_constraint": { - "added": [ - { - "name": "unique", - "fillfactor": "13", - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ] - } - }, - "expected_sql_file": "alter_table_add_unique_const.sql", - "expected_msql_file": "alter_table_add_unique_const_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete constraints", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "check_constraint": { - "deleted": [ - { - "name": "chk_const", - "consrc": "col2 <> NULL::bpchar", - "connoinherit": false, - "convalidated": false, - "relname": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "nspname": "public", - "comment": "chk const comment", - "conislocal": true - } - ] - }, - "unique_constraint": { - "deleted": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"\"'`\\\\/#" - } - ], - "name": "unique", - "comment": null, - "spcname": "pg_default", - "fillfactor": "13", - "condeferrable": false, - "condeferred": false, - "include": [], - "col_count": 1, - "conislocal": true - } - ] - } - }, - "expected_sql_file": "alter_table_delete_constraints.sql", - "expected_msql_file": "alter_table_delete_constraints_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with pk & chk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for FK reference", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "fk_reference_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "bigint" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table with fk constraint", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [ - { - "name": "fk_test", - "comment": "fk comment", - "condeferrable": true, - "confmatchtype": true, - "columns": [ - { - "local_column": "col1", - "references": "", - "referenced": "id" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_fk.sql", - "expected_msql_file": "create_table_with_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add one more fk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "foreign_key": { - "added": [ - { - "name": "fk2", - "columns": [ - { - "local_column": "col2", - "references": "", - "referenced": "name" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_another_fk.sql", - "expected_msql_file": "alter_table_add_another_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add exclude constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "exclude_constraint": { - "added": [ - { - "name": "ex_constr", - "amname": "gist", - "columns": [ - { - "column": "col1", - "is_exp": false, - "order": false, - "nulls_order": false, - "operator": "<>", - "is_sort_nulls_applicable": false - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_exclude_constraint.sql", - "expected_msql_file": "alter_table_add_exclude_constraint_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with custom auto-vacuum", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "custom auto vacuum", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "t", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "character varying[]", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "date", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor", - "value": 0.2 - }, - { - "name": "autovacuum_analyze_threshold", - "value": 55 - }, - { - "name": "autovacuum_freeze_max_age", - "value": 20000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 25 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 10 - }, - { - "name": "autovacuum_vacuum_scale_factor", - "value": 0.3 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 60 - }, - { - "name": "autovacuum_freeze_min_age", - "value": 500000 - }, - { - "name": "autovacuum_freeze_table_age", - "value": 1300000 - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_custom_autovacuum.sql", - "expected_msql_file": "create_table_with_custom_autovacuum_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add toast table", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "autovacuum_enabled": "x", - "toast_autovacuum": true, - "toast_autovacuum_enabled": "f", - "vacuum_table": { - "changed": [ - { - "name": "autovacuum_analyze_threshold", - "value": 60 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 100 - } - ] - }, - "vacuum_toast": { - "changed": [ - { - "name": "autovacuum_freeze_max_age", - "value": 2000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 50 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 13 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 70 - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_with_toast_table.sql", - "expected_msql_file": "alter_table_with_toast_table_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with advanced options", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "relhasoids": true, - "description": "test comment", - "relpersistence": true, - "fillfactor": "50", - "parallel_workers": "", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "double precision", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "numrange", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": true, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "rlspolicy": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_advanced_options.sql", - "expected_msql_file": "create_table_with_advanced_options_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table update grants", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "rlspolicy": false, - "forcerlspolicy": false, - "relacl": { - "added": [ - { - "grantee": "PUBLIC", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "r", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_update_grants.sql", - "expected_msql_file": "alter_table_update_grants_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "like_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "text" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table using like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test ", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": true, - "like_constraints": true, - "like_indexes": true, - "like_storage": true, - "like_comments": true, - "like_relation": "public.like_tbl" - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_lik_tbl.sql", - "expected_msql_file": "create_table_with_lik_tbl_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with list partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_active", - "values_in": "'ACTIVE'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "list", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_partition.sql", - "expected_msql_file": "create_table_with_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small PARTITION", - "values_from": "20", - "values_to": "25", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "arr" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_range_partition.sql", - "expected_msql_file": "create_table_with_range_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition with collate and opclass", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small", - "values_from": "'20'", - "values_to": "'25'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status", - "collationame": "\"C\"", - "op_class": "text_pattern_ops" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_partition_table_with_collate.sql", - "expected_msql_file": "create_partition_table_with_collate_msql.sql" - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/test.json index 6419423fa..d598b3e32 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/11_plus/test.json @@ -1,520 +1,5 @@ { - "scenarios": [ - { - "type": "create", - "name": "Create Table without primary key", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "boolean", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col4", - "cltype": "character varying", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 30, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col5", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": 20, - "attprecision": 10, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col6", - "cltype": "timestamp with time zone", - "attacl": [], - "min_val_attlen": 0, - "max_val_attlen": 6, - "is_primary_key": false, - "attnotnull": false, - "attlen": 5, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_without_primary_key.sql", - "expected_msql_file": "create_table_without_primary_key_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table to change column data types", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "cltype": "bigint" - }, - { - "attnum": 2, - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "cltype": "character varying" - }, - { - "attnum": 6, - "attlen": null, - "cltype": "time without time zone" - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_change_col_data_type.sql", - "expected_msql_file": "alter_table_change_col_data_type_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add pk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "attnotnull": true, - "is_primary_key": true - } - ] - }, - "primary_key": { - "added": [ - { - "columns": [ - { - "column": "col1" - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_pk_not_null_constraint.sql", - "expected_msql_file": "alter_table_add_pk_not_null_constraint_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add null constraint, rename column", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#", - "columns": { - "changed": [ - { - "attnum": 1, - "name": "col1_rename", - "is_primary_key": false - }, - { - "attnum": 4, - "attnotnull": true - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_null_constraint_rename_col.sql", - "expected_msql_file": "alter_table_add_null_constraint_rename_col_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table add pk", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "simple_table_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with primary key", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "integer", - "attacl": [], - "is_primary_key": true, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "json", - "attacl": [], - "is_primary_key": false, - "attnotnull": true, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_pk.sql", - "expected_msql_file": "create_table_with_pk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add columns", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "columns": { - "added": [ - { - "name": "col3_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": 5, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col4_$%{}[]()&*^!@\\\"'`\\\\/#", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_add_cols.sql", - "expected_msql_file": "alter_table_add_cols_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete columns", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "columns": { - "deleted": [ - { - "attoptions": [], - "attacl": [], - "seclabels": [], - "name": "col2_$%{}[]()&*^!@\\\"'`\\\\/#", - "atttypid": 114, - "attnum": 2, - "cltype": "json", - "collspcname": "", - "description": null, - "edit_types": [ - "json", - "jsonb" - ], - "is_primary_key": false, - "attstattarget": -1, - "attnotnull": true, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attndims": 0, - "atttypmod": -1, - "attstorage": "x", - "defval": null, - "typname": "json", - "displaytypname": "json", - "elemoid": 114, - "typnspname": "pg_catalog", - "defaultstorage": "x", - "indkey": "1", - "isdup": false, - "is_fk": false, - "is_sys_column": false, - "relname": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#", - "is_view_only": false, - "is_pk": false, - "old_attidentity": "a" - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_delete_cols.sql", - "expected_msql_file": "alter_table_delete_cols_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table delete columns", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "simple_table_with_pk$%{}[]()&*^!@\"'`\\/#" - } - }, - { + "scenarios": [ { "type": "create", "name": "Create Table with pk & check constraint", "endpoint": "NODE-table.obj", @@ -655,1443 +140,6 @@ "store_object_id": true, "expected_sql_file": "create_table_with_pk_chk.sql", "expected_msql_file": "create_table_with_pk_chk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add unique constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "unique_constraint": { - "added": [ - { - "name": "unique", - "fillfactor": "13", - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"'`\\\\/#" - } - ], - "include": [] - } - ] - } - }, - "expected_sql_file": "alter_table_add_unique_const.sql", - "expected_msql_file": "alter_table_add_unique_const_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table delete constraints", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "check_constraint": { - "deleted": [ - { - "name": "chk_const", - "consrc": "col2 <> NULL::bpchar", - "connoinherit": false, - "convalidated": false, - "relname": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#", - "nspname": "public", - "comment": "chk const comment", - "conislocal": true - } - ] - }, - "unique_constraint": { - "deleted": [ - { - "columns": [ - { - "column": "col1_$%{}[]()&*^!@\\\"\"'`\\\\/#" - } - ], - "name": "unique", - "comment": null, - "spcname": "pg_default", - "fillfactor": "13", - "condeferrable": false, - "condeferred": false, - "include": [], - "col_count": 1, - "conislocal": true - } - ] - } - }, - "expected_sql_file": "alter_table_delete_constraints.sql", - "expected_msql_file": "alter_table_delete_constraints_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with pk & chk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_pk_chk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for FK reference", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "fk_reference_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "bigint" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table with fk constraint", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test comment", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col3", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [ - { - "name": "fk_test", - "comment": "fk comment", - "condeferrable": true, - "confmatchtype": true, - "columns": [ - { - "local_column": "col1", - "references": "", - "referenced": "id" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_fk.sql", - "expected_msql_file": "create_table_with_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add one more fk", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "foreign_key": { - "added": [ - { - "name": "fk2", - "columns": [ - { - "local_column": "col2", - "references": "", - "referenced": "name" - } - ], - "confupdtype": "a", - "confdeltype": "a", - "autoindex": false, - "coveringindex": null - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_another_fk.sql", - "expected_msql_file": "alter_table_add_another_fk_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add exclude constraint", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#", - "exclude_constraint": { - "added": [ - { - "name": "ex_constr", - "amname": "gist", - "columns": [ - { - "column": "col1", - "is_exp": false, - "order": false, - "nulls_order": false, - "operator": "<>", - "is_sort_nulls_applicable": false - } - ], - "include": [] - } - ] - } - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "alter_table_add_exclude_constraint.sql", - "expected_msql_file": "alter_table_add_exclude_constraint_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_fk_constraints$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with custom auto-vacuum", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "custom auto vacuum", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "t", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "character varying[]", - "attacl": [], - "min_val_attlen": 1, - "max_val_attlen": 2147483647, - "is_primary_key": false, - "attnotnull": false, - "attlen": 10, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "date", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor", - "value": 0.2 - }, - { - "name": "autovacuum_analyze_threshold", - "value": 55 - }, - { - "name": "autovacuum_freeze_max_age", - "value": 20000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 25 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 10 - }, - { - "name": "autovacuum_vacuum_scale_factor", - "value": 0.3 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 60 - }, - { - "name": "autovacuum_freeze_min_age", - "value": 500000 - }, - { - "name": "autovacuum_freeze_table_age", - "value": 1300000 - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_custom_autovacuum.sql", - "expected_msql_file": "create_table_with_custom_autovacuum_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table add toast table", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#", - "autovacuum_enabled": "x", - "toast_autovacuum": true, - "toast_autovacuum_enabled": "f", - "vacuum_table": { - "changed": [ - { - "name": "autovacuum_analyze_threshold", - "value": 60 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 100 - } - ] - }, - "vacuum_toast": { - "changed": [ - { - "name": "autovacuum_freeze_max_age", - "value": 2000000 - }, - { - "name": "autovacuum_vacuum_cost_delay", - "value": 50 - }, - { - "name": "autovacuum_vacuum_cost_limit", - "value": 13 - }, - { - "name": "autovacuum_vacuum_threshold", - "value": 70 - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_with_toast_table.sql", - "expected_msql_file": "alter_table_with_toast_table_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with fk constraints", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_custom_autovaccum_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with advanced options", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "relhasoids": true, - "description": "test comment", - "relpersistence": true, - "fillfactor": "50", - "parallel_workers": "", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [ - { - "name": "col1", - "cltype": "double precision", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "col2", - "cltype": "numrange", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": true, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "rlspolicy": true - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_advanced_options.sql", - "expected_msql_file": "create_table_with_advanced_options_msql.sql" - }, - { - "type": "alter", - "name": "Alter Table update grants", - "endpoint": "NODE-table.obj_id", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#", - "rlspolicy": false, - "forcerlspolicy": false, - "relacl": { - "added": [ - { - "grantee": "PUBLIC", - "grantor": "postgres", - "privileges": [ - { - "privilege_type": "r", - "privilege": true, - "with_grant": false - } - ] - } - ] - } - }, - "store_object_id": true, - "expected_sql_file": "alter_table_update_grants.sql", - "expected_msql_file": "alter_table_update_grants_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_with_advanced_options_$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table for like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "data": { - "name": "like_tbl", - "columns": [ - { - "name": "id", - "cltype": "integer", - "is_primary_key": true - }, - { - "name": "name", - "cltype": "text" - } - ], - "primary_key": [ - { - "columns": [ - { - "column": "id" - } - ], - "include": [] - } - ], - "unique_constraint": [ - { - "name": "", - "columns": [ - { - "column": "name" - } - ], - "include": [] - } - ], - "is_partitioned": false, - "schema": "public", - "spcname": "pg_default" - }, - "store_object_id": true - }, - { - "type": "create", - "name": "Create Table using like table", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "test ", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [], - "partition_type": "range", - "is_partitioned": false, - "schema": "public", - "columns": [], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": true, - "like_constraints": true, - "like_indexes": true, - "like_storage": true, - "like_comments": true, - "like_relation": "public.like_tbl" - }, - "store_object_id": true, - "preprocess_data": true, - "expected_sql_file": "create_table_with_lik_tbl.sql", - "expected_msql_file": "create_table_with_lik_tbl_msql.sql" - }, - { - "type": "delete", - "name": "Delete Table with advanced options", - "endpoint": "NODE-table.obj_id", - "data": { - "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" - } - }, - { - "type": "create", - "name": "Create Table with list partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_active", - "values_in": "'ACTIVE'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "list", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_partition.sql", - "expected_msql_file": "create_table_with_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small PARTITION", - "values_from": "20", - "values_to": "25", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "arr" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_range_partition.sql", - "expected_msql_file": "create_table_with_range_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with hash partition", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "table_with_hash_patition_$%{}[]()&*^!@\\\"'`\\\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "hash partition", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_part11", - "values_modulus": "2", - "values_remainder": "1", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "hash", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "bigint", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "name", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "id" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_table_with_hash_partition.sql", - "expected_msql_file": "create_table_with_hash_partition_msql.sql" - }, - { - "type": "create", - "name": "Create Table with range partition with collate and opclass", - "endpoint": "NODE-table.obj", - "sql_endpoint": "NODE-table.sql_id", - "msql_endpoint": "NODE-table.msql", - "data": { - "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", - "relowner": "enterprisedb", - "relacl": [], - "description": "partition table", - "coll_inherits": "[]", - "hastoasttable": true, - "toast_autovacuum_enabled": "x", - "autovacuum_enabled": "x", - "primary_key": [], - "partitions": [ - { - "is_attach": false, - "partition_name": "cust_arr_small", - "values_from": "'20'", - "values_to": "'25'", - "is_sub_partitioned": false, - "sub_partition_type": "range", - "sub_partition_keys": [] - } - ], - "partition_type": "range", - "is_partitioned": true, - "schema": "public", - "columns": [ - { - "name": "id", - "cltype": "integer", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "status", - "cltype": "text", - "attacl": [], - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - }, - { - "name": "arr", - "cltype": "numeric", - "attacl": [], - "min_val_attlen": 1, - "min_val_attprecision": 0, - "max_val_attlen": 1000, - "max_val_attprecision": 1000, - "is_primary_key": false, - "attnotnull": false, - "attlen": null, - "attprecision": null, - "attidentity": "a", - "colconstype": "n", - "attoptions": [], - "seclabels": [] - } - ], - "foreign_key": [], - "check_constraint": [], - "unique_constraint": [], - "exclude_constraint": [], - "partition_keys": [ - { - "key_type": "column", - "pt_column": "status", - "collationame": "\"C\"", - "op_class": "text_pattern_ops" - } - ], - "vacuum_table": [ - { - "name": "autovacuum_analyze_scale_factor" - }, - { - "name": "autovacuum_analyze_threshold" - }, - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "vacuum_toast": [ - { - "name": "autovacuum_freeze_max_age" - }, - { - "name": "autovacuum_vacuum_cost_delay" - }, - { - "name": "autovacuum_vacuum_cost_limit" - }, - { - "name": "autovacuum_vacuum_scale_factor" - }, - { - "name": "autovacuum_vacuum_threshold" - }, - { - "name": "autovacuum_freeze_min_age" - }, - { - "name": "autovacuum_freeze_table_age" - } - ], - "seclabels": [], - "forcerlspolicy": false, - "like_default_value": false, - "like_constraints": false, - "like_indexes": false, - "like_storage": false, - "like_comments": false, - "autovacuum_custom": false - }, - "store_object_id": true, - "expected_sql_file": "create_partition_table_with_collate.sql", - "expected_msql_file": "create_partition_table_with_collate_msql.sql" } ] } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/alter_table_with_toast_table_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/alter_table_with_toast_table_msql.sql index f8cf5a968..89a93aceb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/alter_table_with_toast_table_msql.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/alter_table_with_toast_table_msql.sql @@ -5,6 +5,7 @@ ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" RESET ( autovacuum_enabled ); + ALTER TABLE IF EXISTS public."table_with_custom_autovaccum_$%{}[]()&*^!@""'`\/#" SET ( toast.autovacuum_enabled = false, toast.autovacuum_freeze_max_age = 2000000, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_partition_table_with_collate.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_partition_table_with_collate.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_partition_table_with_collate_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_partition_table_with_collate_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_partition_table_with_collate_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_partition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_partition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_partition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_partition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_partition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_partition_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_range_partition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_range_partition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_range_partition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_range_partition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_range_partition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_range_partition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/10_plus/create_table_with_range_partition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/create_table_with_range_partition_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/test.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/test.json index d65dfb727..c079c472a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/test.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/ppas/default/test.json @@ -1492,6 +1492,456 @@ "data": { "name": "table_like_tbl$%{}[]()&*^!@\"'`\\/#" } + }, + { + "type": "create", + "name": "Create Table with list partition", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_active", + "values_in": "'ACTIVE'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "list", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_partition.sql", + "expected_msql_file": "create_table_with_partition_msql.sql" + }, + { + "type": "create", + "name": "Create Table with range partition", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "table_with_range_patition_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small PARTITION", + "values_from": "20", + "values_to": "25", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "arr" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_table_with_range_partition.sql", + "expected_msql_file": "create_table_with_range_partition_msql.sql" + }, + { + "type": "create", + "name": "Create Table with range partition with collate and opclass", + "endpoint": "NODE-table.obj", + "sql_endpoint": "NODE-table.sql_id", + "msql_endpoint": "NODE-table.msql", + "data": { + "name": "partition_table_with_collate_$%{}[]()&*^!@\"'`\\/#", + "relowner": "enterprisedb", + "relacl": [], + "description": "partition table", + "coll_inherits": "[]", + "hastoasttable": true, + "toast_autovacuum_enabled": "x", + "autovacuum_enabled": "x", + "primary_key": [], + "partitions": [ + { + "is_attach": false, + "partition_name": "cust_arr_small", + "values_from": "'20'", + "values_to": "'25'", + "is_sub_partitioned": false, + "sub_partition_type": "range", + "sub_partition_keys": [] + } + ], + "partition_type": "range", + "is_partitioned": true, + "schema": "public", + "columns": [ + { + "name": "id", + "cltype": "integer", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "status", + "cltype": "text", + "attacl": [], + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + }, + { + "name": "arr", + "cltype": "numeric", + "attacl": [], + "min_val_attlen": 1, + "min_val_attprecision": 0, + "max_val_attlen": 1000, + "max_val_attprecision": 1000, + "is_primary_key": false, + "attnotnull": false, + "attlen": null, + "attprecision": null, + "attidentity": "a", + "colconstype": "n", + "attoptions": [], + "seclabels": [] + } + ], + "foreign_key": [], + "check_constraint": [], + "unique_constraint": [], + "exclude_constraint": [], + "partition_keys": [ + { + "key_type": "column", + "pt_column": "status", + "collationame": "\"C\"", + "op_class": "text_pattern_ops" + } + ], + "vacuum_table": [ + { + "name": "autovacuum_analyze_scale_factor" + }, + { + "name": "autovacuum_analyze_threshold" + }, + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "vacuum_toast": [ + { + "name": "autovacuum_freeze_max_age" + }, + { + "name": "autovacuum_vacuum_cost_delay" + }, + { + "name": "autovacuum_vacuum_cost_limit" + }, + { + "name": "autovacuum_vacuum_scale_factor" + }, + { + "name": "autovacuum_vacuum_threshold" + }, + { + "name": "autovacuum_freeze_min_age" + }, + { + "name": "autovacuum_freeze_table_age" + } + ], + "seclabels": [], + "forcerlspolicy": false, + "like_default_value": false, + "like_constraints": false, + "like_indexes": false, + "like_storage": false, + "like_comments": false, + "autovacuum_custom": false + }, + "store_object_id": true, + "expected_sql_file": "create_partition_table_with_collate.sql", + "expected_msql_file": "create_partition_table_with_collate_msql.sql" } ] } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/allowed_privs.json similarity index 90% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/allowed_privs.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/allowed_privs.json index 0c1784a5b..1253e87dc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/allowed_privs.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/allowed_privs.json @@ -8,8 +8,8 @@ #} { "nspacl": { - "type": "SCHEMA", - "acl": ["C", "U"] + "type": "DATABASE", + "acl": ["c", "C", "T"] }, "deftblacl": { "type": "TABLE", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/acl.sql similarity index 94% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/acl.sql index 58d0aff55..04b20a271 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/acl.sql @@ -20,5 +20,4 @@ FROM ) b LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname -ORDER BY grantee; +GROUP BY g.rolname, gt.rolname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/create.sql new file mode 100644 index 000000000..2dd2328b6 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/create.sql @@ -0,0 +1,17 @@ +{% import 'macros/privilege.macros' as PRIVILEGE %} +{% if data %} +CREATE SCHEMA{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.name) }} +{% if data.namespaceowner %} + AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}; + +{% endif %} +{% if data.description %} +COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} + IS {{ data.description|qtLiteral }}; + +{% endif %} +{% if data.nspacl %} +{% for priv in data.nspacl %} +{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} +{% endif %} +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/get_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/get_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/get_name.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/get_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/is_catalog.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/is_catalog.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/is_catalog.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/is_catalog.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/nodes.sql similarity index 56% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/nodes.sql index ca557164e..5de3ee5b4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/nodes.sql @@ -1,7 +1,7 @@ {% import 'catalog/pg/macros/catalogs.sql' as CATALOGS %} SELECT nsp.oid, - nsp.nspname as name, +{{ CATALOGS.LABELS('nsp', _) }}, pg_catalog.has_schema_privilege(nsp.oid, 'CREATE') as can_create, pg_catalog.has_schema_privilege(nsp.oid, 'USAGE') as has_usage FROM @@ -9,18 +9,8 @@ FROM WHERE {% if scid %} nsp.oid={{scid}}::oid AND - {% else %} - {% if not show_sysobj %} - nspname NOT LIKE 'pg!_%' escape '!' AND {% endif %} - {% endif %} - NOT ( + ( {{ CATALOGS.LIST('nsp') }} ) - - {% if schema_restrictions %} - AND - nsp.nspname in ({{schema_restrictions}}) - {% endif %} - -ORDER BY nspname; +ORDER BY 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/properties.sql new file mode 100644 index 000000000..897e76254 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/properties.sql @@ -0,0 +1,25 @@ +{% import 'catalog/pg/macros/catalogs.sql' as CATALOGS %} +SELECT + 2 AS nsptyp, + nsp.nspname AS name, + nsp.oid, + pg_catalog.array_to_string(nsp.nspacl::text[], ', ') as acl, + r.rolname AS namespaceowner, description, + pg_catalog.has_schema_privilege(nsp.oid, 'CREATE') AS can_create, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl +FROM + pg_catalog.pg_namespace nsp + LEFT OUTER JOIN pg_catalog.pg_description des ON + (des.objoid=nsp.oid AND des.classoid='pg_namespace'::regclass) + LEFT JOIN pg_catalog.pg_roles r ON (r.oid = nsp.nspowner) +WHERE + {% if scid %} + nsp.oid={{scid}}::oid AND + {% endif %} + ( +{{ CATALOGS.LIST('nsp') }} + ) +ORDER BY 1, nspname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/update.sql new file mode 100644 index 000000000..39f7f94c7 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/default/sql/update.sql @@ -0,0 +1,30 @@ +{% import 'macros/security.macros' as SECLABEL %} +{% if data %} +{# ==== To update catalog comments ==== #} +{% if data.description and data.description != o_data.description %} +COMMENT ON SCHEMA {{ conn|qtIdent(o_data.name) }} + IS {{ data.description|qtLiteral }}; + +{% endif %} +{# ==== To update catalog securitylabel ==== #} +{# The SQL generated below will change Security Label #} +{% if data.seclabels and data.seclabels|length > 0 %} +{% set seclabels = data.seclabels %} +{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} +{% for r in seclabels.deleted %} +{{ SECLABEL.DROP(conn, 'SCHEMA', o_data.name, r.provider) }} +{% endfor %} +{% endif %} +{% if 'added' in seclabels and seclabels.added|length > 0 %} +{% for r in seclabels.added %} +{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }} +{% endfor %} +{% endif %} +{% if 'changed' in seclabels and seclabels.changed|length > 0 %} +{% for r in seclabels.changed %} +{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }} +{% endfor %} +{% endif %} + +{% endif %} +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/allowed_privs.json similarity index 79% rename from web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/allowed_privs.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/allowed_privs.json index da14f3229..0d0b305e2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/allowed_privs.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/allowed_privs.json @@ -1,13 +1,13 @@ -{# List down allowed privileges for PostgreSQL/PPAS 9.1, or less #} +{# List of allowed privileges for PPAS 9.2 or later #} {# - Format for allowed privileges are: + Format for allowed privileges is: "acl_col": { "type": "name", "acl": [...] } #} { - "datacl": { + "nspacl": { "type": "DATABASE", "acl": ["c", "C", "T"] }, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/acl.sql similarity index 94% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/acl.sql index 58d0aff55..04b20a271 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/acl.sql @@ -20,5 +20,4 @@ FROM ) b LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname -ORDER BY grantee; +GROUP BY g.rolname, gt.rolname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/create.sql new file mode 100644 index 000000000..38c553228 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/create.sql @@ -0,0 +1,17 @@ +{% import 'macros/privilege.macros' as PRIVILEGE %} +{% if data %} +CREATE SCHEMA {{ conn|qtIdent(data.name) }} +{% if data.namespaceowner %} + AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}; + +{% endif %} +{% if data.description %} +COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} + IS {{ data.description|qtLiteral }}; + +{% endif %} +{% if data.nspacl %} +{% for priv in data.nspacl %} +{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} +{% endif %} +{% endif %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/get_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/get_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/get_name.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/get_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/is_catalog.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/is_catalog.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/is_catalog.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/is_catalog.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/nodes.sql similarity index 58% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/nodes.sql index 7f1c94796..83db58499 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/nodes.sql @@ -1,25 +1,17 @@ {% import 'catalog/ppas/macros/catalogs.sql' as CATALOGS %} SELECT nsp.oid, - nsp.nspname as name, +{{ CATALOGS.LABELS('nsp', _) }}, pg_catalog.has_schema_privilege(nsp.oid, 'CREATE') as can_create, pg_catalog.has_schema_privilege(nsp.oid, 'USAGE') as has_usage FROM pg_catalog.pg_namespace nsp WHERE - nsp.nspparent = 0 AND {% if scid %} nsp.oid={{scid}}::oid AND - {% else %} - {% if not show_sysobj %} - nspname NOT LIKE 'pg!_%' escape '!' AND {% endif %} - {% endif %} - NOT ( + nsp.nspparent = 0 AND + ( {{ CATALOGS.LIST('nsp') }} ) - {% if schema_restrictions %} - AND - nsp.nspname in ({{schema_restrictions}}) - {% endif %} -ORDER BY nspname; +ORDER BY 2; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/properties.sql new file mode 100644 index 000000000..2e1af5b06 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/properties.sql @@ -0,0 +1,27 @@ +{% import 'catalog/ppas/macros/catalogs.sql' as CATALOGS %} +SELECT + 2 AS nsptyp, + nsp.nspname AS name, + nsp.oid, + pg_catalog.array_to_string(nsp.nspacl::text[], ', ') as acl, + r.rolname AS namespaceowner, description, + pg_catalog.has_schema_privilege(nsp.oid, 'CREATE') AS can_create, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl, + (SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl, + (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels +FROM + pg_catalog.pg_namespace nsp + LEFT OUTER JOIN pg_catalog.pg_description des ON + (des.objoid=nsp.oid AND des.classoid='pg_namespace'::regclass) + LEFT JOIN pg_catalog.pg_roles r ON (r.oid = nsp.nspowner) +WHERE + {% if scid %} + nsp.oid={{scid}}::oid AND + {% endif %} + nsp.nspparent = 0 AND + ( +{{ CATALOGS.LIST('nsp') }} + ) +ORDER BY 1, nspname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/update.sql new file mode 100644 index 000000000..39f7f94c7 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/default/sql/update.sql @@ -0,0 +1,30 @@ +{% import 'macros/security.macros' as SECLABEL %} +{% if data %} +{# ==== To update catalog comments ==== #} +{% if data.description and data.description != o_data.description %} +COMMENT ON SCHEMA {{ conn|qtIdent(o_data.name) }} + IS {{ data.description|qtLiteral }}; + +{% endif %} +{# ==== To update catalog securitylabel ==== #} +{# The SQL generated below will change Security Label #} +{% if data.seclabels and data.seclabels|length > 0 %} +{% set seclabels = data.seclabels %} +{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} +{% for r in seclabels.deleted %} +{{ SECLABEL.DROP(conn, 'SCHEMA', o_data.name, r.provider) }} +{% endfor %} +{% endif %} +{% if 'added' in seclabels and seclabels.added|length > 0 %} +{% for r in seclabels.added %} +{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }} +{% endfor %} +{% endif %} +{% if 'changed' in seclabels and seclabels.changed|length > 0 %} +{% for r in seclabels.changed %} +{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }} +{% endfor %} +{% endif %} + +{% endif %} +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/defacl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/defacl.sql deleted file mode 100644 index bb7a1dffe..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/defacl.sql +++ /dev/null @@ -1,40 +0,0 @@ -SELECT - CASE (a.deftype) - WHEN 'r' THEN 'deftblacl' - WHEN 'S' THEN 'defseqacl' - WHEN 'f' THEN 'deffuncacl' - WHEN 'T' THEN 'deftypeacl' - ELSE 'UNKNOWN - ' || a.deftype::text - END AS deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(a.privilege_type) as privileges, pg_catalog.array_agg(a.is_grantable) as grantable -FROM - (SELECT - (acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable AS is_grantable, - CASE (acl).privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN - ' || (acl).privilege_type - END AS privilege_type, - defaclobjtype as deftype - FROM - (SELECT defaclobjtype, pg_catalog.aclexplode(defaclacl) as acl - FROM - pg_catalog.pg_namespace nsp - LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid) - WHERE - nsp.oid={{scid}}::oid - ) d) a - LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname, a.deftype -ORDER BY a.deftype; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/properties.sql deleted file mode 100644 index eacc48fa9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/properties.sql +++ /dev/null @@ -1,57 +0,0 @@ -{% import 'catalog/pg/macros/catalogs.sql' as CATALOGS %} -SELECT - CASE - WHEN (nspname LIKE E'pg\\_temp\\_%') THEN 1 - WHEN (nspname LIKE E'pg\\_%') THEN 0 - ELSE 3 END AS nsptyp, - nsp.nspname AS name, - nsp.oid, - pg_catalog.array_to_string(nsp.nspacl::text[], ', ') as acl, - r.rolname AS namespaceowner, description, - pg_catalog.has_schema_privilege(nsp.oid, 'CREATE') AS can_create, - {### Default ACL for Tables ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid - ), ', ')) AS tblacl, - {### Default ACL for Sequnces ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid - ), ', ')) AS seqacl, - {### Default ACL for Functions ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid - ), ', ')) AS funcacl, - {### Default ACL for Type ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid - ), ', ')) AS typeacl, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels -FROM - pg_catalog.pg_namespace nsp - LEFT OUTER JOIN pg_catalog.pg_description des ON - (des.objoid=nsp.oid AND des.classoid='pg_namespace'::regclass) - LEFT JOIN pg_catalog.pg_roles r ON (r.oid = nsp.nspowner) -WHERE - {% if scid %} - nsp.oid={{scid}}::oid AND - {% else %} - {% if not show_sysobj %} - nspname NOT LIKE E'pg\\_%' AND - {% endif %} - {% endif %} - NOT ( -{{ CATALOGS.LIST('nsp') }} - ) - {% if schema_restrictions %} - AND - nsp.nspname in ({{schema_restrictions}}) - {% endif %} -ORDER BY 1, nspname; 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 deleted file mode 100644 index e04140875..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/update.sql +++ /dev/null @@ -1,91 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{# Rename the schema #} -{% if data.name and data.name != o_data.name %} -ALTER SCHEMA {{ conn|qtIdent(o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; - -{% endif %} -{# Change the owner #} -{% if data.namespaceowner and data.namespaceowner != o_data.namespaceowner %} -ALTER SCHEMA {{ conn|qtIdent(data.name) }} - OWNER TO {{ conn|qtIdent(data.namespaceowner) }}; - -{% endif %} -{# Update the comments/description #} -{% if data.description is defined and data.description != o_data.description %} -COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; - -{% endif %} -{# Change the privileges #} -{% if data.nspacl %} -{% if 'deleted' in data.nspacl %} -{% for priv in data.nspacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.nspacl %} -{% for priv in data.nspacl.added %} -{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} -{# Change the default privileges #} -{% for defacl, type in [ - ('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'), - ('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')] -%} -{% if data[defacl] %}{% set acl = data[defacl] %} -{% if 'deleted' in acl %} -{% for priv in acl.deleted %} -{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee, priv.grantor) }} -{% endfor %} -{% 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, priv.grantor) }} -{% else %} -{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, type, priv.grantee, priv.grantor) }} -{% endif %} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in acl %} -{% for priv in acl.added %} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, type, priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} -{% endfor %} -{# Change the security labels #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'SCHEMA', data.name, r.provider) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/allowed_privs.json index b51c50eaf..0c1784a5b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/allowed_privs.json +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/allowed_privs.json @@ -1,4 +1,4 @@ -{# List of allowed privileges for PostgreSQL 9.1 #} +{# List of allowed privileges for PostgreSQL 9.2 or later #} {# Format for allowed privileges is: "acl_col": { @@ -22,5 +22,9 @@ "deffuncacl": { "type": "FUNCTION", "acl": ["X"] + }, + "deftypeacl": { + "type": "TYPE", + "acl": ["U"] } } diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql index f148797cc..bbbb2477c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/create.sql @@ -20,7 +20,7 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {# Default privileges on tables #} {% for defacl, type in [ ('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'), - ('deffuncacl', 'FUNCTIONS')] + ('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')] %} {% if data[defacl] %}{% set acl = data[defacl] %} {% for priv in acl %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/defacl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/defacl.sql index c9a7e98e4..bb7a1dffe 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/defacl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/defacl.sql @@ -3,6 +3,7 @@ SELECT WHEN 'r' THEN 'deftblacl' WHEN 'S' THEN 'defseqacl' WHEN 'f' THEN 'deffuncacl' + WHEN 'T' THEN 'deftypeacl' ELSE 'UNKNOWN - ' || a.deftype::text END AS deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(a.privilege_type) as privileges, pg_catalog.array_agg(a.is_grantable) as grantable @@ -22,7 +23,7 @@ FROM WHEN 'TRUNCATE' THEN 'D' WHEN 'UPDATE' THEN 'w' WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' + ELSE 'UNKNOWN - ' || (acl).privilege_type END AS privilege_type, defaclobjtype as deftype FROM diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/nodes.sql index 200204f54..ca557164e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/nodes.sql @@ -17,4 +17,10 @@ WHERE NOT ( {{ CATALOGS.LIST('nsp') }} ) + + {% if schema_restrictions %} + AND + nsp.nspname in ({{schema_restrictions}}) + {% endif %} + ORDER BY nspname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/properties.sql index 235df7624..eacc48fa9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/default/sql/properties.sql @@ -27,6 +27,12 @@ SELECT FROM pg_catalog.pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid ), ', ')) AS funcacl, + {### Default ACL for Type ###} + (SELECT pg_catalog.array_to_string(ARRAY( + SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') + FROM pg_catalog.pg_default_acl + WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid + ), ', ')) AS typeacl, (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels FROM pg_catalog.pg_namespace nsp @@ -44,4 +50,8 @@ WHERE NOT ( {{ CATALOGS.LIST('nsp') }} ) + {% if schema_restrictions %} + AND + nsp.nspname in ({{schema_restrictions}}) + {% endif %} ORDER BY 1, nspname; 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 315dc312d..e04140875 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 @@ -45,7 +45,7 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} {# Change the default privileges #} {% for defacl, type in [ ('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'), - ('deffuncacl', 'FUNCTIONS')] + ('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')] %} {% if data[defacl] %}{% set acl = data[defacl] %} {% if 'deleted' in acl %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/allowed_privs.json deleted file mode 100644 index 2cf5c728c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/allowed_privs.json +++ /dev/null @@ -1,26 +0,0 @@ -{# List of allowed privileges for PPAS 9.1 #} -{# - Format for allowed privileges is: - "acl_col": { - "type": "name", - "acl": [...] - } -#} -{ - "nspacl": { - "type": "SCHEMA", - "acl": ["C", "U"] - }, - "deftblacl": { - "type": "TABLE", - "acl": ["r", "a", "w", "d", "D", "x", "t"] - }, - "defseqacl": { - "type": "SEQUENCE", - "acl": ["U", "r", "w"] - }, - "deffuncacl": { - "type": "FUNCTION", - "acl": ["X"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/create.sql deleted file mode 100644 index 7b3367f1c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/create.sql +++ /dev/null @@ -1,40 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data.name %} -CREATE SCHEMA{% if add_not_exists_clause %} IF NOT EXISTS {% endif %} {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %} - - AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %}; -{# Alter the comment/description #} -{% if data.description %} - -COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif %} -{# ACL for the schema #} -{% if data.nspacl %} -{% for priv in data.nspacl %} - -{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} -{% endif %} -{# Default privileges on tables #} -{% for defacl, type in [ - ('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'), - ('deffuncacl', 'FUNCTIONS')] -%} -{% if data[defacl] %}{% set acl = data[defacl] %} -{% for priv in acl %} - -{{ DEFAULT_PRIVILEGE.SET( - conn, 'SCHEMA', data.name, type, priv.grantee, - priv.without_grant, priv.with_grant, priv.grantor - ) }}{% endfor %} -{% endif %} -{% endfor %} -{# Security Labels on schema #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% for r in data.seclabels %} - -{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/defacl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/defacl.sql deleted file mode 100644 index e15775bfd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/defacl.sql +++ /dev/null @@ -1,39 +0,0 @@ -SELECT - CASE (a.deftype) - WHEN 'r' THEN 'deftblacl' - WHEN 'S' THEN 'defseqacl' - WHEN 'f' THEN 'deffuncacl' - ELSE 'UNKNOWN - ' || a.deftype::text - END AS deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(a.privilege_type) as privileges, pg_catalog.array_agg(a.is_grantable) as grantable -FROM - (SELECT - (acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable AS is_grantable, - CASE (acl).privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN - ' || (acl).privilege_type - END AS privilege_type, - defaclobjtype as deftype - FROM - (SELECT defaclobjtype, pg_catalog.aclexplode(defaclacl) as acl - FROM - pg_catalog.pg_namespace nsp - LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid) - WHERE - nsp.oid={{scid}}::oid - ) d) a - LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname, a.deftype -ORDER BY a.deftype; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/delete.sql deleted file mode 100644 index 75e9a8b4d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/delete.sql +++ /dev/null @@ -1 +0,0 @@ -DROP SCHEMA IF EXISTS {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/oid.sql deleted file mode 100644 index 9528a26fe..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/oid.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT nsp.oid FROM pg_catalog.pg_namespace nsp WHERE nsp.nspname = {{ schema|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/properties.sql deleted file mode 100644 index 1a81b07b9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/properties.sql +++ /dev/null @@ -1,51 +0,0 @@ -{% import 'catalog/ppas/macros/catalogs.sql' as CATALOGS %} -SELECT - CASE - WHEN (nspname LIKE E'pg\\_temp\\_%') THEN 1 - WHEN (nspname LIKE E'pg\\_%') THEN 0 - ELSE 3 END AS nsptyp, - nsp.nspname AS name, - nsp.oid, - pg_catalog.array_to_string(nsp.nspacl::text[], ', ') as acl, - r.rolname AS namespaceowner, description, - pg_catalog.has_schema_privilege(nsp.oid, 'CREATE') AS can_create, - {### Default ACL for Tables ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid - ), ', ')) AS tblacl, - {### Default ACL for Sequnces ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid - ), ', ')) AS seqacl, - {### Default ACL for Functions ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid - ), ', ')) AS funcacl -FROM - pg_catalog.pg_namespace nsp - LEFT OUTER JOIN pg_catalog.pg_description des ON - (des.objoid=nsp.oid AND des.classoid='pg_namespace'::regclass) - LEFT JOIN pg_catalog.pg_roles r ON (r.oid = nsp.nspowner) -WHERE - {% if scid %} - nsp.oid={{scid}}::oid AND - {% else %} - {% if not show_sysobj %} - nspname NOT LIKE E'pg\\_%' AND - {% endif %} - {% endif %} - nsp.nspparent = 0 AND - NOT ( -{{ CATALOGS.LIST('nsp') }} - ) - {% if schema_restrictions %} - AND - nsp.nspname in ({{schema_restrictions}}) - {% endif %} -ORDER BY 1, nspname; 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 deleted file mode 100644 index 9a263662e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/update.sql +++ /dev/null @@ -1,133 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data %} -{### To update SCHEMA name ###} -{% if data.name and data.name != o_data.name %} -ALTER SCHEMA {{ conn|qtIdent(o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; - -{% endif %} -{### To update SCHEMA owner ###} -{% if data.namespaceowner and data.namespaceowner != o_data.namespaceowner %} -ALTER SCHEMA {{ conn|qtIdent(data.name) }} - OWNER TO {{ conn|qtIdent(data.namespaceowner) }}; - -{% endif %} -{### To update SCHEMA comments ###} -{% if data.description is defined and data.description != o_data.description %} -COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; - -{% endif %} -{### Change the security labels ###} -{# The SQL generated below will change Security Label #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'SCHEMA', data.name, r.provider) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} - -{% endif %} -{### Change the privileges ###} -{% if data.nspacl %} -{% if 'deleted' in data.nspacl %} -{% for priv in data.nspacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'SCHEMA', priv.grantee, data.name) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.nspacl %} -{% for priv in data.nspacl.added %} -{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} - -{% endif %} -{### To change default privileges for tables ###} -{% if data.deftblacl %} -{% if 'deleted' in data.deftblacl %} -{% for priv in data.deftblacl.deleted %} -{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee, priv.grantor) }} -{% endfor %} -{% 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, priv.grantor) }} -{% else %} -{{ DEFAULT_PRIVILEGE.UNSET(conn, 'SCHEMA', data.name, 'TABLES', priv.grantee, priv.grantor) }} -{% endif %} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deftblacl %} -{% for priv in data.deftblacl.added %} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} - -{% endif %} -{### To change default privileges for sequences ###} -{% if data.defseqacl %} -{% if 'deleted' in data.defseqacl %} -{% for priv in data.defseqacl.deleted %} -{{ DEFAULT_PRIVILEGE.UNSET(conn,'SCHEMA', data.name, 'SEQUENCES', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.defseqacl %} -{% for priv in data.defseqacl.changed %} -{{ DEFAULT_PRIVILEGE.UNSET(conn,'SCHEMA', data.name, 'SEQUENCES', priv.grantee, priv.grantor) }} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.defseqacl %} -{% for priv in data.defseqacl.added %} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} - -{% endif %} -{### To change default privileges for functions ###} -{% if data.deffuncacl %} -{% if 'deleted' in data.deffuncacl %} -{% for priv in data.deffuncacl.deleted %} -{{ DEFAULT_PRIVILEGE.UNSET(conn,'SCHEMA', data.name, 'FUNCTIONS', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deffuncacl %} -{% for priv in data.deffuncacl.changed %} -{{ DEFAULT_PRIVILEGE.UNSET(conn,'SCHEMA', data.name, 'FUNCTIONS', priv.grantee, priv.grantor) }} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deffuncacl %} -{% for priv in data.deffuncacl.added %} -{{ DEFAULT_PRIVILEGE.SET(conn,'SCHEMA', data.name, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} - -{% endif %} -{### End main if data ###} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/create.sql deleted file mode 100644 index bbbb2477c..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/create.sql +++ /dev/null @@ -1,40 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data.name %} -CREATE SCHEMA{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %} - - AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %}; -{# Alter the comment/description #} -{% if data.description %} - -COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; -{% endif %} -{# ACL for the schema #} -{% if data.nspacl %} -{% for priv in data.nspacl %} - -{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %} -{% endif %} -{# Default privileges on tables #} -{% for defacl, type in [ - ('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'), - ('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')] -%} -{% if data[defacl] %}{% set acl = data[defacl] %} -{% for priv in acl %} - -{{ DEFAULT_PRIVILEGE.SET( - conn, 'SCHEMA', data.name, type, priv.grantee, - priv.without_grant, priv.with_grant, priv.grantor - ) }}{% endfor %} -{% endif %} -{% endfor %} -{# Security Labels on schema #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% for r in data.seclabels %} - -{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/delete.sql deleted file mode 100644 index 75e9a8b4d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/delete.sql +++ /dev/null @@ -1 +0,0 @@ -DROP SCHEMA IF EXISTS {{ conn|qtIdent(name) }} {% if cascade %}CASCADE{%endif%}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/oid.sql deleted file mode 100644 index 9528a26fe..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/oid.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT nsp.oid FROM pg_catalog.pg_namespace nsp WHERE nsp.nspname = {{ schema|qtLiteral }}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/allowed_privs.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/allowed_privs.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/allowed_privs.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/defacl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/defacl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/defacl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/defacl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/delete.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/delete.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/delete.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/get_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/get_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/get_name.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/get_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/is_catalog.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/is_catalog.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/is_catalog.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/is_catalog.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.1_plus/sql/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/pg/9.2_plus/sql/oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/properties.sql 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/default/sql/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/9.2_plus/sql/update.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schemas/ppas/default/sql/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_add_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_add_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_add_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_add_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_add_priv_msql.sql 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/default/alter_schema_drop_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_drop_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_drop_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_drop_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_drop_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_name_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_name_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_name_msql.sql 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/default/alter_schema_update_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_update_priv.sql 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/default/alter_schema_update_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/alter_schema_update_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/alter_schema_update_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_with_comment.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_with_comment.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_with_comment_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/create_schema_with_comment_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/create_schema_with_comment_msql.sql 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/default/test_schema.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/9.2_plus/test_schema.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/pg/default/test_schema.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_add_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_add_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_add_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_add_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_add_priv_msql.sql 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/default/alter_schema_drop_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_drop_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_drop_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_drop_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_drop_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_name_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_name_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_name_msql.sql 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/default/alter_schema_update_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_update_priv.sql 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/default/alter_schema_update_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/alter_schema_update_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/alter_schema_update_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_all_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_all_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_all_options_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_all_options_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_all_options_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_with_comment.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_with_comment.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_with_comment_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/create_schema_with_comment_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/create_schema_with_comment_msql.sql 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/default/test_schema.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/9.2_plus/test_schema.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/tests/ppas/default/test_schema.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py index 210feab16..7fd1a660b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py @@ -1773,19 +1773,16 @@ class MViewNode(ViewNode, VacuumSettings): @staticmethod def ppas_template_path(ver): """ - Returns the template path for EDB Advanced servers. + Returns the template path for PPAS servers. """ - return 'ppas/9.3_plus' + return 'ppas/#{0}#'.format(ver) @staticmethod def pg_template_path(ver): """ Returns the template path for PostgreSQL servers. """ - return 'pg/{0}'.format( - '9.4_plus' if ver >= 90400 else - '9.3_plus' - ) + return 'pg/#{0}#'.format(ver) @staticmethod def merge_to_vacuum_data(old_data, data, vacuum_key): diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/refresh.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/refresh.sql deleted file mode 100644 index 0dcb67b64..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/refresh.sql +++ /dev/null @@ -1,2 +0,0 @@ -{#= Refresh materialized view ===#} -REFRESH MATERIALIZED VIEW {{ conn|qtIdent(nspname, name) }} WITH {% if not with_data %} NO {% endif %}DATA; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/acl.sql deleted file mode 100644 index c48706cc1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/acl.sql +++ /dev/null @@ -1,41 +0,0 @@ -{#============================Get ACLs=========================#} -{% if vid %} -SELECT - 'datacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, - d.grantor, - d.is_grantable, - CASE d.privilege_type - WHEN 'DELETE' THEN 'd' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TRIGGER' THEN 't' - WHEN 'UPDATE' THEN 'w' - WHEN 'TRUNCATE' THEN 'D' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - relacl - FROM - pg_catalog.pg_class cl - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON - (cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass) - WHERE - cl.oid = {{ vid }}::OID AND relkind = 'm' - ) acl, - pg_catalog.aclexplode(relacl) d - ) d -LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY - g.rolname, - gt.rolname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/properties.sql deleted file mode 100644 index d63c1b7cd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/properties.sql +++ /dev/null @@ -1,109 +0,0 @@ -{# ========================== Fetch Materialized View Properties ========================= #} -{% if (vid and datlastsysoid) or scid %} -SELECT - c.oid, - c.xmin, - c.relname AS name, - c.reltablespace AS spcoid, - c.relispopulated AS with_data, - CASE WHEN length(spcname::text) > 0 THEN spcname ELSE - (SELECT sp.spcname FROM pg_catalog.pg_database dtb - JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid - WHERE dtb.oid = {{ did }}::oid) - END as spcname, - c.relacl, - nsp.nspname as schema, - pg_catalog.pg_get_userbyid(c.relowner) AS owner, - description AS comment, - pg_catalog.pg_get_viewdef(c.oid, true) AS definition, - {# ============= Checks if it is system view ================ #} - {% if vid and datlastsysoid %} - CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, - {% endif %} - pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=c.oid AND sl1.objsubid=0) AS seclabels, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'fillfactor=([0-9]*)') AS fillfactor, - (substring(pg_catalog.array_to_string(c.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age, - (substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age, - substring(pg_catalog.array_to_string(tst.reloptions, ',') - FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, - c.reloptions AS reloptions, tst.reloptions AS toast_reloptions, - (CASE WHEN c.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable -FROM - pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) -LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = c.reltoastrelid - WHERE ((c.relhasrules AND (EXISTS ( - SELECT - r.rulename - FROM - pg_catalog.pg_rewrite r - WHERE - ((r.ev_class = c.oid) - AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar)) ))) - AND (c.relkind = 'm'::char) - ) -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -ORDER BY - c.relname -{% endif %} - -{% elif type == 'roles' %} -SELECT - pr.rolname -FROM - pg_catalog.pg_roles pr -WHERE - pr.rolcanlogin -ORDER BY - pr.rolname - -{% elif type == 'schemas' %} -SELECT - nsp.nspname -FROM - pg_catalog.pg_namespace nsp -WHERE - (nsp.nspname NOT LIKE E'pg\\_%' - AND nsp.nspname != 'information_schema') -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/allowed_privs.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/allowed_privs.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/allowed_privs.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/delete.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/delete.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/delete.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/get_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/get_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/get_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/get_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/get_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/get_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/get_view_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/get_view_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/get_view_name.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/get_view_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/grant.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/grant.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/grant.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/properties.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/refresh.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/refresh.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/refresh.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/refresh.sql 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/default/sql/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/update.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/view_id.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/view_id.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/default/sql/view_id.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/allowed_privs.json deleted file mode 100644 index f01bb73c1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/allowed_privs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "datacl": { - "type": "MVIEW", - "acl": ["a", "r", "w", "d", "D", "x", "t"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/create.sql deleted file mode 100644 index bfb807a5e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/create.sql +++ /dev/null @@ -1,45 +0,0 @@ -{# ===================== Create new view ===================== #} -{% if display_comments %} --- View: {{ data.schema }}.{{ data.name }} - --- DROP MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }}; - -{% endif %} -{% if data.name and data.schema and data.definition %} -CREATE MATERIALIZED VIEW{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }} -{% if(data.fillfactor or data.autovacuum_enabled in ('t', 'f') or data.toast_autovacuum_enabled in ('t', 'f') or data['vacuum_data']|length > 0) %} -{% set ns = namespace(add_comma=false) %} -WITH ( -{% if data.fillfactor %} - FILLFACTOR = {{ data.fillfactor }}{% set ns.add_comma = true%}{% endif %}{% if data.autovacuum_enabled in ('t', 'f') %} -{% if ns.add_comma %}, -{% endif %} - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %}{% if data.toast_autovacuum_enabled in ('t', 'f') %} -{% if ns.add_comma %}, -{% endif %} - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}TRUE{% else %}FALSE{% endif %}{% set ns.add_comma = true%}{% endif %} -{% for field in data['vacuum_data'] %} -{% if field.value is defined and field.value != '' and field.value != none %} -{% if ns.add_comma %}, -{% endif %} {{ field.name }} = {{ field.value|lower }}{% set ns.add_comma = true%}{% endif %}{% endfor %} -{{ '\n' }}) -{% endif %} -{% if data.spcname %}TABLESPACE {{ data.spcname }} -{% endif %}AS -{{ data.definition.rstrip(';') }} -{% if data.with_data %} -WITH DATA; -{% else %} -WITH NO DATA; -{% endif %} -{% if data.owner %} - -ALTER TABLE IF EXISTS {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.comment %} - -COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/delete.sql deleted file mode 100644 index 2f45fceeb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/delete.sql +++ /dev/null @@ -1,13 +0,0 @@ -{# =================== Drop/Cascade materialized view by name ====================#} -{% if vid %} -SELECT - c.relname As name, - nsp.nspname -FROM - pg_catalog.pg_class c -LEFT JOIN pg_catalog.pg_namespace nsp ON c.relnamespace = nsp.oid -WHERE - c.relfilenode = {{ vid }}; -{% elif (name and nspname) %} -DROP MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(nspname, name) }} {% if cascade %} CASCADE {% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_schema.sql deleted file mode 100644 index df31e8e71..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -{# ===== fetch schema name =====#} -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_view_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_view_name.sql deleted file mode 100644 index 87bb97cb5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_view_name.sql +++ /dev/null @@ -1,11 +0,0 @@ -{# ===== get view name against view id ==== #} -{% if vid %} -SELECT - c.relname AS name, - nsp.nspname AS schema -FROM - pg_catalog.pg_class c - LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE - c.oid = {{vid}} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/grant.sql deleted file mode 100644 index c8228cb89..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/grant.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Grant Permissions to User Role on Views/Tables ==== #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# We will generate Security Label SQL using macro #} -{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}{% endfor %}{% endif %} -{% if data.datacl %}{% for priv in data.datacl %}{{ 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/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/nodes.sql deleted file mode 100644 index 2244f67b0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - c.oid, - c.relname AS name -FROM pg_catalog.pg_class c -WHERE - c.relkind = 'm' -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - c.relname -{% 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 deleted file mode 100644 index e3fb4719b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/update.sql +++ /dev/null @@ -1,199 +0,0 @@ -{# ===================== Update View ===================#} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{%- if data -%} -{% set view_name = data.name if data.name else o_data.name %} -{% set view_schema = data.schema if data.schema else o_data.schema %} -{% set def = data.definition.rstrip(';') if data.definition %} -{# ===== Rename mat view ===== #} -{% if data.name and data.name != o_data.name %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; - -{% endif %} -{# ===== Alter schema view ===== #} -{% if data.schema and data.schema != o_data.schema %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, view_name ) }} - SET SCHEMA {{ conn|qtIdent(data.schema) }}; - -{% endif %} -{# ===== Alter Table owner ===== #} -{% if data.owner and data.owner != o_data.owner %} -ALTER TABLE IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; - -{% endif %} -{# ===== First Drop and then create mat view ===== #} -{% if def and def != o_data.definition.rstrip(';') %} -DROP MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }}; -CREATE MATERIALIZED VIEW IF NOT EXISTS {{ conn|qtIdent(view_schema, view_name) }} -{% if data.fillfactor or o_data.fillfactor %} -WITH( -{% if data.fillfactor %} - FILLFACTOR = {{ data.fillfactor }}{% if (data['vacuum_data'] is defined and data['vacuum_data']['changed']|length > 0) %},{% endif %} -{% elif o_data.fillfactor %} - FILLFACTOR = {{ o_data.fillfactor }}{% if (data['vacuum_data'] is defined and data['vacuum_data']['changed']|length > 0) %},{% endif %} -{% endif %} - -{% if data['vacuum_data']['changed']|length > 0 %} -{% for field in data['vacuum_data']['changed'] %} {{ field.name }} = {{ field.value|lower }}{% if not loop.last %}, -{% endif %} -{% endfor %} -{% endif %} -) -{% endif %} - AS -{{ def }} -{% if data.with_data is defined %} - WITH {{ 'DATA' if data.with_data else 'NO DATA' }}; -{% elif o_data.with_data is defined %} - WITH {{ 'DATA' if o_data.with_data else 'NO DATA' }}; - -{% endif %} -{% if o_data.comment and not data.comment %} -COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ o_data.comment|qtLiteral }}; -{% endif %} -{% else %} -{# ======= Alter Tablespace ========= #} -{%- if data.spcoid and o_data.spcoid != data.spcoid -%} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} - SET TABLESPACE {{ data.spcoid }}; - -{% endif %} -{# ======= SET/RESET Fillfactor ========= #} -{% if data.fillfactor and o_data.fillfactor != data.fillfactor %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} -SET( - FILLFACTOR = {{ data.fillfactor }} -); - -{% elif data.fillfactor == '' and o_data.fillfactor|default('', 'true') != data.fillfactor %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} -RESET( - FILLFACTOR -); - -{% endif %} -{# ===== Check for with_data property ===== #} -{% if data.with_data is defined and o_data.with_data|lower != data.with_data|lower %} -REFRESH MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} WITH{{ ' NO' if data.with_data|lower == 'false' else '' }} DATA; - -{% endif %} -{# ===== Check for Autovacuum options ===== #} -{% if data.autovacuum_custom is defined and data.autovacuum_custom == False %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} RESET( - autovacuum_enabled, - autovacuum_vacuum_threshold, - autovacuum_analyze_threshold, - autovacuum_vacuum_scale_factor, - autovacuum_analyze_scale_factor, - autovacuum_vacuum_cost_delay, - autovacuum_vacuum_cost_limit, - autovacuum_freeze_min_age, - autovacuum_freeze_max_age, - autovacuum_freeze_table_age -); - -{% endif %} - -{% if data.toast_autovacuum is defined and data.toast_autovacuum == False %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} RESET( - toast.autovacuum_enabled, - toast.autovacuum_vacuum_threshold, - toast.autovacuum_analyze_threshold, - toast.autovacuum_vacuum_scale_factor, - toast.autovacuum_analyze_scale_factor, - toast.autovacuum_vacuum_cost_delay, - toast.autovacuum_vacuum_cost_limit, - toast.autovacuum_freeze_min_age, - toast.autovacuum_freeze_max_age, - toast.autovacuum_freeze_table_age -); - -{% endif %}{#-- toast_endif ends --#} -{% if data['vacuum_data']['changed']|length > 0 or data.autovacuum_enabled in ('t', 'f') or data.toast_autovacuum_enabled in ('t', 'f') %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(data.schema, data.name) }} SET( -{% if data.autovacuum_enabled in ('t', 'f') %} - autovacuum_enabled = {% if data.autovacuum_enabled == 't' %}true{% else %}false{% endif %}{% if data['vacuum_data']['changed']|length > 0 or data.toast_autovacuum_enabled in ('t', 'f') %}, -{% endif %} -{% endif %} -{% if data.toast_autovacuum_enabled in ('t', 'f') %} - toast.autovacuum_enabled = {% if data.toast_autovacuum_enabled == 't' %}true{% else %}false{% endif %}{% if data['vacuum_data']['changed']|length > 0 %}, -{% endif %} -{% endif %} -{% for field in data['vacuum_data']['changed'] %} -{% if field.value != None %} {{ field.name }} = {{ field.value|lower }}{% if not loop.last %}, -{% endif %} -{% endif %} -{% endfor %} - -); -{% endif %} -{% if data['vacuum_data']['reset']|length > 0 or data.autovacuum_enabled == 'x' or data.toast_autovacuum_enabled == 'x' %} -ALTER MATERIALIZED VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} RESET( -{% if data.autovacuum_enabled == 'x' %} - autovacuum_enabled{% if data['vacuum_data']['reset']|length > 0 or data.toast_autovacuum_enabled == 'x' %}, -{% endif %} -{% endif %} -{% if data.toast_autovacuum_enabled == 'x' %} - toast.autovacuum_enabled{% if data['vacuum_data']['reset']|length > 0 %}, -{% endif %} -{% endif %} -{% for field in data['vacuum_data']['reset'] %} {{ field.name }}{% if not loop.last %}, -{% endif %} -{% endfor %} - -); -{% endif %} -{# ===== End check for custom autovacuum ===== #} -{% endif %}{# ===== End block for check data definition ===== #} -{% set old_comment = o_data.comment|default('', true) %} -{% if (data.comment is defined and (data.comment != old_comment)) %} - -COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{# ============= The SQL generated below will change privileges ============= #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{# ============== The SQL generated below will change Security Label ========= #} -{% if data.seclabels is not none and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'MATERIALIZED VIEW', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/view_id.sql deleted file mode 100644 index fe4c57a0e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/view_id.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Below will provide view id for last created view ==== #} -{% if data %} -SELECT c.oid, c.relname FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = {{ data.schema|qtLiteral }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/allowed_privs.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/allowed_privs.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/allowed_privs.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.3_plus/sql/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/delete.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/delete.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/delete.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/get_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/get_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/get_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/get_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/get_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/get_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/get_view_name.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/get_view_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/get_view_name.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/get_view_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/grant.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/grant.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/grant.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/properties.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/refresh.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/refresh.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/refresh.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/refresh.sql 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/ppas/default/sql/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/update.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/view_id.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/9.4_plus/sql/view_id.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/default/sql/view_id.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/acl.sql deleted file mode 100644 index 59de7eff9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/acl.sql +++ /dev/null @@ -1,51 +0,0 @@ -{# ============================ Get ACLs ========================= #} -{% if vid %} -SELECT - 'datacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'DELETE' THEN 'd' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TRIGGER' THEN 't' - WHEN 'UPDATE' THEN 'w' - WHEN 'TRUNCATE' THEN 'D' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - relacl - FROM - pg_catalog.pg_class cl - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass) - WHERE - cl.oid = {{ vid }}::OID AND relkind = 'v' - ) acl, - (SELECT - (d).grantee AS grantee, - (d).grantor AS grantor, - (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM - (SELECT - pg_catalog.aclexplode(relacl) AS d - FROM - pg_catalog.pg_class cl1 - WHERE - cl1.oid = {{ vid }} - ) a - ) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY - g.rolname, gt.rolname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/create.sql deleted file mode 100644 index 1f5a923da..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/create.sql +++ /dev/null @@ -1,20 +0,0 @@ -{#============================Create new view=========================#} -{% if display_comments %} --- View: {{ data.schema }}.{{ data.name }} - --- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; - -{% endif %} -{% if data.name and data.schema and data.definition %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }} AS -{{ data.definition.rstrip(';') }}; -{% if data.owner %} - -ALTER TABLE {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.comment %} -COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/delete.sql deleted file mode 100644 index 6b0305b18..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/delete.sql +++ /dev/null @@ -1,13 +0,0 @@ -{# ====================== Drop/Cascade view by name ===================== #} -{% if vid %} -SELECT - c.relname AS name, - nsp.nspname -FROM - pg_catalog.pg_class c -LEFT JOIN pg_catalog.pg_namespace nsp ON c.relnamespace = nsp.oid -WHERE - c.relfilenode = {{ vid }}; -{% elif (name and nspname) %} -DROP VIEW {{ conn|qtIdent(nspname, name) }} {% if cascade %} CASCADE {% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/properties.sql deleted file mode 100644 index 651ae1140..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/properties.sql +++ /dev/null @@ -1,63 +0,0 @@ -{% if (vid and datlastsysoid) or scid %} -SELECT - c.oid, - c.xmin, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, - c.relname AS name, - nsp.nspname AS schema, - description AS comment, - c.reltablespace AS spcoid, - pg_catalog.pg_get_userbyid(c.relowner) AS owner, - pg_catalog.pg_get_viewdef(c.oid, true) AS definition, - pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, - {#=============Checks if it is system view================#} - {% if vid and datlastsysoid %} - CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, - {% endif %} - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabels sl1 - WHERE - sl1.objoid=c.oid AND sl1.objsubid=0 - ) AS seclabels, -FROM pg_class c - LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace - LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace - LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) -WHERE ((c.relhasrules - AND - (EXISTS( - SELECT - r.rulename - FROM - pg_catalog.pg_rewrite r - WHERE - ((r.ev_class = c.oid) AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar)) - )) - ) AND (c.relkind = 'v'::char)) -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid ORDER BY c.relname -{% endif %} - -{% elif type == 'roles' %} -SELECT - pr.rolname -FROM - pg_catalog.pg_roles pr -WHERE - pr.rolcanlogin -ORDER BY - pr.rolname - -{% elif type == 'schemas' %} -SELECT - nsp.nspname -FROM - pg_catalog.pg_namespace nsp -WHERE - (nsp.nspname NOT LIKE E'pg\\_%' - AND nsp.nspname != 'information_schema') -{% 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 deleted file mode 100644 index ee8072484..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/update.sql +++ /dev/null @@ -1,71 +0,0 @@ -{# ============================ Update View ========================= #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set view_name = data.name if data.name else o_data.name %} -{% set view_schema = data.schema if data.schema else o_data.schema %} -{% set def = data.definition.rstrip(';') if data.definition %} -{% if data.name and data.name != o_data.name %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.schema and data.schema != o_data.schema %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, view_name ) }} - SET SCHEMA {{ conn|qtIdent(data.schema) }}; -{% endif %} -{% if data.owner and data.owner != o_data.owner %} -ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if def and def != o_data.definition.rstrip(';') %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} - AS{{ def }}; -{% endif %} -{% set old_comment = o_data.comment|default('', true) %} -{% if (data.comment is defined and (data.comment != old_comment)) %} -COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{# The SQL generated below will change privileges #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{# The SQL generated below will change Security Label #} -{% if data.seclabels is not none and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/acl.sql deleted file mode 100644 index 38f5400e1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/acl.sql +++ /dev/null @@ -1,52 +0,0 @@ -{# ============================ Get ACLs ========================= #} -{% if vid %} -SELECT - 'datacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'DELETE' THEN 'd' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TRIGGER' THEN 't' - WHEN 'UPDATE' THEN 'w' - WHEN 'TRUNCATE' THEN 'D' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - relacl - FROM - pg_catalog.pg_class cl - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass) - WHERE - cl.oid = {{ vid }}::OID AND relkind = 'v' - ) acl, - (SELECT - (d).grantee AS grantee, - (d).grantor AS grantor, - (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM - (SELECT - pg_catalog.aclexplode(relacl) AS d - FROM - pg_catalog.pg_class cl1 - WHERE - cl1.oid = {{ vid }} - ) a - ) d - ) d -LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY - g.rolname, - gt.rolname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/create.sql deleted file mode 100644 index 461168703..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/create.sql +++ /dev/null @@ -1,24 +0,0 @@ -{#============================Create new view=========================#} -{% if display_comments %} --- View: {{ data.schema }}.{{ data.name }} - --- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; - -{% endif %} -{% if data.name and data.schema and data.definition %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %} -WITH ( -{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %} -){% endif %} AS -{{ data.definition.rstrip(';') }}; -{% if data.owner %} - -ALTER TABLE {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.comment %} - -COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/delete.sql deleted file mode 100644 index 6b0305b18..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/delete.sql +++ /dev/null @@ -1,13 +0,0 @@ -{# ====================== Drop/Cascade view by name ===================== #} -{% if vid %} -SELECT - c.relname AS name, - nsp.nspname -FROM - pg_catalog.pg_class c -LEFT JOIN pg_catalog.pg_namespace nsp ON c.relnamespace = nsp.oid -WHERE - c.relfilenode = {{ vid }}; -{% elif (name and nspname) %} -DROP VIEW {{ conn|qtIdent(nspname, name) }} {% if cascade %} CASCADE {% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/get_oid.sql deleted file mode 100644 index d56a189bb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/get_oid.sql +++ /dev/null @@ -1,9 +0,0 @@ -{# ===== fetch new assigned schema id ===== #} -{% if vid %} -SELECT - c.relnamespace as scid -FROM - pg_catalog.pg_class c -WHERE - c.oid = {{vid}}::oid; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/properties.sql deleted file mode 100644 index b238e367d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/properties.sql +++ /dev/null @@ -1,66 +0,0 @@ -{% if (vid and datlastsysoid) or scid %} -SELECT - c.oid, - c.xmin, - c.relname AS name, - description AS comment, - c.reltablespace AS spcoid, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, - pg_catalog.pg_get_userbyid(c.relowner) AS owner, - description As comment, - pg_catalog.pg_get_viewdef(c.oid, true) AS definition, - nsp.nspname AS schema, - pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, - {#=============Checks if it is system view================#} - {% if vid and datlastsysoid %} - CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, - {% endif %} - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabels sl1 - WHERE - sl1.objoid=c.oid AND sl1.objsubid=0 - ) AS seclabels, - (substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier -FROM pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) - WHERE ((c.relhasrules AND (EXISTS ( - SELECT - r.rulename - FROM - pg_catalog.pg_rewrite r - WHERE - ((r.ev_class = c.oid) - AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar) - ) )) - ) AND (c.relkind = 'v'::char) - ) -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid ORDER BY c.relname -{% endif %} - -{% elif type == 'roles' %} -SELECT - pr.rolname -FROM - pg_catalog.pg_roles pr -WHERE - pr.rolcanlogin -ORDER BY - pr.rolname - -{% elif type == 'schemas' %} -SELECT - nsp.nspname -FROM - pg_catalog.pg_namespace nsp -WHERE - (nsp.nspname NOT LIKE E'pg\\_%' - AND nsp.nspname != 'information_schema') -{% 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 deleted file mode 100644 index 00a1329f2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/update.sql +++ /dev/null @@ -1,79 +0,0 @@ -{# ============================ Update View ========================= #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set view_name = data.name if data.name else o_data.name %} -{% set view_schema = data.schema if data.schema else o_data.schema %} -{% set def = data.definition.rstrip(';') if data.definition %} -{% if data.name and data.name != o_data.name %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.schema and data.schema != o_data.schema %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, view_name ) }} - SET SCHEMA {{ conn|qtIdent(data.schema) }}; -{% endif %} -{% if data.owner and data.owner != o_data.owner %} -ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if def and def != o_data.definition.rstrip(';') %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} - WITH (security_barrier={{ data.security_barrier|lower if data.security_barrier is defined else o_data.security_barrier|default('false', 'true')|lower }}) - AS - {{ def }}; -{% else %} -{% if (data.security_barrier is defined and data.security_barrier|lower != o_data.security_barrier|lower) %} -ALTER VIEW {{ conn|qtIdent(view_schema, view_name) }} - SET (security_barrier={{ data.security_barrier|lower }}); -{% endif %} -{% endif %} -{% set old_comment = o_data.comment|default('', true) %} -{% if (data.comment is defined and (data.comment != old_comment)) %} - -COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{# The SQL generated below will change privileges #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{# The SQL generated below will change Security Label #} -{% if data.seclabels is not none and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/view_id.sql deleted file mode 100644 index 8b87a863b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/view_id.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Below will provide view id for last created view ===== #} -{% if data %} -SELECT c.oid, c.relname FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE c.relname = {{ data.name |qtLiteral }} and nsp.nspname = '{{ data.schema }}'; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/acl.sql deleted file mode 100644 index 76b9f19e3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/acl.sql +++ /dev/null @@ -1,38 +0,0 @@ -{# ============================ Get ACLs ========================= #} -{% if vid %} -SELECT - 'datacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'DELETE' THEN 'd' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TRIGGER' THEN 't' - WHEN 'UPDATE' THEN 'w' - WHEN 'TRUNCATE' THEN 'D' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - relacl - FROM - pg_catalog.pg_class cl - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass) - WHERE cl.oid = {{ vid }}::OID AND relkind = 'v' - ) acl, - pg_catalog.aclexplode(relacl) d - ) d -LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY - g.rolname, - gt.rolname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/allowed_privs.json deleted file mode 100644 index 71f317fb2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/allowed_privs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "datacl": { - "type": "VIEW", - "acl": ["a", "r", "w", "d", "D", "x", "t"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/create.sql deleted file mode 100644 index dac7b12c0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/create.sql +++ /dev/null @@ -1,23 +0,0 @@ -{#============================Create new view=========================#} -{% if display_comments %} --- View: {{ data.schema }}.{{ data.name }} - --- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; - -{% endif %} -{% if data.name and data.schema and data.definition %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %} -WITH ( -{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %} -){% endif %} AS -{{ data.definition.rstrip(';') }}; -{% if data.owner %} - -ALTER TABLE {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.comment %} -COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/get_oid.sql deleted file mode 100644 index d56a189bb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/get_oid.sql +++ /dev/null @@ -1,9 +0,0 @@ -{# ===== fetch new assigned schema id ===== #} -{% if vid %} -SELECT - c.relnamespace as scid -FROM - pg_catalog.pg_class c -WHERE - c.oid = {{vid}}::oid; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/get_schema.sql deleted file mode 100644 index 45cf02987..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/get_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -{# ===== fetch schema name against schema oid ===== #} -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/grant.sql deleted file mode 100644 index a7e1585bd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/grant.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Grant Permissions to User Role on Views/Tables ===== #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# ===== We will generate Security Label SQL using macro ===== #} -{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %} -{% for priv in data.datacl %}{{ 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/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/nodes.sql deleted file mode 100644 index d0a61515f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - c.oid, - c.relname AS name -FROM pg_catalog.pg_class c -WHERE - c.relkind = 'v' -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - c.relname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/properties.sql deleted file mode 100644 index d01bd95f8..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/properties.sql +++ /dev/null @@ -1,68 +0,0 @@ -{% if (vid and datlastsysoid) or scid %} -SELECT - c.oid, - c.xmin, - c.relkind, - description AS comment, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, - c.relname AS name, - nsp.nspname AS schema, - c.reltablespace AS spcoid, - c.relispopulated AS ispopulated, - pg_catalog.pg_get_userbyid(c.relowner) AS owner, - pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, - pg_catalog.pg_get_viewdef(c.oid, true) AS definition, - {# ===== Checks if it is system view ===== #} - {% if vid and datlastsysoid %} - CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, - {% endif %} - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabels sl1 - WHERE - sl1.objoid=c.oid AND sl1.objsubid=0 - ) AS seclabels, - (substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier -FROM pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) - WHERE ((c.relhasrules AND (EXISTS ( - SELECT - r.rulename - FROM - pg_catalog.pg_rewrite r - WHERE - ((r.ev_class = c.oid) - AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar)) ))) - AND (c.relkind = 'v'::char) - ) -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -ORDER BY - c.relname -{% endif %} - -{% elif type == 'roles' %} -SELECT - pr.rolname -FROM - pg_catalog.pg_roles pr -WHERE - pr.rolcanlogin -ORDER BY - pr.rolname - -{% elif type == 'schemas' %} -SELECT - nsp.nspname -FROM - pg_catalog.pg_namespace nsp -WHERE - (nsp.nspname NOT LIKE E'pg\\_%' - AND nsp.nspname != 'information_schema') -{% 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 deleted file mode 100644 index 00a1329f2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/update.sql +++ /dev/null @@ -1,79 +0,0 @@ -{# ============================ Update View ========================= #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set view_name = data.name if data.name else o_data.name %} -{% set view_schema = data.schema if data.schema else o_data.schema %} -{% set def = data.definition.rstrip(';') if data.definition %} -{% if data.name and data.name != o_data.name %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.schema and data.schema != o_data.schema %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, view_name ) }} - SET SCHEMA {{ conn|qtIdent(data.schema) }}; -{% endif %} -{% if data.owner and data.owner != o_data.owner %} -ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if def and def != o_data.definition.rstrip(';') %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} - WITH (security_barrier={{ data.security_barrier|lower if data.security_barrier is defined else o_data.security_barrier|default('false', 'true')|lower }}) - AS - {{ def }}; -{% else %} -{% if (data.security_barrier is defined and data.security_barrier|lower != o_data.security_barrier|lower) %} -ALTER VIEW {{ conn|qtIdent(view_schema, view_name) }} - SET (security_barrier={{ data.security_barrier|lower }}); -{% endif %} -{% endif %} -{% set old_comment = o_data.comment|default('', true) %} -{% if (data.comment is defined and (data.comment != old_comment)) %} - -COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{# The SQL generated below will change privileges #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{# The SQL generated below will change Security Label #} -{% if data.seclabels is not none and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/view_id.sql deleted file mode 100644 index 8b87a863b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/view_id.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Below will provide view id for last created view ===== #} -{% if data %} -SELECT c.oid, c.relname FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE c.relname = {{ data.name |qtLiteral }} and nsp.nspname = '{{ data.schema }}'; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/allowed_privs.json deleted file mode 100644 index 71f317fb2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/allowed_privs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "datacl": { - "type": "VIEW", - "acl": ["a", "r", "w", "d", "D", "x", "t"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/get_oid.sql deleted file mode 100644 index d56a189bb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/get_oid.sql +++ /dev/null @@ -1,9 +0,0 @@ -{# ===== fetch new assigned schema id ===== #} -{% if vid %} -SELECT - c.relnamespace as scid -FROM - pg_catalog.pg_class c -WHERE - c.oid = {{vid}}::oid; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/get_schema.sql deleted file mode 100644 index 45cf02987..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/get_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -{# ===== fetch schema name against schema oid ===== #} -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/grant.sql deleted file mode 100644 index a7e1585bd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/grant.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Grant Permissions to User Role on Views/Tables ===== #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# ===== We will generate Security Label SQL using macro ===== #} -{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %} -{% for priv in data.datacl %}{{ 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/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/nodes.sql deleted file mode 100644 index d0a61515f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - c.oid, - c.relname AS name -FROM pg_catalog.pg_class c -WHERE - c.relkind = 'v' -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - c.relname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/view_id.sql deleted file mode 100644 index 8b87a863b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/view_id.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Below will provide view id for last created view ===== #} -{% if data %} -SELECT c.oid, c.relname FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE c.relname = {{ data.name |qtLiteral }} and nsp.nspname = '{{ data.schema }}'; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/allowed_privs.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/allowed_privs.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/allowed_privs.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/delete.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/delete.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/delete.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/get_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/9.3_plus/sql/get_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/get_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/get_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/get_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/get_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/grant.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/grant.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/grant.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/properties.sql 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/default/sql/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.4_plus/sql/update.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/view_id.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/view_id.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/default/sql/view_id.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/acl.sql deleted file mode 100644 index 45bc121ce..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/acl.sql +++ /dev/null @@ -1,39 +0,0 @@ -{# ============================ Get ACLs ========================= #} -{% if vid %} -SELECT - 'datacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'DELETE' THEN 'd' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TRIGGER' THEN 't' - WHEN 'UPDATE' THEN 'w' - WHEN 'TRUNCATE' THEN 'D' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - relacl - FROM - pg_catalog.pg_class cl - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON - (cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass) - WHERE - cl.oid = {{ vid }}::OID AND relkind = 'v' - ) acl, - pg_catalog.aclexplode(relacl) d - ) d -LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY - g.rolname, - gt.rolname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/allowed_privs.json deleted file mode 100644 index 71f317fb2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/allowed_privs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "datacl": { - "type": "VIEW", - "acl": ["a", "r", "w", "d", "D", "x", "t"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/create.sql deleted file mode 100644 index 1f5a923da..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/create.sql +++ /dev/null @@ -1,20 +0,0 @@ -{#============================Create new view=========================#} -{% if display_comments %} --- View: {{ data.schema }}.{{ data.name }} - --- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; - -{% endif %} -{% if data.name and data.schema and data.definition %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }} AS -{{ data.definition.rstrip(';') }}; -{% if data.owner %} - -ALTER TABLE {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.comment %} -COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/delete.sql deleted file mode 100644 index 6b0305b18..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/delete.sql +++ /dev/null @@ -1,13 +0,0 @@ -{# ====================== Drop/Cascade view by name ===================== #} -{% if vid %} -SELECT - c.relname AS name, - nsp.nspname -FROM - pg_catalog.pg_class c -LEFT JOIN pg_catalog.pg_namespace nsp ON c.relnamespace = nsp.oid -WHERE - c.relfilenode = {{ vid }}; -{% elif (name and nspname) %} -DROP VIEW {{ conn|qtIdent(nspname, name) }} {% if cascade %} CASCADE {% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/get_oid.sql deleted file mode 100644 index d56a189bb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/get_oid.sql +++ /dev/null @@ -1,9 +0,0 @@ -{# ===== fetch new assigned schema id ===== #} -{% if vid %} -SELECT - c.relnamespace as scid -FROM - pg_catalog.pg_class c -WHERE - c.oid = {{vid}}::oid; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/get_schema.sql deleted file mode 100644 index 45cf02987..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/get_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -{# ===== fetch schema name against schema oid ===== #} -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/grant.sql deleted file mode 100644 index a7e1585bd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/grant.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Grant Permissions to User Role on Views/Tables ===== #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# ===== We will generate Security Label SQL using macro ===== #} -{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %} -{% for priv in data.datacl %}{{ 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/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/nodes.sql deleted file mode 100644 index d0a61515f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - c.oid, - c.relname AS name -FROM pg_catalog.pg_class c -WHERE - c.relkind = 'v' -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - c.relname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/properties.sql deleted file mode 100644 index cfd0dd764..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/properties.sql +++ /dev/null @@ -1,70 +0,0 @@ -{% if (vid and datlastsysoid) or scid %} -SELECT - c.oid, - c.xmin, - c.relkind, - description AS comment, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, - c.relname AS name, - c.reltablespace AS spcoid, - nsp.nspname AS schema, - c.relispopulated AS ispopulated, - pg_catalog.pg_get_userbyid(c.relowner) AS owner, - pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, - pg_catalog.pg_get_viewdef(c.oid) AS definition, - {# ===== Checks if it is system view ===== #} - {% if vid and datlastsysoid %} - CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, - {% endif %} - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabels sl1 - WHERE - sl1.objoid=c.oid AND sl1.objsubid=0 - ) AS seclabels, - substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'check_option=([a-z]*)') AS check_option, - (substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier -FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) - WHERE ((c.relhasrules AND (EXISTS ( - SELECT - r.rulename - FROM - pg_catalog.pg_rewrite r - WHERE - ((r.ev_class = c.oid) - AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar)) ))) - AND (c.relkind = 'v'::char) - ) -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -ORDER BY - c.relname -{% endif %} - -{% elif type == 'roles' %} -SELECT - pr.rolname -FROM - pg_catalog.pg_roles pr -WHERE - pr.rolcanlogin -ORDER BY - pr.rolname - -{% elif type == 'schemas' %} -SELECT - nsp.nspname -FROM - pg_catalog.pg_namespace nsp -WHERE - (nsp.nspname NOT LIKE E'pg\\_%' - AND nsp.nspname != 'information_schema') -{% 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 deleted file mode 100644 index 429919f9a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/update.sql +++ /dev/null @@ -1,79 +0,0 @@ -{# ============================ Update View ========================= #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set view_name = data.name if data.name else o_data.name %} -{% set view_schema = data.schema if data.schema else o_data.schema %} -{% set def = data.definition.rstrip(';') if data.definition %} -{% if data.name and data.name != o_data.name %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.schema and data.schema != o_data.schema %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, view_name ) }} - SET SCHEMA {{ conn|qtIdent(data.schema) }}; -{% endif %} -{% if data.owner and data.owner != o_data.owner %} -ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if def and def != o_data.definition.rstrip(';') %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} - WITH (security_barrier={{ data.security_barrier|lower if data.security_barrier else o_data.security_barrier|default('false', 'true')|lower }}) - AS - {{ def }}; -{% else %} -{% if (data.security_barrier is defined and data.security_barrier|lower != o_data.security_barrier|lower) %} -ALTER VIEW {{ conn|qtIdent(view_schema, view_name) }} - SET (security_barrier={{ data.security_barrier|lower }}); -{% endif %} -{% endif %} -{% set old_comment = o_data.comment|default('', true) %} -{% if (data.comment is defined and (data.comment != old_comment)) %} - -COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{# The SQL generated below will change privileges #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{# The SQL generated below will change Security Label #} -{% if data.seclabels is not none and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/view_id.sql deleted file mode 100644 index b3ec20da9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.1_plus/sql/view_id.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Below will provide view id for last created view ===== #} -{% if data %} -SELECT c.oid, c.relname FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = '{{ data.schema }}'; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/acl.sql deleted file mode 100644 index 38f5400e1..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/acl.sql +++ /dev/null @@ -1,52 +0,0 @@ -{# ============================ Get ACLs ========================= #} -{% if vid %} -SELECT - 'datacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'DELETE' THEN 'd' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TRIGGER' THEN 't' - WHEN 'UPDATE' THEN 'w' - WHEN 'TRUNCATE' THEN 'D' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - relacl - FROM - pg_catalog.pg_class cl - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass) - WHERE - cl.oid = {{ vid }}::OID AND relkind = 'v' - ) acl, - (SELECT - (d).grantee AS grantee, - (d).grantor AS grantor, - (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM - (SELECT - pg_catalog.aclexplode(relacl) AS d - FROM - pg_catalog.pg_class cl1 - WHERE - cl1.oid = {{ vid }} - ) a - ) d - ) d -LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY - g.rolname, - gt.rolname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/allowed_privs.json deleted file mode 100644 index 71f317fb2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/allowed_privs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "datacl": { - "type": "VIEW", - "acl": ["a", "r", "w", "d", "D", "x", "t"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/create.sql deleted file mode 100644 index dac7b12c0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/create.sql +++ /dev/null @@ -1,23 +0,0 @@ -{#============================Create new view=========================#} -{% if display_comments %} --- View: {{ data.schema }}.{{ data.name }} - --- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; - -{% endif %} -{% if data.name and data.schema and data.definition %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %} -WITH ( -{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %} -){% endif %} AS -{{ data.definition.rstrip(';') }}; -{% if data.owner %} - -ALTER TABLE {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.comment %} -COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/delete.sql deleted file mode 100644 index 6b0305b18..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/delete.sql +++ /dev/null @@ -1,13 +0,0 @@ -{# ====================== Drop/Cascade view by name ===================== #} -{% if vid %} -SELECT - c.relname AS name, - nsp.nspname -FROM - pg_catalog.pg_class c -LEFT JOIN pg_catalog.pg_namespace nsp ON c.relnamespace = nsp.oid -WHERE - c.relfilenode = {{ vid }}; -{% elif (name and nspname) %} -DROP VIEW {{ conn|qtIdent(nspname, name) }} {% if cascade %} CASCADE {% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/get_oid.sql deleted file mode 100644 index d56a189bb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/get_oid.sql +++ /dev/null @@ -1,9 +0,0 @@ -{# ===== fetch new assigned schema id ===== #} -{% if vid %} -SELECT - c.relnamespace as scid -FROM - pg_catalog.pg_class c -WHERE - c.oid = {{vid}}::oid; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/get_schema.sql deleted file mode 100644 index 45cf02987..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/get_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -{# ===== fetch schema name against schema oid ===== #} -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/grant.sql deleted file mode 100644 index a7e1585bd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/grant.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Grant Permissions to User Role on Views/Tables ===== #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# ===== We will generate Security Label SQL using macro ===== #} -{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %} -{% for priv in data.datacl %}{{ 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/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/nodes.sql deleted file mode 100644 index d0a61515f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - c.oid, - c.relname AS name -FROM pg_catalog.pg_class c -WHERE - c.relkind = 'v' -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - c.relname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/properties.sql deleted file mode 100644 index 77d3761f5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/properties.sql +++ /dev/null @@ -1,65 +0,0 @@ -{% if (vid and datlastsysoid) or scid %} -SELECT - c.oid, - c.xmin, - c.relname AS name, - c.reltablespace AS spcoid, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, - pg_catalog.pg_get_userbyid(c.relowner) AS owner, - description As comment, - pg_catalog.pg_get_viewdef(c.oid) AS definition, - nsp.nspname AS schema, - pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, - {#=============Checks if it is system view================#} - {% if vid and datlastsysoid %} - CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, - {% endif %} - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabels sl1 - WHERE - sl1.objoid=c.oid AND sl1.objsubid=0 - ) AS seclabels, - (substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier -FROM pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) - WHERE ((c.relhasrules AND (EXISTS ( - SELECT - r.rulename - FROM - pg_catalog.pg_rewrite r - WHERE - ((r.ev_class = c.oid) - AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar) - ) )) - ) AND (c.relkind = 'v'::char) - ) -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid ORDER BY c.relname -{% endif %} - -{% elif type == 'roles' %} -SELECT - pr.rolname -FROM - pg_catalog.pg_roles pr -WHERE - pr.rolcanlogin -ORDER BY - pr.rolname - -{% elif type == 'schemas' %} -SELECT - nsp.nspname -FROM - pg_catalog.pg_namespace nsp -WHERE - (nsp.nspname NOT LIKE E'pg\\_%' - AND nsp.nspname != 'information_schema') -{% 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 deleted file mode 100644 index 429919f9a..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/update.sql +++ /dev/null @@ -1,79 +0,0 @@ -{# ============================ Update View ========================= #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set view_name = data.name if data.name else o_data.name %} -{% set view_schema = data.schema if data.schema else o_data.schema %} -{% set def = data.definition.rstrip(';') if data.definition %} -{% if data.name and data.name != o_data.name %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.schema and data.schema != o_data.schema %} -ALTER VIEW {{ conn|qtIdent(o_data.schema, view_name ) }} - SET SCHEMA {{ conn|qtIdent(data.schema) }}; -{% endif %} -{% if data.owner and data.owner != o_data.owner %} -ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if def and def != o_data.definition.rstrip(';') %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} - WITH (security_barrier={{ data.security_barrier|lower if data.security_barrier else o_data.security_barrier|default('false', 'true')|lower }}) - AS - {{ def }}; -{% else %} -{% if (data.security_barrier is defined and data.security_barrier|lower != o_data.security_barrier|lower) %} -ALTER VIEW {{ conn|qtIdent(view_schema, view_name) }} - SET (security_barrier={{ data.security_barrier|lower }}); -{% endif %} -{% endif %} -{% set old_comment = o_data.comment|default('', true) %} -{% if (data.comment is defined and (data.comment != old_comment)) %} - -COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{# The SQL generated below will change privileges #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{# The SQL generated below will change Security Label #} -{% if data.seclabels is not none and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/view_id.sql deleted file mode 100644 index b3ec20da9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.2_plus/sql/view_id.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Below will provide view id for last created view ===== #} -{% if data %} -SELECT c.oid, c.relname FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = '{{ data.schema }}'; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/acl.sql deleted file mode 100644 index 76b9f19e3..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/acl.sql +++ /dev/null @@ -1,38 +0,0 @@ -{# ============================ Get ACLs ========================= #} -{% if vid %} -SELECT - 'datacl' as deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, - g.rolname grantor, - pg_catalog.array_agg(privilege_type) as privileges, - pg_catalog.array_agg(is_grantable) as grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'DELETE' THEN 'd' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TRIGGER' THEN 't' - WHEN 'UPDATE' THEN 'w' - WHEN 'TRUNCATE' THEN 'D' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - relacl - FROM - pg_catalog.pg_class cl - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass) - WHERE cl.oid = {{ vid }}::OID AND relkind = 'v' - ) acl, - pg_catalog.aclexplode(relacl) d - ) d -LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY - g.rolname, - gt.rolname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/allowed_privs.json deleted file mode 100644 index 71f317fb2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/allowed_privs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "datacl": { - "type": "VIEW", - "acl": ["a", "r", "w", "d", "D", "x", "t"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/create.sql deleted file mode 100644 index 5099cc106..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/create.sql +++ /dev/null @@ -1,23 +0,0 @@ -{#============================Create new view=========================#} -{% if display_comments %} --- View: {{ data.schema }}.{{ data.name }} - --- DROP VIEW {{ conn|qtIdent(data.schema, data.name) }}; - -{% endif %} -{% if data.name and data.schema and data.definition %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(data.schema, data.name) }}{% if (data.security_barrier) %} -WITH ( -{% if data.security_barrier %} security_barrier={{ data.security_barrier|lower }}{% endif %} -){% endif %} AS -{{ data.definition.rstrip(';') }}; -{% if data.owner %} - -ALTER TABLE IF EXISTS {{ conn|qtIdent(data.schema, data.name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if data.comment %} -COMMENT ON VIEW {{ conn|qtIdent(data.schema, data.name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/delete.sql deleted file mode 100644 index 987752ac6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/delete.sql +++ /dev/null @@ -1,13 +0,0 @@ -{# ====================== Drop/Cascade view by name ===================== #} -{% if vid %} -SELECT - c.relname AS name, - nsp.nspname -FROM - pg_catalog.pg_class c -LEFT JOIN pg_catalog.pg_namespace nsp ON c.relnamespace = nsp.oid -WHERE - c.relfilenode = {{ vid }}; -{% elif (name and nspname) %} -DROP VIEW IF EXISTS {{ conn|qtIdent(nspname, name) }} {% if cascade %} CASCADE {% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/get_oid.sql deleted file mode 100644 index d56a189bb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/get_oid.sql +++ /dev/null @@ -1,9 +0,0 @@ -{# ===== fetch new assigned schema id ===== #} -{% if vid %} -SELECT - c.relnamespace as scid -FROM - pg_catalog.pg_class c -WHERE - c.oid = {{vid}}::oid; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/get_schema.sql deleted file mode 100644 index 45cf02987..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/get_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -{# ===== fetch schema name against schema oid ===== #} -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/grant.sql deleted file mode 100644 index a7e1585bd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/grant.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Grant Permissions to User Role on Views/Tables ===== #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# ===== We will generate Security Label SQL using macro ===== #} -{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %} -{% for priv in data.datacl %}{{ 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/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/nodes.sql deleted file mode 100644 index d0a61515f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - c.oid, - c.relname AS name -FROM pg_catalog.pg_class c -WHERE - c.relkind = 'v' -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - c.relname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/properties.sql deleted file mode 100644 index 8b0401ae0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/properties.sql +++ /dev/null @@ -1,68 +0,0 @@ -{% if (vid and datlastsysoid) or scid %} -SELECT - c.oid, - c.xmin, - c.relkind, - description AS comment, - (CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE 'pg_default' END) as spcname, - c.relname AS name, - nsp.nspname AS schema, - c.reltablespace AS spcoid, - c.relispopulated AS ispopulated, - pg_catalog.pg_get_userbyid(c.relowner) AS owner, - pg_catalog.array_to_string(c.relacl::text[], ', ') AS acl, - pg_catalog.pg_get_viewdef(c.oid) AS definition, - {# ===== Checks if it is system view ===== #} - {% if vid and datlastsysoid %} - CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view, - {% endif %} - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM - pg_catalog.pg_seclabels sl1 - WHERE - sl1.objoid=c.oid AND sl1.objsubid=0 - ) AS seclabels, - (substring(pg_catalog.array_to_string(c.reloptions, ',') - FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier -FROM pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=c.reltablespace -LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid and des.objsubid=0 AND des.classoid='pg_class'::regclass) - WHERE ((c.relhasrules AND (EXISTS ( - SELECT - r.rulename - FROM - pg_catalog.pg_rewrite r - WHERE - ((r.ev_class = c.oid) - AND (pg_catalog.bpchar(r.ev_type) = '1'::bpchar)) ))) - AND (c.relkind = 'v'::char) - ) -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -ORDER BY - c.relname -{% endif %} - -{% elif type == 'roles' %} -SELECT - pr.rolname -FROM - pg_catalog.pg_roles pr -WHERE - pr.rolcanlogin -ORDER BY - pr.rolname - -{% elif type == 'schemas' %} -SELECT - nsp.nspname -FROM - pg_catalog.pg_namespace nsp -WHERE - (nsp.nspname NOT LIKE E'pg\\_%' - AND nsp.nspname != 'information_schema') -{% 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 deleted file mode 100644 index 718bae6a0..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/update.sql +++ /dev/null @@ -1,79 +0,0 @@ -{# ============================ Update View ========================= #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{% if data %} -{% set view_name = data.name if data.name else o_data.name %} -{% set view_schema = data.schema if data.schema else o_data.schema %} -{% set def = data.definition.rstrip(';') if data.definition %} -{% if data.name and data.name != o_data.name %} -ALTER VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} -{% if data.schema and data.schema != o_data.schema %} -ALTER VIEW IF EXISTS {{ conn|qtIdent(o_data.schema, view_name ) }} - SET SCHEMA {{ conn|qtIdent(data.schema) }}; -{% endif %} -{% if data.owner and data.owner != o_data.owner %} -ALTER TABLE IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} - OWNER TO {{ conn|qtIdent(data.owner) }}; -{% endif %} -{% if def and def != o_data.definition.rstrip(';') %} -CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }} - WITH (security_barrier={{ data.security_barrier|lower if data.security_barrier else o_data.security_barrier|default('false', 'true')|lower }}) - AS - {{ def }}; -{% else %} -{% if (data.security_barrier is defined and data.security_barrier|lower != o_data.security_barrier|lower) %} -ALTER VIEW IF EXISTS {{ conn|qtIdent(view_schema, view_name) }} - SET (security_barrier={{ data.security_barrier|lower }}); -{% endif %} -{% endif %} -{% set old_comment = o_data.comment|default('', true) %} -{% if (data.comment is defined and (data.comment != old_comment)) %} - -COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }} - IS {{ data.comment|qtLiteral }}; -{% endif %} -{# The SQL generated below will change privileges #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.UNSETALL(conn, 'TABLE', priv.grantee, data.name, data.schema) }} -{% endfor %} -{% 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 %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{# The SQL generated below will change Security Label #} -{% if data.seclabels is not none and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/view_id.sql deleted file mode 100644 index b3ec20da9..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.3_plus/sql/view_id.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Below will provide view id for last created view ===== #} -{% if data %} -SELECT c.oid, c.relname FROM pg_catalog.pg_class c -LEFT OUTER JOIN pg_catalog.pg_namespace nsp on nsp.oid = c.relnamespace -WHERE c.relname = {{ data.name|qtLiteral }} and nsp.nspname = '{{ data.schema }}'; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/allowed_privs.json deleted file mode 100644 index 71f317fb2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/allowed_privs.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "datacl": { - "type": "VIEW", - "acl": ["a", "r", "w", "d", "D", "x", "t"] - } -} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/delete.sql deleted file mode 100644 index 987752ac6..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/delete.sql +++ /dev/null @@ -1,13 +0,0 @@ -{# ====================== Drop/Cascade view by name ===================== #} -{% if vid %} -SELECT - c.relname AS name, - nsp.nspname -FROM - pg_catalog.pg_class c -LEFT JOIN pg_catalog.pg_namespace nsp ON c.relnamespace = nsp.oid -WHERE - c.relfilenode = {{ vid }}; -{% elif (name and nspname) %} -DROP VIEW IF EXISTS {{ conn|qtIdent(nspname, name) }} {% if cascade %} CASCADE {% endif %}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/get_oid.sql deleted file mode 100644 index d56a189bb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/get_oid.sql +++ /dev/null @@ -1,9 +0,0 @@ -{# ===== fetch new assigned schema id ===== #} -{% if vid %} -SELECT - c.relnamespace as scid -FROM - pg_catalog.pg_class c -WHERE - c.oid = {{vid}}::oid; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/get_schema.sql deleted file mode 100644 index 45cf02987..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/get_schema.sql +++ /dev/null @@ -1,7 +0,0 @@ -{# ===== fetch schema name against schema oid ===== #} -SELECT - nspname -FROM - pg_catalog.pg_namespace -WHERE - oid = {{ scid }}::oid; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/grant.sql deleted file mode 100644 index a7e1585bd..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/grant.sql +++ /dev/null @@ -1,6 +0,0 @@ -{# ===== Grant Permissions to User Role on Views/Tables ===== #} -{% import 'macros/schemas/security.macros' as SECLABEL %} -{% import 'macros/schemas/privilege.macros' as PRIVILEGE %} -{# ===== We will generate Security Label SQL using macro ===== #} -{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %} -{% for priv in data.datacl %}{{ 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/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/nodes.sql deleted file mode 100644 index d0a61515f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/nodes.sql +++ /dev/null @@ -1,17 +0,0 @@ -SELECT - c.oid, - c.relname AS name -FROM pg_catalog.pg_class c -WHERE - c.relkind = 'v' -{% if (vid and datlastsysoid) %} - AND c.oid = {{vid}}::oid -{% elif scid %} - AND c.relnamespace = {{scid}}::oid -{% if schema_diff %} - AND CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend - WHERE objid = c.oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END -{% endif %} -ORDER BY - c.relname -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/acl.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/acl.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/acl.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/allowed_privs.json b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/allowed_privs.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/allowed_privs.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/allowed_privs.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/create.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/delete.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.3_plus/sql/delete.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/delete.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/get_oid.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/get_oid.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.1_plus/sql/get_oid.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/get_oid.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/get_schema.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/get_schema.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/get_schema.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/get_schema.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/grant.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/grant.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/grant.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/pg/9.2_plus/sql/nodes.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/properties.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/properties.sql 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/default/sql/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/update.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/view_id.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/view_id.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/9.4_plus/sql/view_id.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/views/ppas/default/sql/view_id.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_fillfactor.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_fillfactor.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_fillfactor.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_fillfactor.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_fillfactor_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_fillfactor_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_fillfactor_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_fillfactor_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_table_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_table_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_table_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_table_parameter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_table_parameter_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_table_parameter_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_add_table_parameter_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_add_table_parameter_msql.sql 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/default/alter_mview_change_grantee_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_change_grantee_priv.sql 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/default/alter_mview_change_grantee_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_change_grantee_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_change_grantee_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_definition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_definition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_definition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_definition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_definition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_definition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_definition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_definition_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_drop_all_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_drop_all_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_drop_all_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_drop_all_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_drop_all_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_drop_all_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_drop_all_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_drop_all_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_remove_table_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_remove_table_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_remove_table_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_remove_table_parameter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_remove_table_parameter_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_remove_table_parameter_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_mview_remove_table_parameter_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_mview_remove_table_parameter_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_add_some_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_add_some_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_add_some_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_add_some_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_add_some_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_definition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_definition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_definition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_definition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_definition_msql.sql 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/default/alter_view_delete_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_delete_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_delete_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_delete_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_delete_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_msql.sql 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/default/alter_view_update_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_update_priv.sql 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/default/alter_view_update_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/alter_view_update_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/alter_view_update_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_mview.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_mview.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_mview.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_mview.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_mview_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_mview_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_mview_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_mview_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_view.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_view.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_view.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_view.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_view_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_view_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/create_view_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/create_view_msql.sql 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/default/test_mview.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/test_mview.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/test_mview.json 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/default/tests.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/9.4_plus/tests.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/pg/default/tests.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_fillfactor.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_fillfactor.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_fillfactor.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_fillfactor.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_fillfactor_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_fillfactor_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_fillfactor_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_fillfactor_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_table_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_table_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_table_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_table_parameter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_table_parameter_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_table_parameter_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_add_table_parameter_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_add_table_parameter_msql.sql 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/default/alter_mview_change_grantee_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_change_grantee_priv.sql 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/default/alter_mview_change_grantee_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_change_grantee_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_change_grantee_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_definition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_definition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_definition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_definition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_definition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_definition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_definition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_definition_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_drop_all_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_drop_all_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_drop_all_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_drop_all_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_drop_all_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_drop_all_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_drop_all_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_drop_all_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_remove_table_parameter.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_remove_table_parameter.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_remove_table_parameter.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_remove_table_parameter.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_remove_table_parameter_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_remove_table_parameter_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_mview_remove_table_parameter_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_mview_remove_table_parameter_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_add_some_priv.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_add_some_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_add_some_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_add_some_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_add_some_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_add_some_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_add_some_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_add_some_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_definition.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_definition.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_definition.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_definition.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_definition_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_definition_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_definition_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_definition_msql.sql 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/default/alter_view_delete_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_delete_priv.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_delete_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_delete_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_delete_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_msql.sql 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/default/alter_view_update_priv.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_update_priv.sql 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/default/alter_view_update_priv_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/alter_view_update_priv_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/alter_view_update_priv_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_mview.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_mview.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_mview.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_mview.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_mview_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_mview_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_mview_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_mview_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_view.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_view.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_view.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_view.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_view_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_view_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/create_view_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/create_view_msql.sql 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/default/test_mview.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/test_mview.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/test_mview.json 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/default/tests.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/9.4_plus/tests.json rename to web/pgadmin/browser/server_groups/servers/databases/schemas/views/tests/ppas/default/tests.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/alter_maintenance_db.sql b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_maintenance_db.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/alter_maintenance_db.sql rename to web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_maintenance_db.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/alter_subscription.sql b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_subscription.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/alter_subscription.sql rename to web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_subscription.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/alter_sync.sql b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_sync.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/alter_sync.sql rename to web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_sync.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/create_subscription.sql b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/create_subscription.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/create_subscription.sql rename to web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/create_subscription.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/create_subscription_msql.sql b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/create_subscription_msql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/create_subscription_msql.sql rename to web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/create_subscription_msql.sql diff --git a/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/test.json b/web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/test.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/10_plus/test.json rename to web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/test.json diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/alter_online.sql deleted file mode 100644 index b8a8c2c0d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/alter_online.sql +++ /dev/null @@ -1,147 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data %} - -{# Change the default priviledges for the functions #} -{% if data.deffuncacl %} -{% if 'deleted' in data.deffuncacl %} -{% for priv in data.deffuncacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deffuncacl %} -{% for priv in data.deffuncacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deffuncacl %} -{% for priv in data.deffuncacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} - - -{# Change the variables/options #} -{% if data.variables and data.variables|length > 0 %} -{% set variables = data.variables %} -{% if 'deleted' in variables and variables.deleted|length > 0 %} -{% for var in variables.deleted %} -{{ VARIABLE.RESET(conn, data.name, var.role, var.name) }} -{% endfor %} -{% endif %} -{% if 'added' in variables and variables.added|length > 0 %} -{% for var in variables.added %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} -{% if 'changed' in variables and variables.changed|length > 0 %} -{% for var in variables.changed %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the priviledges/ACLs #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'DATABASE', priv.grantee, data.name) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.datacl %} -{% for priv in data.datacl.changed %} -{{ PRIVILEGE.RESETALL(conn, 'DATABASE', priv.grantee, data.name) }} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges for the tables #} -{% if data.deftblacl %} -{% if 'deleted' in data.deftblacl %} -{% for priv in data.deftblacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TABLES', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deftblacl %} -{% for priv in data.deftblacl.changed %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deftblacl %} -{% for priv in data.deftblacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges for the sequences #} -{% if data.deftblacl %} -{% if data.defseqacl %} -{% if 'deleted' in data.defseqacl %} -{% for priv in data.defseqacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.defseqacl %} -{% for priv in data.defseqacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.defseqacl %} -{% for priv in data.defseqacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} - - - -{% endif %} -{# Change the security labels #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'DATABASE', data.name, r.provider) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% endif %} -{% endif %} - -{# Alter database to template DB or vice versa #} -{% if data.is_template is defined %} -ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH IS_TEMPLATE = {{ data.is_template }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/create.sql deleted file mode 100644 index 11f96cbcb..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/create.sql +++ /dev/null @@ -1,21 +0,0 @@ -{% if data %} -CREATE DATABASE {{ conn|qtIdent(data.name) }} -{% if data.datowner %} - WITH{% endif %}{% if data.datowner %} - - OWNER = {{ conn|qtIdent(data.datowner) }}{% endif %}{% if data.template %} - - TEMPLATE = {{ conn|qtIdent(data.template) }}{% endif %}{% if data.encoding %} - - ENCODING = {{ data.encoding|qtLiteral }}{% endif %}{% if data.datcollate %} - - LC_COLLATE = {{ data.datcollate|qtLiteral }}{% endif %}{% if data.datctype %} - - LC_CTYPE = {{ data.datctype|qtLiteral }}{% endif %}{% if data.spcname %} - - TABLESPACE = {{ conn|qtIdent(data.spcname) }}{% endif %}{% if data.datconnlimit %} - - CONNECTION LIMIT = {{ data.datconnlimit }}{% endif %} - - IS_TEMPLATE = {{ data.is_template }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/properties.sql deleted file mode 100644 index 7dea8b1d5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/10_plus/properties.sql +++ /dev/null @@ -1,42 +0,0 @@ -SELECT - db.oid AS did, db.oid, db.datname AS name, db.dattablespace AS spcoid, - spcname, datallowconn, pg_catalog.pg_encoding_to_char(encoding) AS encoding, - pg_catalog.pg_get_userbyid(datdba) AS datowner, - (select pg_catalog.current_setting('lc_collate')) as datcollate, - (select pg_catalog.current_setting('lc_ctype')) as datctype, - datconnlimit, - pg_catalog.has_database_privilege(db.oid, 'CREATE') AS cancreate, - pg_catalog.current_setting('default_tablespace') AS default_tablespace, - descr.description AS comments, db.datistemplate AS is_template, - {### Default ACL for Tables ###} - '' AS tblacl, - {### Default ACL for Sequnces ###} - '' AS seqacl, - {### Default ACL for Functions ###} - '' AS funcacl, - pg_catalog.array_to_string(datacl::text[], ', ') AS acl -FROM pg_catalog.pg_database db - LEFT OUTER JOIN pg_catalog.pg_tablespace ta ON db.dattablespace=ta.OID - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - db.oid=descr.objoid AND descr.classoid='pg_database'::regclass - ) -WHERE -{% if show_user_defined_templates is defined %} - db.datistemplate = {{show_user_defined_templates}} AND -{% endif %} -{% if did %} - db.oid = {{ did|qtLiteral }}::OID -{% else %} - {% if name %} - db.datname = {{ name|qtLiteral }}::text - {% endif %} -{% endif %} - -{% if db_restrictions %} - {% if did or name %}AND{% endif %} - db.datname in ({{db_restrictions}}) -{% elif not did and not name%} - db.oid > {{ last_system_oid }}::OID OR db.datname IN ('postgres', 'edb') -{% endif %} - -ORDER BY datname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/acl.sql deleted file mode 100644 index 8fe549790..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/acl.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT - 'datacl' AS deftype, COALESCE(gt.rolname, 'PUBLIC') AS grantee, - g.rolname AS grantor, pg_catalog.array_agg(privilege_type) AS privileges, - pg_catalog.array_agg(is_grantable) AS grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - (d).grantee AS grantee, (d).grantor AS grantor, - (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM - (SELECT pg_catalog.aclexplode(db.datacl) AS d FROM pg_catalog.pg_database db - WHERE db.oid = {{ did|qtLiteral }}::OID) a - ) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/defacl.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/defacl.sql deleted file mode 100644 index 512820bd2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/defacl.sql +++ /dev/null @@ -1,34 +0,0 @@ -SELECT - CASE (a.deftype) - WHEN 'r' THEN 'deftblacl' - WHEN 'S' THEN 'defseqacl' - WHEN 'f' THEN 'deffuncacl' - WHEN 'T' THEN 'deftypeacl' - END AS deftype, - COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, pg_catalog.array_agg(a.privilege_type) as privileges, pg_catalog.array_agg(a.is_grantable) as grantable -FROM - (SELECT - (acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable AS is_grantable, - CASE (acl).privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type, - defaclobjtype as deftype - FROM - (SELECT defaclobjtype, pg_catalog.aclexplode(defaclacl) as acl FROM pg_catalog.pg_default_acl dacl - WHERE dacl.defaclnamespace = 0::OID) d) a - LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname, a.deftype -ORDER BY a.deftype diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_ctypes.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_ctypes.sql deleted file mode 100644 index 32fdd807f..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_ctypes.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT DISTINCT(datctype) AS cname -FROM pg_catalog.pg_database -UNION -SELECT DISTINCT(datcollate) AS cname -FROM pg_catalog.pg_database diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_variables.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_variables.sql deleted file mode 100644 index 49976fe39..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/get_variables.sql +++ /dev/null @@ -1,5 +0,0 @@ - SELECT rl.*, r.rolname AS user_name, db.datname as db_name -FROM pg_catalog.pg_db_role_setting AS rl - LEFT JOIN pg_catalog.pg_roles AS r ON rl.setrole = r.oid - LEFT JOIN pg_catalog.pg_database AS db ON rl.setdatabase = db.oid -WHERE setdatabase = {{did}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql deleted file mode 100644 index 79789d9c5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql +++ /dev/null @@ -1,45 +0,0 @@ -SELECT - db.oid AS did, db.oid, db.datname AS name, db.dattablespace AS spcoid, - spcname, datallowconn, pg_catalog.pg_encoding_to_char(encoding) AS encoding, - pg_catalog.pg_get_userbyid(datdba) AS datowner, datcollate, datctype, datconnlimit, - pg_catalog.has_database_privilege(db.oid, 'CREATE') AS cancreate, - pg_catalog.current_setting('default_tablespace') AS default_tablespace, - descr.description AS comments, db.datistemplate AS is_template, - {### Default ACL for Tables ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID - ), ', ')) AS tblacl, - {### Default ACL for Sequnces ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'S' AND defaclnamespace = 0::OID - ), ', ')) AS seqacl, - {### Default ACL for Functions ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'f' AND defaclnamespace = 0::OID - ), ', ')) AS funcacl, - pg_catalog.array_to_string(datacl::text[], ', ') AS acl -FROM pg_catalog.pg_database db - LEFT OUTER JOIN pg_catalog.pg_tablespace ta ON db.dattablespace=ta.OID - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - db.oid=descr.objoid AND descr.classoid='pg_database'::regclass - ) -WHERE {% if did %} -db.oid = {{ did|qtLiteral }}::OID -{% endif %} -{% if db_restrictions %} - -{% if did %}AND{% endif %} -db.datname in ({{db_restrictions}}) -{% elif not did%} -db.oid > {{ last_system_oid }}::OID OR db.datname IN ('postgres', 'edb') -{% endif %} - -AND db.datistemplate in (false, {{show_system_objects}}) - -ORDER BY datname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/acl.sql deleted file mode 100644 index d72fafb10..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/acl.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT - 'datacl' AS deftype, COALESCE(gt.rolname, 'PUBLIC') AS grantee, - g.rolname grantor, pg_catalog.array_agg(privilege_type) AS privileges, - pg_catalog.array_agg(is_grantable) AS grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - (d).grantee AS grantee, (d).grantor AS grantor, - (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM - (SELECT pg_catalog.aclexplode(db.datacl) AS d FROM pg_catalog.pg_database db - WHERE db.oid = {{ did|qtLiteral }}::OID) a - ) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_online.sql deleted file mode 100644 index fd402b25e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_online.sql +++ /dev/null @@ -1,157 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data %} -{# Change the security labels #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'DATABASE', data.name, r.provider) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% endif %} -{# Change the variables/options #} -{% if data.variables and data.variables|length > 0 %} -{% set variables = data.variables %} -{% if 'deleted' in variables and variables.deleted|length > 0 %} -{% for var in variables.deleted %} -{{ VARIABLE.RESET(conn, data.name, var.role, var.name) }} -{% endfor %} -{% endif %} -{% if 'added' in variables and variables.added|length > 0 %} -{% for var in variables.added %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} -{% if 'changed' in variables and variables.changed|length > 0 %} -{% for var in variables.changed %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the priviledges/ACLs #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'DATABASE', priv.grantee, data.name) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.datacl %} -{% for priv in data.datacl.changed %} -{{ PRIVILEGE.RESETALL(conn, 'DATABASE', priv.grantee, data.name) }} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for the tables #} -{% if data.deftblacl %} -{% if 'deleted' in data.deftblacl %} -{% for priv in data.deftblacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TABLES', priv.grantee) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deftblacl %} -{% for priv in data.deftblacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TABLES', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deftblacl %} -{% for priv in data.deftblacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for the sequences #} -{% if data.defseqacl %} -{% if 'deleted' in data.defseqacl %} -{% for priv in data.defseqacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.defseqacl %} -{% for priv in data.defseqacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.defseqacl %} -{% for priv in data.defseqacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for the functions #} -{% if data.deffuncacl %} -{% if 'deleted' in data.deffuncacl %} -{% for priv in data.deffuncacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deffuncacl %} -{% for priv in data.deffuncacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deffuncacl %} -{% for priv in data.deffuncacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for the types #} -{% if data.deftypeacl %} -{% if 'deleted' in data.deftypeacl %} -{% for priv in data.deftypeacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TYPES', priv.grantee) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deftypeacl %} -{% for priv in data.deftypeacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TYPES', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deftypeacl %} -{% for priv in data.deftypeacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/delete.sql deleted file mode 100644 index ac8ff009e..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/delete.sql +++ /dev/null @@ -1,8 +0,0 @@ -{# We need database name before we execute drop #} -{% if did %} -SELECT db.datname as name FROM pg_catalog.pg_database as db WHERE db.oid = {{did}} -{% endif %} -{# Using name from above query we will drop the database #} -{% if datname %} -DROP DATABASE {{ conn|qtIdent(datname) }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_encodings.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_encodings.sql deleted file mode 100644 index 51caf9637..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_encodings.sql +++ /dev/null @@ -1,18 +0,0 @@ -{# --- Given SQL is workaround --- We need to implement a mechanism to check for valid supported server encoding -#} -SELECT * -FROM - (SELECT pg_catalog.pg_encoding_to_char(s.i) AS encoding - FROM (SELECT pg_catalog.generate_series(0, 100, 1) as i) s) a -WHERE encoding != '' ORDER BY encoding; - -{# --- For future use, Do not delete ---SELECT * FROM ---(SELECT s.i as id, pg_encoding_to_char(s.i) --- as encoding --- FROM (SELECT generate_series(0, 100, 1) as i) s) a ---WHERE encoding != '' -#} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_variables.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_variables.sql deleted file mode 100644 index c4e58f5c2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/get_variables.sql +++ /dev/null @@ -1,7 +0,0 @@ -SELECT - rl.*, r.rolname AS user_name, db.datname as db_name -FROM - pg_catalog.pg_db_role_setting AS rl - LEFT JOIN pg_catalog.pg_roles AS r ON rl.setrole = r.oid - LEFT JOIN pg_catalog.pg_database AS db ON rl.setdatabase = db.oid -WHERE setdatabase = {{did}}; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/grant.sql deleted file mode 100644 index 94f2bf404..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/grant.sql +++ /dev/null @@ -1,58 +0,0 @@ -{# -# CREATE DATABSE does not allow us to run any -# other sql statments along with it, so we wrote -# seprate sql for rest alter sql statments here -#} -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data.comments %} -COMMENT ON DATABASE {{ conn|qtIdent(data.name) }} - IS {{ data.comments|qtLiteral }}; -{% endif %} - -{# Generate the security labels #} -{% if data.seclabels %} -{% for r in data.seclabels %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{# Generate the variable/options #} -{% if data.variables %} -{% for var in data.variables %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} -{# Generate the privileges/ACLs #} -{% if data.datacl %} -{% for priv in data.datacl %} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if data.deftblacl %} -{% for priv in data.deftblacl %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if data.defseqacl %} -{% for priv in data.defseqacl %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if data.deffuncacl %} -{% for priv in data.deffuncacl %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if data.deftypeacl %} -{% for priv in data.deftypeacl %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql deleted file mode 100644 index 0bd9b6e88..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,55 +0,0 @@ -SELECT - db.oid AS did, db.oid, db.datname AS name, db.dattablespace AS spcoid, - spcname, datallowconn, pg_catalog.pg_encoding_to_char(encoding) AS encoding, - pg_catalog.pg_get_userbyid(datdba) AS datowner, datcollate, datctype, datconnlimit, - pg_catalog.has_database_privilege(db.oid, 'CREATE') AS cancreate, - pg_catalog.current_setting('default_tablespace') AS default_tablespace, - descr.description AS comments, db.datistemplate AS is_template, - {### Default ACL for Tables ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID - ), ', ')) AS tblacl, - {### Default ACL for Sequnces ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'S' AND defaclnamespace = 0::OID - ), ', ')) AS seqacl, - {### Default ACL for Functions ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'f' AND defaclnamespace = 0::OID - ), ', ')) AS funcacl, - {### Default ACL for Type ###} - (SELECT pg_catalog.array_to_string(ARRAY( - SELECT pg_catalog.array_to_string(defaclacl::text[], ', ') - FROM pg_catalog.pg_default_acl - WHERE defaclobjtype = 'T' AND defaclnamespace = 0::OID - ), ', ')) AS typeacl, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_shseclabel sl1 WHERE sl1.objoid=db.oid) AS seclabels, - pg_catalog.array_to_string(datacl::text[], ', ') AS acl -FROM pg_catalog.pg_database db - LEFT OUTER JOIN pg_catalog.pg_tablespace ta ON db.dattablespace=ta.OID - LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( - db.oid=descr.objoid AND descr.classoid='pg_database'::regclass - ) -WHERE -{% if did %} - db.oid = {{ did|qtLiteral }}::OID -{% else %} - {% if name %} - db.datname = {{ name|qtLiteral }}::text - {% endif %} -{% endif %} - -{% if db_restrictions %} - {% if did or name %}AND{% endif %} - db.datname in ({{db_restrictions}}) -{% elif not did and not name%} - db.oid > {{ last_system_oid }}::OID OR db.datname IN ('postgres', 'edb') -{% endif %} - -ORDER BY datname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/stats.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/stats.sql deleted file mode 100644 index 241cae6bc..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/stats.sql +++ /dev/null @@ -1,38 +0,0 @@ -SELECT - {% if not did %}db.datname AS {{ conn|qtIdent(_('Database')) }}, {% endif %} - numbackends AS {{ conn|qtIdent(_('Backends')) }}, - xact_commit AS {{ conn|qtIdent(_('Xact committed')) }}, - xact_rollback AS {{ conn|qtIdent(_('Xact rolled back')) }}, - blks_read AS {{ conn|qtIdent(_('Blocks read')) }}, - blks_hit AS {{ conn|qtIdent(_('Blocks hit')) }}, - tup_returned AS {{ conn|qtIdent(_('Tuples returned')) }}, - tup_fetched AS {{ conn|qtIdent(_('Tuples fetched')) }}, - tup_inserted AS {{ conn|qtIdent(_('Tuples inserted')) }}, - tup_updated AS {{ conn|qtIdent(_('Tuples updated')) }}, - tup_deleted AS {{ conn|qtIdent(_('Tuples deleted')) }}, - stats_reset AS {{ conn|qtIdent(_('Last statistics reset')) }}, - slave.confl_tablespace AS {{ conn|qtIdent(_('Tablespace conflicts')) }}, - slave.confl_lock AS {{ conn|qtIdent(_('Lock conflicts')) }}, - slave.confl_snapshot AS {{ conn|qtIdent(_('Snapshot conflicts')) }}, - slave.confl_bufferpin AS {{ conn|qtIdent(_('Bufferpin conflicts')) }}, - slave.confl_deadlock AS {{ conn|qtIdent(_('Deadlock conflicts')) }}, - temp_files AS {{ conn|qtIdent(_("Temporary files")) }}, - temp_bytes AS {{ conn|qtIdent(_("Size of temporary files")) }}, - deadlocks AS {{ conn|qtIdent(_("Deadlocks")) }}, - blk_read_time AS {{ conn|qtIdent(_("Block read time")) }}, - blk_write_time AS {{ conn|qtIdent(_("Block write time")) }}, - pg_catalog.pg_database_size(db.datid) AS {{ conn|qtIdent(_('Size')) }} -FROM - pg_catalog.pg_stat_database db - LEFT JOIN pg_catalog.pg_stat_database_conflicts slave ON db.datid=slave.datid -WHERE {% if did %} -db.datid = {{ did|qtLiteral }}::OID{% else %} -db.datid > {{ last_system_oid|qtLiteral }}::OID -{% endif %} -{% if db_restrictions %} - -AND -db.datname in ({{db_restrictions}}) -{% endif %} - -ORDER BY db.datname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/variables.sql deleted file mode 100644 index b49e153c5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/variables.sql +++ /dev/null @@ -1,4 +0,0 @@ -SELECT - name, vartype, min_val, max_val, enumvals -FROM pg_catalog.pg_settings -WHERE context in ('user', 'superuser'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/acl.sql deleted file mode 100644 index 8fe549790..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/acl.sql +++ /dev/null @@ -1,35 +0,0 @@ -SELECT - 'datacl' AS deftype, COALESCE(gt.rolname, 'PUBLIC') AS grantee, - g.rolname AS grantor, pg_catalog.array_agg(privilege_type) AS privileges, - pg_catalog.array_agg(is_grantable) AS grantable -FROM - (SELECT - d.grantee, d.grantor, d.is_grantable, - CASE d.privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type - FROM - (SELECT - (d).grantee AS grantee, (d).grantor AS grantor, - (d).is_grantable AS is_grantable, - (d).privilege_type AS privilege_type - FROM - (SELECT pg_catalog.aclexplode(db.datacl) AS d FROM pg_catalog.pg_database db - WHERE db.oid = {{ did|qtLiteral }}::OID) a - ) d - ) d - LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname; diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_offline.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_offline.sql deleted file mode 100644 index 59f9e599b..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_offline.sql +++ /dev/null @@ -1,22 +0,0 @@ -{% if data %} -{% if action == "rename_database" %} {% if data.old_name != data.name %} -ALTER DATABASE {{ conn|qtIdent(data.old_name) }} RENAME TO {{ conn|qtIdent(data.name) }}; -{% endif %} -{# Change the owner #} -{% if data.datowner %} -ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }}; -{% endif %} -{# Change the comments/description #} -{% if data.comments is defined %} -COMMENT ON DATABASE {{ conn|qtIdent(data.name) }} -IS {{ data.comments|qtLiteral }}; -{% endif %} -{# Change the connection limit #} -{% if data.datconnlimit %} -ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }}; -{% endif %} -{% endif %}{% if action == "tablespace" and data.spcname %} - -ALTER DATABASE {{ conn|qtIdent(data.name) }} SET TABLESPACE {{ conn|qtIdent(data.spcname) }}; -{% endif %} -{% endif %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_online.sql deleted file mode 100644 index 40ec137ba..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_online.sql +++ /dev/null @@ -1,157 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data %} -{# Change the security labels #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'DATABASE', data.name, r.provider) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% endif %} -{# Change the variables/options #} -{% if data.variables and data.variables|length > 0 %} -{% set variables = data.variables %} -{% if 'deleted' in variables and variables.deleted|length > 0 %} -{% for var in variables.deleted %} -{{ VARIABLE.RESET(conn, data.name, var.role, var.name) }} -{% endfor %} -{% endif %} -{% if 'added' in variables and variables.added|length > 0 %} -{% for var in variables.added %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} -{% if 'changed' in variables and variables.changed|length > 0 %} -{% for var in variables.changed %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the priviledges/ACLs #} -{% if data.datacl %} -{% if 'deleted' in data.datacl %} -{% for priv in data.datacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'DATABASE', priv.grantee, data.name) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.datacl %} -{% for priv in data.datacl.changed %} -{{ PRIVILEGE.RESETALL(conn, 'DATABASE', priv.grantee, data.name) }} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.datacl %} -{% for priv in data.datacl.added %} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for tables #} -{% if data.deftblacl %} -{% if 'deleted' in data.deftblacl %} -{% for priv in data.deftblacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TABLES', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deftblacl %} -{% for priv in data.deftblacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TABLES', priv.grantee, priv.grantor) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deftblacl %} -{% for priv in data.deftblacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for sequences #} -{% if data.defseqacl %} -{% if 'deleted' in data.defseqacl %} -{% for priv in data.defseqacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.defseqacl %} -{% for priv in data.defseqacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee, priv.grantor) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.defseqacl %} -{% for priv in data.defseqacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for functions #} -{% if data.deffuncacl %} -{% if 'deleted' in data.deffuncacl %} -{% for priv in data.deffuncacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deffuncacl %} -{% for priv in data.deffuncacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee, priv.grantor) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deffuncacl %} -{% for priv in data.deffuncacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} - -{# Change the default priviledges/ACLs for types #} -{% if data.deftypeacl %} -{% if 'deleted' in data.deftypeacl %} -{% for priv in data.deftypeacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TYPES', priv.grantee, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deftypeacl %} -{% for priv in data.deftypeacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TYPES', priv.grantee, priv.grantor) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deftypeacl %} -{% for priv in data.deftypeacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endfor %} -{% endif %} -{% endif %} - -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/defacl.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/defacl.sql deleted file mode 100644 index 2527a5d36..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/defacl.sql +++ /dev/null @@ -1,161 +0,0 @@ -{% if not grant_reovke_sql %} -(SELECT - CASE (a.deftype) - WHEN 'r' THEN 'deftblacl' - WHEN 'S' THEN 'defseqacl' - WHEN 'f' THEN 'deffuncacl' - WHEN 'T' THEN 'deftypeacl' - END AS deftype, - 'defaultacls' as acltype, - COALESCE(gt.rolname, 'PUBLIC') AS grantee, g.rolname AS grantor, pg_catalog.array_agg(a.privilege_type) as privileges, pg_catalog.array_agg(a.is_grantable) as grantable -FROM - (SELECT - (acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable AS is_grantable, - CASE (acl).privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type, - defaclobjtype as deftype - FROM - (SELECT defaclobjtype, pg_catalog.aclexplode(defaclacl) as acl FROM pg_catalog.pg_default_acl dacl - WHERE dacl.defaclnamespace = 0::OID) d) a - LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname, a.deftype -ORDER BY a.deftype - ) -{% else %} -SELECT * from ( -(SELECT - CASE (e.deftype) - WHEN 'r' THEN 'deftblacl' - WHEN 'S' THEN 'defseqacl' - WHEN 'f' THEN 'deffuncacl' - WHEN 'T' THEN 'deftypeacl' - END AS deftype, - 'revoke' as acltype, - COALESCE(gt.rolname, 'PUBLIC') AS grantee, g.rolname AS grantor, pg_catalog.array_agg(e.privilege_type) as privileges, pg_catalog.array_agg(e.is_grantable) as grantable -FROM( - SELECT - (d.acl).grantee as grantee, (d.acl).grantor AS grantor, (d.acl).is_grantable AS is_grantable, - CASE (d.acl).privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type, - d.defaclobjtype as deftype - FROM - (select - b.defaclobjtype, - pg_catalog.aclexplode(b.revoke_priv) as acl - from - (select - a.defaclobjtype, - a.defaclrole, - a.defaultprivileges, - a.acldefault, - array(select unnest(a.acldefault) except select unnest(a.defaultprivileges)) as revoke_priv - from - (SELECT - defaclobjtype, - defaclrole, - defaclacl as defaultprivileges, - CASE - WHEN defaclnamespace = 0 THEN acldefault(CASE WHEN defaclobjtype = 'S' THEN 's'::"char" ELSE defaclobjtype END, defaclrole) - ELSE '{}' - END AS acldefault - FROM pg_catalog.pg_default_acl dacl - WHERE dacl.defaclnamespace = 0::OID - ) a - ) b - where not b.revoke_priv = '{}' - ) d - ) e -LEFT JOIN pg_catalog.pg_roles g ON (e.grantor = g.oid) -LEFT JOIN pg_catalog.pg_roles gt ON (e.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname, e.deftype -ORDER BY e.deftype) - -UNION -( -SELECT - CASE (e.deftype) - WHEN 'r' THEN 'deftblacl' - WHEN 'S' THEN 'defseqacl' - WHEN 'f' THEN 'deffuncacl' - WHEN 'T' THEN 'deftypeacl' - END AS deftype, - 'grant' as acltype, - COALESCE(gt.rolname, 'PUBLIC') AS grantee, g.rolname AS grantor, pg_catalog.array_agg(e.privilege_type) as privileges, pg_catalog.array_agg(e.is_grantable) as grantable -FROM( - SELECT - (d.acl).grantee as grantee, (d.acl).grantor AS grantor, (d.acl).is_grantable AS is_grantable, - CASE (d.acl).privilege_type - WHEN 'CONNECT' THEN 'c' - WHEN 'CREATE' THEN 'C' - WHEN 'DELETE' THEN 'd' - WHEN 'EXECUTE' THEN 'X' - WHEN 'INSERT' THEN 'a' - WHEN 'REFERENCES' THEN 'x' - WHEN 'SELECT' THEN 'r' - WHEN 'TEMPORARY' THEN 'T' - WHEN 'TRIGGER' THEN 't' - WHEN 'TRUNCATE' THEN 'D' - WHEN 'UPDATE' THEN 'w' - WHEN 'USAGE' THEN 'U' - ELSE 'UNKNOWN' - END AS privilege_type, - d.defaclobjtype as deftype - FROM( - select - *, - pg_catalog.aclexplode(b.grant_priv) as acl - from - (select - a.defaclobjtype, - a.defaclrole, - a.defaultprivileges, - a.acldefault, - array(select unnest(a.defaultprivileges) except select unnest(a.acldefault)) as grant_priv - from - (SELECT - defaclobjtype, - defaclrole, - defaclacl as defaultprivileges, - CASE - WHEN defaclnamespace = 0 - THEN acldefault(CASE WHEN defaclobjtype = 'S' THEN 's'::"char" ELSE defaclobjtype END, defaclrole) - ELSE '{}' - END AS acldefault - FROM pg_catalog.pg_default_acl dacl - WHERE dacl.defaclnamespace = 0::OID - ) a - ) b where not b.grant_priv = '{}' - ) d - ) e -LEFT JOIN pg_catalog.pg_roles g ON (e.grantor = g.oid) - LEFT JOIN pg_catalog.pg_roles gt ON (e.grantee = gt.oid) -GROUP BY g.rolname, gt.rolname, e.deftype -ORDER BY e.deftype)) f order by f.acltype DESC -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/get_variables.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/get_variables.sql deleted file mode 100644 index 468e1ddd2..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/get_variables.sql +++ /dev/null @@ -1,6 +0,0 @@ -SELECT - rl.*, r.rolname AS user_name, db.datname as db_name -FROM pg_catalog.pg_db_role_setting AS rl - LEFT JOIN pg_catalog.pg_roles AS r ON rl.setrole = r.oid - LEFT JOIN pg_catalog.pg_database AS db ON rl.setdatabase = db.oid -WHERE setdatabase = {{did}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/grant.sql deleted file mode 100644 index 87e18ee0d..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/grant.sql +++ /dev/null @@ -1,83 +0,0 @@ -{# -# CREATE DATABASE does not allow us to run any -# other sql statements along with it, so we wrote -# separate sql for rest alter sql statements here -#} -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} -{% if data.comments %} -COMMENT ON DATABASE {{ conn|qtIdent(data.name) }} - IS {{ data.comments|qtLiteral }}; -{% endif %} - -{# Change the security labels #} -{% if data.seclabels %} -{% for r in data.seclabels %} -{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{# Variables/options #} -{% if data.variables %} -{% for var in data.variables %} -{% if var.value == True %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'on') }} -{% elif var.value == False %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, 'off') }} -{% else %} -{{ VARIABLE.APPLY(conn, data.name, var.role, var.name, var.value) }} -{% endif %} -{% endfor %} -{% endif %} - -{# Privileges/ACLs #} -{% if data.datacl %} -{% for priv in data.datacl %} -{{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} - -{# Default privileges/ACLs for tables #} -{% if data.deftblacl %} -{% for priv in data.deftblacl %} -{% if priv.acltype == 'grant' %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% else %} -{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endif %} -{% endfor %} - -{% endif %} -{# Default privileges/ACLs for sequences #} -{% if data.defseqacl %} -{% for priv in data.defseqacl %} -{% if priv.acltype == 'grant' %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% else %} -{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endif %} -{% endfor %} -{% endif %} - -{# Default privileges/ACLs for functions #} -{% if data.deffuncacl %} -{% for priv in data.deffuncacl %} -{% if priv.acltype == 'grant' %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% else %} -{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endif %} -{% endfor %} -{% endif %} - -{# Default privileges/ACLs for types #} -{% if data.deftypeacl %} -{% for priv in data.deftypeacl %} -{% if priv.acltype == 'grant' %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% else %} -{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} -{% endif %} -{% endfor %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.6_plus/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.6_plus/delete.sql deleted file mode 100644 index 2b52461d5..000000000 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.6_plus/delete.sql +++ /dev/null @@ -1,8 +0,0 @@ -{# We need database name before we execute drop #} -{% if did %} -SELECT db.datname as name FROM pg_catalog.pg_database as db WHERE db.oid = {{did}}; -{% endif %} -{# Using name from above query we will drop the database #} -{% if datname %} -DROP DATABASE IF EXISTS {{ conn|qtIdent(datname) }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/acl.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/acl.sql index 585851add..8fe549790 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/acl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/acl.sql @@ -4,9 +4,7 @@ SELECT pg_catalog.array_agg(is_grantable) AS grantable FROM (SELECT - d.grantee, - d.grantor, - d.is_grantable, + d.grantee, d.grantor, d.is_grantable, CASE d.privilege_type WHEN 'CONNECT' THEN 'c' WHEN 'CREATE' THEN 'C' @@ -24,36 +22,14 @@ FROM END AS privilege_type FROM (SELECT - u_grantor.oid AS grantor, - grantee.oid AS grantee, - pr.type AS privilege_type, - pg_catalog.aclcontains(c.datacl, pg_catalog.makeaclitem(grantee.oid, u_grantor.oid, pr.type, true)) AS is_grantable - FROM pg_catalog.pg_database c, pg_catalog.pg_authid u_grantor, ( - SELECT pg_catalog.pg_authid.oid, pg_catalog.pg_authid.rolname - FROM pg_catalog.pg_authid - UNION ALL - SELECT 0::oid AS oid, 'PUBLIC') grantee(oid, rolname), - ( SELECT 'SELECT' - UNION ALL - SELECT 'INSERT' - UNION ALL - SELECT 'UPDATE' - UNION ALL - SELECT 'DELETE' - UNION ALL - SELECT 'TRUNCATE' - UNION ALL - SELECT 'REFERENCES' - UNION ALL - SELECT 'TRIGGER') pr(type) - WHERE pg_catalog.aclcontains(c.datacl, pg_catalog.makeaclitem(grantee.oid, u_grantor.oid, pr.type, false)) - AND (pg_catalog.pg_has_role(u_grantor.oid, 'USAGE'::text) OR pg_catalog.pg_has_role(grantee.oid, 'USAGE'::text) - OR grantee.rolname = 'PUBLIC'::name) - AND c.oid = {{ did|qtLiteral }}::OID + (d).grantee AS grantee, (d).grantor AS grantor, + (d).is_grantable AS is_grantable, + (d).privilege_type AS privilege_type + FROM + (SELECT pg_catalog.aclexplode(db.datacl) AS d FROM pg_catalog.pg_database db + WHERE db.oid = {{ did|qtLiteral }}::OID) a ) d ) d LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid) LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid) GROUP BY g.rolname, gt.rolname; - - diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/alter_online.sql index 9296ee6cb..b8a8c2c0d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/alter_online.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/alter_online.sql @@ -3,6 +3,28 @@ {% import 'macros/privilege.macros' as PRIVILEGE %} {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %} {% if data %} + +{# Change the default priviledges for the functions #} +{% if data.deffuncacl %} +{% if 'deleted' in data.deffuncacl %} +{% for priv in data.deffuncacl.deleted %} +{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee, priv.grantor) }} +{% endfor %} +{% endif %} +{% if 'changed' in data.deffuncacl %} +{% for priv in data.deffuncacl.changed %} +{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee) }} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% endfor %} +{% endif %} +{% if 'added' in data.deffuncacl %} +{% for priv in data.deffuncacl.added %} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% endfor %} +{% endif %} +{% endif %} + + {# Change the variables/options #} {% if data.variables and data.variables|length > 0 %} {% set variables = data.variables %} @@ -59,7 +81,7 @@ {% if data.deftblacl %} {% if 'deleted' in data.deftblacl %} {% for priv in data.deftblacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESET(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} +{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'TABLES', priv.grantee, priv.grantor) }} {% endfor %} {% endif %} {% if 'changed' in data.deftblacl %} @@ -69,7 +91,7 @@ {% endif %} {% if 'added' in data.deftblacl %} {% for priv in data.deftblacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} {% endfor %} {% endif %} {% endif %} @@ -79,41 +101,23 @@ {% if data.defseqacl %} {% if 'deleted' in data.defseqacl %} {% for priv in data.defseqacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee) }} +{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee, priv.grantor) }} {% endfor %} {% endif %} {% if 'changed' in data.defseqacl %} {% for priv in data.defseqacl.changed %} {{ DEFAULT_PRIVILEGE.RESETALL(conn, 'SEQUENCES', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant) }} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} {% endfor %} {% endif %} {% if 'added' in data.defseqacl %} {% for priv in data.defseqacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant) }} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} {% endfor %} {% endif %} {% endif %} -{# Change the default priviledges for the functions #} -{% if data.deffuncacl %} -{% if 'deleted' in data.deffuncacl %} -{% for priv in data.deffuncacl.deleted %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.deffuncacl %} -{% for priv in data.deffuncacl.changed %} -{{ DEFAULT_PRIVILEGE.RESETALL(conn, 'FUNCTIONS', priv.grantee) }} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.deffuncacl %} -{% for priv in data.deffuncacl.added %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% endif %} + {% endif %} {# Change the security labels #} @@ -136,3 +140,8 @@ {% endif %} {% endif %} {% endif %} + +{# Alter database to template DB or vice versa #} +{% if data.is_template is defined %} +ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH IS_TEMPLATE = {{ data.is_template }}; +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/create.sql index 9f153356b..11f96cbcb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/create.sql @@ -15,5 +15,7 @@ CREATE DATABASE {{ conn|qtIdent(data.name) }} TABLESPACE = {{ conn|qtIdent(data.spcname) }}{% endif %}{% if data.datconnlimit %} - CONNECTION LIMIT = {{ data.datconnlimit }}{% endif %}; + CONNECTION LIMIT = {{ data.datconnlimit }}{% endif %} + + IS_TEMPLATE = {{ data.is_template }}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/defacl.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/defacl.sql index 191e40ccb..2527a5d36 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/defacl.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/defacl.sql @@ -1,7 +1,161 @@ +{% if not grant_reovke_sql %} +(SELECT + CASE (a.deftype) + WHEN 'r' THEN 'deftblacl' + WHEN 'S' THEN 'defseqacl' + WHEN 'f' THEN 'deffuncacl' + WHEN 'T' THEN 'deftypeacl' + END AS deftype, + 'defaultacls' as acltype, + COALESCE(gt.rolname, 'PUBLIC') AS grantee, g.rolname AS grantor, pg_catalog.array_agg(a.privilege_type) as privileges, pg_catalog.array_agg(a.is_grantable) as grantable +FROM + (SELECT + (acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable AS is_grantable, + CASE (acl).privilege_type + WHEN 'CONNECT' THEN 'c' + WHEN 'CREATE' THEN 'C' + WHEN 'DELETE' THEN 'd' + WHEN 'EXECUTE' THEN 'X' + WHEN 'INSERT' THEN 'a' + WHEN 'REFERENCES' THEN 'x' + WHEN 'SELECT' THEN 'r' + WHEN 'TEMPORARY' THEN 'T' + WHEN 'TRIGGER' THEN 't' + WHEN 'TRUNCATE' THEN 'D' + WHEN 'UPDATE' THEN 'w' + WHEN 'USAGE' THEN 'U' + ELSE 'UNKNOWN' + END AS privilege_type, + defaclobjtype as deftype + FROM + (SELECT defaclobjtype, pg_catalog.aclexplode(defaclacl) as acl FROM pg_catalog.pg_default_acl dacl + WHERE dacl.defaclnamespace = 0::OID) d) a + LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid) + LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid) +GROUP BY g.rolname, gt.rolname, a.deftype +ORDER BY a.deftype + ) +{% else %} +SELECT * from ( +(SELECT + CASE (e.deftype) + WHEN 'r' THEN 'deftblacl' + WHEN 'S' THEN 'defseqacl' + WHEN 'f' THEN 'deffuncacl' + WHEN 'T' THEN 'deftypeacl' + END AS deftype, + 'revoke' as acltype, + COALESCE(gt.rolname, 'PUBLIC') AS grantee, g.rolname AS grantor, pg_catalog.array_agg(e.privilege_type) as privileges, pg_catalog.array_agg(e.is_grantable) as grantable +FROM( + SELECT + (d.acl).grantee as grantee, (d.acl).grantor AS grantor, (d.acl).is_grantable AS is_grantable, + CASE (d.acl).privilege_type + WHEN 'CONNECT' THEN 'c' + WHEN 'CREATE' THEN 'C' + WHEN 'DELETE' THEN 'd' + WHEN 'EXECUTE' THEN 'X' + WHEN 'INSERT' THEN 'a' + WHEN 'REFERENCES' THEN 'x' + WHEN 'SELECT' THEN 'r' + WHEN 'TEMPORARY' THEN 'T' + WHEN 'TRIGGER' THEN 't' + WHEN 'TRUNCATE' THEN 'D' + WHEN 'UPDATE' THEN 'w' + WHEN 'USAGE' THEN 'U' + ELSE 'UNKNOWN' + END AS privilege_type, + d.defaclobjtype as deftype + FROM + (select + b.defaclobjtype, + pg_catalog.aclexplode(b.revoke_priv) as acl + from + (select + a.defaclobjtype, + a.defaclrole, + a.defaultprivileges, + a.acldefault, + array(select unnest(a.acldefault) except select unnest(a.defaultprivileges)) as revoke_priv + from + (SELECT + defaclobjtype, + defaclrole, + defaclacl as defaultprivileges, + CASE + WHEN defaclnamespace = 0 THEN acldefault(CASE WHEN defaclobjtype = 'S' THEN 's'::"char" ELSE defaclobjtype END, defaclrole) + ELSE '{}' + END AS acldefault + FROM pg_catalog.pg_default_acl dacl + WHERE dacl.defaclnamespace = 0::OID + ) a + ) b + where not b.revoke_priv = '{}' + ) d + ) e +LEFT JOIN pg_catalog.pg_roles g ON (e.grantor = g.oid) +LEFT JOIN pg_catalog.pg_roles gt ON (e.grantee = gt.oid) +GROUP BY g.rolname, gt.rolname, e.deftype +ORDER BY e.deftype) + +UNION +( SELECT - '' AS deftype, - '' AS grantee, - '' AS grantor, - '' AS grantor, - '' AS privileges, - '' AS grantable + CASE (e.deftype) + WHEN 'r' THEN 'deftblacl' + WHEN 'S' THEN 'defseqacl' + WHEN 'f' THEN 'deffuncacl' + WHEN 'T' THEN 'deftypeacl' + END AS deftype, + 'grant' as acltype, + COALESCE(gt.rolname, 'PUBLIC') AS grantee, g.rolname AS grantor, pg_catalog.array_agg(e.privilege_type) as privileges, pg_catalog.array_agg(e.is_grantable) as grantable +FROM( + SELECT + (d.acl).grantee as grantee, (d.acl).grantor AS grantor, (d.acl).is_grantable AS is_grantable, + CASE (d.acl).privilege_type + WHEN 'CONNECT' THEN 'c' + WHEN 'CREATE' THEN 'C' + WHEN 'DELETE' THEN 'd' + WHEN 'EXECUTE' THEN 'X' + WHEN 'INSERT' THEN 'a' + WHEN 'REFERENCES' THEN 'x' + WHEN 'SELECT' THEN 'r' + WHEN 'TEMPORARY' THEN 'T' + WHEN 'TRIGGER' THEN 't' + WHEN 'TRUNCATE' THEN 'D' + WHEN 'UPDATE' THEN 'w' + WHEN 'USAGE' THEN 'U' + ELSE 'UNKNOWN' + END AS privilege_type, + d.defaclobjtype as deftype + FROM( + select + *, + pg_catalog.aclexplode(b.grant_priv) as acl + from + (select + a.defaclobjtype, + a.defaclrole, + a.defaultprivileges, + a.acldefault, + array(select unnest(a.defaultprivileges) except select unnest(a.acldefault)) as grant_priv + from + (SELECT + defaclobjtype, + defaclrole, + defaclacl as defaultprivileges, + CASE + WHEN defaclnamespace = 0 + THEN acldefault(CASE WHEN defaclobjtype = 'S' THEN 's'::"char" ELSE defaclobjtype END, defaclrole) + ELSE '{}' + END AS acldefault + FROM pg_catalog.pg_default_acl dacl + WHERE dacl.defaclnamespace = 0::OID + ) a + ) b where not b.grant_priv = '{}' + ) d + ) e +LEFT JOIN pg_catalog.pg_roles g ON (e.grantor = g.oid) + LEFT JOIN pg_catalog.pg_roles gt ON (e.grantee = gt.oid) +GROUP BY g.rolname, gt.rolname, e.deftype +ORDER BY e.deftype)) f order by f.acltype DESC +{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/delete.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/delete.sql index 48886d981..2b52461d5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/delete.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/delete.sql @@ -4,5 +4,5 @@ SELECT db.datname as name FROM pg_catalog.pg_database as db WHERE db.oid = {{did {% endif %} {# Using name from above query we will drop the database #} {% if datname %} - DROP DATABASE {{ conn|qtIdent(datname) }}; +DROP DATABASE IF EXISTS {{ conn|qtIdent(datname) }}; {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_variables.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_variables.sql index d5384c644..468e1ddd2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/get_variables.sql @@ -1,2 +1,6 @@ -SELECT NULL -WHERE false +SELECT + rl.*, r.rolname AS user_name, db.datname as db_name +FROM pg_catalog.pg_db_role_setting AS rl + LEFT JOIN pg_catalog.pg_roles AS r ON rl.setrole = r.oid + LEFT JOIN pg_catalog.pg_database AS db ON rl.setdatabase = db.oid +WHERE setdatabase = {{did}} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/grant.sql index b9275c6e0..87e18ee0d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/grant.sql @@ -1,7 +1,7 @@ {# -# CREATE DATABSE does not allow us to run any -# other sql statments along with it, so we wrote -# seprate sql for rest alter sql statments here +# CREATE DATABASE does not allow us to run any +# other sql statements along with it, so we wrote +# separate sql for rest alter sql statements here #} {% import 'macros/security.macros' as SECLABEL %} {% import 'macros/variable.macros' as VARIABLE %} @@ -12,13 +12,13 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }} IS {{ data.comments|qtLiteral }}; {% endif %} -{# Generate the security labels #} +{# Change the security labels #} {% if data.seclabels %} {% for r in data.seclabels %} {{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} {% endfor %} {% endif %} -{# TO generate Variable SQL using macro #} +{# Variables/options #} {% if data.variables %} {% for var in data.variables %} {% if var.value == True %} @@ -30,23 +30,54 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }} {% endif %} {% endfor %} {% endif %} + +{# Privileges/ACLs #} {% if data.datacl %} {% for priv in data.datacl %} {{ PRIVILEGE.APPLY(conn, 'DATABASE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} {% endfor %} {% endif %} + +{# Default privileges/ACLs for tables #} {% if data.deftblacl %} {% for priv in data.deftblacl %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant) }} -{% endfor %} +{% if priv.acltype == 'grant' %} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% else %} +{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'TABLES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} {% endif %} +{% endfor %} + +{% endif %} +{# Default privileges/ACLs for sequences #} {% if data.defseqacl %} {% for priv in data.defseqacl %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant) }} +{% if priv.acltype == 'grant' %} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% else %} +{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'SEQUENCES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% endif %} {% endfor %} {% endif %} + +{# Default privileges/ACLs for functions #} {% if data.deffuncacl %} {% for priv in data.deffuncacl %} -{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant) }} +{% if priv.acltype == 'grant' %} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% else %} +{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'FUNCTIONS', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% endif %} +{% endfor %} +{% endif %} + +{# Default privileges/ACLs for types #} +{% if data.deftypeacl %} +{% for priv in data.deftypeacl %} +{% if priv.acltype == 'grant' %} +{{ DEFAULT_PRIVILEGE.APPLY(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% else %} +{{ DEFAULT_PRIVILEGE.REMOVE(conn, 'TYPES', priv.grantee, priv.without_grant, priv.with_grant, priv.grantor) }} +{% endif %} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql index 15ca26ea3..7dea8b1d5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/properties.sql @@ -20,15 +20,23 @@ FROM pg_catalog.pg_database db LEFT OUTER JOIN pg_catalog.pg_shdescription descr ON ( db.oid=descr.objoid AND descr.classoid='pg_database'::regclass ) -WHERE {% if did %} -db.oid = {{ did|qtLiteral }}::OID +WHERE +{% if show_user_defined_templates is defined %} + db.datistemplate = {{show_user_defined_templates}} AND +{% endif %} +{% if did %} + db.oid = {{ did|qtLiteral }}::OID +{% else %} + {% if name %} + db.datname = {{ name|qtLiteral }}::text + {% endif %} {% endif %} -{% if db_restrictions %} -{% if did %}AND{% endif %} -db.datname in ({{db_restrictions}}) -{% elif not did%} -db.oid > {{ last_system_oid }}::OID OR db.datname IN ('postgres', 'edb') +{% if db_restrictions %} + {% if did or name %}AND{% endif %} + db.datname in ({{db_restrictions}}) +{% elif not did and not name%} + db.oid > {{ last_system_oid }}::OID OR db.datname IN ('postgres', 'edb') {% endif %} ORDER BY datname; diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/create.sql deleted file mode 100644 index fc7b9e2b5..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/create.sql +++ /dev/null @@ -1,61 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -CREATE ROLE {{ conn|qtIdent(data.rolname) }} WITH{% if data.rolcanlogin and data.rolcanlogin is sameas True %} - - LOGIN{% else %} - - NOLOGIN{% endif %}{% if data.rolsuper %} - - SUPERUSER{% else %} - - NOSUPERUSER{% endif %}{% if data.rolcreatedb %} - - CREATEDB{% else %} - - NOCREATEDB{% endif %}{% if data.rolcreaterole %} - - CREATEROLE{% else %} - - NOCREATEROLE{% endif %}{% if data.rolinherit is sameas true %} - - INHERIT{% else %} - - NOINHERIT{% endif %}{% if data.rolreplication %} - - REPLICATION{% else %} - - NOREPLICATION{% endif %}{% if 'rolconnlimit' in data and data.rolconnlimit is number and data.rolconnlimit >= -1 %} - - CONNECTION LIMIT {{ data.rolconnlimit }}{% endif %}{% if data.rolvaliduntil and data.rolvaliduntil is not none %} - - VALID UNTIL {{ data.rolvaliduntil|qtLiteral }} {% endif %}{% if data.rolpassword %} - - PASSWORD {% if data.rolpassword is none %}NULL{% else %}{% if dummy %}'xxxxxx'{% else %} {{ data.rolpassword | qtLiteral }}{% endif %}{% endif %}{% endif %};{% if data.rolsuper and data.rolcatupdate is sameas false %} - - -UPDATE pg_catalog.pg_authid SET rolcatupdate=false WHERE rolname = {{ data.rolname|qtLiteral }};{% endif %}{% if data.members and data.members|length > 0 %} - - -GRANT {{ conn|qtIdent(data.members)|join(', ') }} TO {{ conn|qtIdent(data.rolname) }};{% endif %}{% if data.admins and data.admins|length > 0 %} - -GRANT {{ conn|qtIdent(data.admins)|join(', ') }} TO {{ conn|qtIdent(data.rolname) }} WITH ADMIN OPTION;{% endif %}{% if data.seclabels and data.seclabels|length > 0 %} - -{% for r in data.seclabels %} - -{{ SECLABEL.APPLY(conn, 'ROLE', data.rolname, r.provider, r.label) }} -{% endfor %}{% endif %}{% if data.variables %} - -{% for var in data.variables %} - -{{ VARIABLE.APPLY(conn, var.database, data.rolname, var.name, var.value) }} -{% endfor %}{% endif %}{% if data.description %} - -COMMENT ON ROLE {{ conn|qtIdent(data.rolname) }} IS {{ data.description|qtLiteral }}; -{% endif %} - -{% if data.rol_admins and data.rol_admins|length > 0 %} - -GRANT {{ conn|qtIdent(data.rolname) }} TO {{ conn|qtIdent(data.rol_admins)|join(', ') }} WITH ADMIN OPTION;{% endif %}{% if data.rol_members and data.rol_members|length > 0 %} - -GRANT {{ conn|qtIdent(data.rolname) }} TO {{ conn|qtIdent(data.rol_members)|join(', ') }}; -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/dependents.sql deleted file mode 100644 index 18bcc1f82..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/dependents.sql +++ /dev/null @@ -1,40 +0,0 @@ -{% if fetch_database %} -SELECT 'd' as type, datname, - datallowconn AND pg_catalog.has_database_privilege(datname, 'CONNECT') AS datallowconn, - datdba -FROM pg_catalog.pg_database db -UNION -SELECT 'M', spcname, null, null - FROM pg_catalog.pg_tablespace where spcowner= {{rid}}::oid -ORDER BY 1, 2 -{% endif %} - -{% if fetch_dependents %} -SELECT cl.relkind, COALESCE(cin.nspname, cln.nspname) as nspname, - COALESCE(ci.relname, cl.relname) as relname, cl.relname as indname -FROM pg_catalog.pg_class cl -JOIN pg_catalog.pg_namespace cln ON cl.relnamespace=cln.oid -LEFT OUTER JOIN pg_catalog.pg_index ind ON ind.indexrelid=cl.oid -LEFT OUTER JOIN pg_catalog.pg_class ci ON ind.indrelid=ci.oid -LEFT OUTER JOIN pg_catalog.pg_namespace cin ON ci.relnamespace=cin.oid -WHERE cl.oid IN (SELECT objid FROM pg_catalog.pg_shdepend WHERE refobjid={{rid}}::oid) AND cl.oid > {{lastsysoid}}::oid -UNION ALL SELECT 'n', null, nspname, null - FROM pg_catalog.pg_namespace nsp - WHERE nsp.oid IN (SELECT objid FROM pg_catalog.pg_shdepend WHERE refobjid={{rid}}::oid) AND nsp.oid > {{lastsysoid}}::oid -UNION ALL SELECT CASE WHEN typtype='d' THEN 'd' ELSE 'y' END, null, typname, null - FROM pg_catalog.pg_type ty - WHERE ty.oid IN (SELECT objid FROM pg_catalog.pg_shdepend WHERE refobjid={{rid}}::oid) AND ty.oid > {{lastsysoid}}::oid -UNION ALL SELECT 'C', null, conname, null - FROM pg_catalog.pg_conversion co - WHERE co.oid IN (SELECT objid FROM pg_catalog.pg_shdepend WHERE refobjid={{rid}}::oid) AND co.oid > {{lastsysoid}}::oid -UNION ALL SELECT CASE WHEN prorettype=2279 THEN 'T' ELSE 'p' END, null, proname, null - FROM pg_catalog.pg_proc pr - WHERE pr.oid IN (SELECT objid FROM pg_catalog.pg_shdepend WHERE refobjid={{rid}}::oid) AND pr.oid > {{lastsysoid}}::oid -UNION ALL SELECT 'o', null, oprname || '('::text || COALESCE(tl.typname, ''::text) || CASE WHEN tl.oid IS NOT NULL - AND tr.oid IS NOT NULL THEN ','::text END || COALESCE(tr.typname, ''::text) || ')'::text, null - FROM pg_catalog.pg_operator op - LEFT JOIN pg_catalog.pg_type tl ON tl.oid=op.oprleft - LEFT JOIN pg_catalog.pg_type tr ON tr.oid=op.oprright - WHERE op.oid IN (SELECT objid FROM pg_catalog.pg_shdepend WHERE refobjid={{rid}}::oid) AND op.oid > {{lastsysoid}}::oid -ORDER BY 1,2,3 -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/permission.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/permission.sql deleted file mode 100644 index a9180095e..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/permission.sql +++ /dev/null @@ -1,5 +0,0 @@ -SELECT - rolname, rolcanlogin, rolcatupdate, rolsuper -FROM - pg_catalog.pg_roles -WHERE oid = {{ rid }}::OID diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/properties.sql deleted file mode 100644 index a48cf73f4..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/properties.sql +++ /dev/null @@ -1,26 +0,0 @@ -SELECT - r.oid, r.*, - pg_catalog.shobj_description(r.oid, 'pg_authid') AS description, - ARRAY( - SELECT - CASE WHEN am.admin_option THEN '1' ELSE '0' END || rm.rolname - FROM - (SELECT * FROM pg_catalog.pg_auth_members WHERE member = r.oid) am - LEFT JOIN pg_catalog.pg_roles rm ON (rm.oid = am.roleid) - ) rolmembership, - (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_shseclabel sl1 WHERE sl1.objoid=r.oid) AS seclabels - {% if rid %} - ,ARRAY( - SELECT - CASE WHEN pg.admin_option THEN '1' ELSE '0' END || pg.usename - FROM - (SELECT pg_roles.rolname AS usename, pg_auth_members.admin_option AS admin_option FROM pg_roles - JOIN pg_auth_members ON pg_roles.oid=pg_auth_members.member AND pg_auth_members.roleid={{ rid|qtLiteral }}::oid) pg - ) rolmembers - {% endif %} -FROM - pg_catalog.pg_roles r -{% if rid %} -WHERE r.oid = {{ rid|qtLiteral }}::oid -{% endif %} -ORDER BY r.rolcanlogin, r.rolname diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/sql.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/sql.sql deleted file mode 100644 index 0d2559714..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/sql.sql +++ /dev/null @@ -1,118 +0,0 @@ -SELECT - pg_catalog.array_to_string(array_agg(sql), E'\n\n') -FROM -(SELECT - '-- Role: ' || - pg_catalog.quote_ident(rolname) || - E'\n-- DROP ROLE IF EXISTS ' || - pg_catalog.quote_ident(rolname) || E';\n\nCREATE ROLE ' || - pg_catalog.quote_ident(rolname) || E' WITH\n ' || - CASE WHEN rolcanlogin THEN 'LOGIN' ELSE 'NOLOGIN' END || E'\n ' || - CASE WHEN rolcanlogin AND rolpassword LIKE 'md5%%' THEN 'ENCRYPTED PASSWORD ' || pg_catalog.quote_literal(rolpassword) || E'\n ' ELSE '' END || - CASE WHEN rolsuper THEN 'SUPERUSER' ELSE 'NOSUPERUSER' END || E'\n ' || - CASE WHEN rolinherit THEN 'INHERIT' ELSE 'NOINHERIT' END || E'\n ' || - CASE WHEN rolcreatedb THEN 'CREATEDB' ELSE 'NOCREATEDB' END || E'\n ' || - CASE WHEN rolcreaterole THEN 'CREATEROLE' ELSE 'NOCREATEROLE' END || E'\n ' || - -- PostgreSQL >= 9.1 - CASE WHEN rolreplication THEN 'REPLICATION' ELSE 'NOREPLICATION' END || - CASE WHEN rolconnlimit > 0 THEN E'\n CONNECTION LIMIT ' || rolconnlimit ELSE '' END || - CASE WHEN rolvaliduntil IS NOT NULL THEN E'\n VALID UNTIL ' || pg_catalog.quote_literal(rolvaliduntil::text) ELSE '' END || ';' || - -- PostgreSQL < 9.5 - CASE WHEN rolsuper AND NOT rolcatupdate THEN E'\n\nUPDATE pg_catalog.pg_authid SET rolcatupdate=false WHERE rolname=' || pg_catalog.quote_literal(rolname) || ';' ELSE '' END AS sql -FROM - pg_catalog.pg_roles r -WHERE - r.oid=%(rid)s::OID -UNION ALL -(SELECT - pg_catalog.array_to_string(array_agg(sql), E'\n') -FROM -(SELECT - 'GRANT ' || pg_catalog.array_to_string(pg_catalog.array_agg(rolname), ', ') || ' TO ' || pg_catalog.quote_ident(pg_catalog.pg_get_userbyid(%(rid)s::OID)) || - CASE WHEN admin_option THEN ' WITH ADMIN OPTION;' ELSE ';' END AS sql -FROM - (SELECT - pg_catalog.quote_ident(r.rolname) AS rolname, m.admin_option AS admin_option - FROM - pg_catalog.pg_auth_members m - LEFT JOIN pg_catalog.pg_roles r ON (m.roleid = r.oid) - WHERE - m.member=%(rid)s::OID - ORDER BY - r.rolname - ) a -GROUP BY admin_option) s) -UNION ALL -(SELECT - pg_catalog.array_to_string(array_agg(sql), E'\n') AS sql -FROM -(SELECT - 'ALTER ROLE ' || pg_catalog.quote_ident(rolname) || ' SET ' || param || ' TO ' || CASE WHEN param IN ('search_path', 'temp_tablespaces') THEN value ELSE pg_catalog.quote_literal(value) END || ';' AS sql -FROM -(SELECT - rolcanlogin, rolname, pg_catalog.split_part(rolconfig, '=', 1) AS param, pg_catalog.replace(rolconfig, pg_catalog.split_part(rolconfig, '=', 1) || '=', '') AS value -FROM - (SELECT - pg_catalog.unnest(rolconfig) AS rolconfig, rolcanlogin, rolname - FROM - pg_catalog.pg_roles - WHERE - oid=%(rid)s::OID - ) r -) a) b) --- PostgreSQL >= 9.0 -UNION ALL -(SELECT - pg_catalog.array_to_string(array_agg(sql), E'\n') AS sql -FROM - (SELECT - 'ALTER ROLE ' || pg_catalog.quote_ident(pg_catalog.pg_get_userbyid(%(rid)s::OID)) || - ' IN DATABASE ' || pg_catalog.quote_ident(datname) || - ' SET ' || param|| ' TO ' || - CASE - WHEN param IN ('search_path', 'temp_tablespaces') THEN value - ELSE pg_catalog.quote_literal(value) - END || ';' AS sql - FROM - (SELECT - datname, pg_catalog.split_part(rolconfig, '=', 1) AS param, pg_catalog.replace(rolconfig, pg_catalog.split_part(rolconfig, '=', 1) || '=', '') AS value - FROM - (SELECT - d.datname, pg_catalog.unnest(c.setconfig) AS rolconfig - FROM - (SELECT * - FROM - pg_catalog.pg_db_role_setting dr - WHERE - dr.setrole=%(rid)s::OID AND dr.setdatabase!=0) c - LEFT JOIN pg_catalog.pg_database d ON (d.oid = c.setdatabase) - ) a - ) b - ) d -) -UNION ALL -(SELECT - 'COMMENT ON ROLE ' || pg_catalog.quote_ident(pg_catalog.pg_get_userbyid(%(rid)s::OID)) || ' IS ' || pg_catalog.quote_literal(description) || ';' AS sql -FROM - (SELECT pg_catalog.shobj_description(%(rid)s::OID, 'pg_authid') AS description) a -WHERE - description IS NOT NULL) --- PostgreSQL >= 9.2 -UNION ALL -(SELECT - pg_catalog.array_to_string(array_agg(sql), E'\n') AS sql -FROM - (SELECT - 'SECURITY LABEL FOR ' || provider || - E'\n ON ROLE ' || pg_catalog.quote_ident(rolname) || - E'\n IS ' || pg_catalog.quote_literal(label) || ';' AS sql - FROM - (SELECT - label, provider, rolname - FROM - (SELECT * - FROM - pg_catalog.pg_shseclabel sl1 - WHERE sl1.objoid=%(rid)s::OID) s - LEFT JOIN pg_catalog.pg_roles r ON (s.objoid=r.oid)) a) b -)) AS a diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/update.sql deleted file mode 100644 index 57323ae02..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/update.sql +++ /dev/null @@ -1,138 +0,0 @@ -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -{% if 'rolname' in data %} -{% set rolname=data.rolname %} -ALTER ROLE {{ conn|qtIdent(role) }} - RENAME TO {{ conn|qtIdent(rolname) }}; - -{% else %} -{% set rolname=role %} -{% endif %} -{% if data|hasAny(alterKeys) %} -ALTER ROLE {{ conn|qtIdent(rolname) }}{% if 'rolcanlogin' in data %} - -{% if data.rolcanlogin %} - LOGIN{% else %} - NOLOGIN{% endif %}{% endif %}{% if 'rolsuper' in data %} - -{% if data.rolsuper %} - SUPERUSER{% else %} - NOSUPERUSER{% endif %}{% endif %}{% if 'rolcreatedb' in data %} - -{% if data.rolcreatedb %} - CREATEDB{% else %} - NOCREATEDB{% endif %}{% endif %}{% if 'rolcreaterole' in data %} - -{% if data.rolcreaterole %} - CREATEROLE{% else %} - NOCREATEROLE{% endif %}{% endif %}{% if 'rolinherit' in data %} - -{% if data.rolinherit %} - INHERIT{% else %} - NOINHERIT{% endif %}{% endif %}{% if 'rolreplication' in data %} - -{% if data.rolreplication %} - REPLICATION{% else %} - NOREPLICATION{% endif %}{% endif %}{% if 'rolconnlimit' in data and data.rolconnlimit is number and data.rolconnlimit >= -1 %} - - CONNECTION LIMIT {{ data.rolconnlimit }} -{% endif %}{% if 'rolvaliduntil' in data %} - - VALID UNTIL {% if data.rolvaliduntil %}{{ data.rolvaliduntil|qtLiteral }}{% else %}'infinity' -{% endif %}{% endif %}{% if 'rolpassword' in data %} - - PASSWORD{% if data.rolpassword is none %} NULL{% else %}{% if dummy %} 'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral }}{% endif %}{% endif %}{% endif %};{% endif %} - -{% if - not rolSuper and - 'rolsuper' in data and - 'rolcatupdate' not in data and - data.rolsuper %} - - -UPDATE pg_catalog.pg_authid SET rolcatupdate=false WHERE rolname = {{ rolname|qtLiteral }}; - -{% elif - rolSuper and - 'rolsuper' not in data and - 'rolcatupdate' in data %} -{% if data.rolcatupdate %} - - -UPDATE pg_catalog.pg_authid SET rolcatupdate=true WHERE rolname = {{ rolname|qtLiteral }}; - -{% else %} - - -UPDATE pg_catalog.pg_authid SET rolcatupdate=false WHERE rolname = {{ rolname|qtLiteral }}; - -{% endif %} -{% endif %} -{% if 'revoked_admins' in data and - data.revoked_admins|length > 0 -%} - -REVOKE ADMIN OPTION FOR {{ conn|qtIdent(data.revoked_admins)|join(', ') }} FROM {{ conn|qtIdent(rolname) }};{% endif %}{% if 'revoked' in data and data.revoked|length > 0 %} - -REVOKE {{ conn|qtIdent(data.revoked)|join(', ') }} FROM {{ conn|qtIdent(rolname) }};{% endif %}{% if data.admins and data.admins|length > 0 %} - -GRANT {{ conn|qtIdent(data.admins)|join(', ') }} TO {{ conn|qtIdent(rolname) }} WITH ADMIN OPTION;{% endif %}{% if data.members and data.members|length > 0 %} - -GRANT {{ conn|qtIdent(data.members)|join(', ') }} TO {{ conn|qtIdent(rolname) }};{% endif %}{% if data.seclabels and - data.seclabels|length > 0 -%}{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} - -{% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'ROLE', rolname, r.provider) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} - -{% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'ROLE', rolname, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} - -{% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'ROLE', rolname, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% endif %} -{% if 'variables' in data and data.variables|length > 0 %} -{% set variables = data.variables %} -{% if 'deleted' in variables and variables.deleted|length > 0 %} - -{% for var in variables.deleted %} -{{ VARIABLE.RESET(conn, var.database, rolname, var.name) }} -{% endfor %}{% endif %} -{% if 'added' in variables and variables.added|length > 0 %} - -{% for var in variables.added %} -{{ VARIABLE.APPLY(conn, var.database, rolname, var.name, var.value) }} -{% endfor %}{% endif %} -{% if 'changed' in variables and variables.changed|length > 0 %} - -{% for var in variables.changed %} -{{ VARIABLE.APPLY(conn, var.database, rolname, var.name, var.value) }} -{% endfor %} -{% endif %} -{% endif %} -{% if 'description' in data %} - - -COMMENT ON ROLE {{ conn|qtIdent(rolname) }} IS {{ data.description|qtLiteral }}; -{% endif %} - -{% if 'rol_revoked_admins' in data and - data.rol_revoked_admins|length > 0 -%} - -REVOKE ADMIN OPTION FOR {{ conn|qtIdent(rolname) }} FROM {{ conn|qtIdent(data.rol_revoked_admins)|join(', ') }};{% endif %}{% if 'rol_revoked' in data and data.rol_revoked|length > 0 %} - -REVOKE {{ conn|qtIdent(rolname) }} FROM {{ conn|qtIdent(data.rol_revoked)|join(', ') }};{% endif %}{% if data.rol_admins and data.rol_admins|length > 0 %} - -GRANT {{ conn|qtIdent(rolname) }} TO {{ conn|qtIdent(data.rol_admins)|join(', ') }} WITH ADMIN OPTION;{% endif %}{% if data.rol_members and data.rol_members|length > 0 %} - -GRANT {{ conn|qtIdent(rolname) }} TO {{ conn|qtIdent(data.rol_members)|join(', ') }};{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/nodes.sql deleted file mode 100644 index 1f450b07e..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/nodes.sql +++ /dev/null @@ -1,8 +0,0 @@ -SELECT - r.oid, r.rolname, r.rolcanlogin, r.rolsuper -FROM - pg_catalog.pg_roles r -{% if rid %} -WHERE r.oid = {{ rid|qtLiteral }}::oid -{% endif %} -ORDER BY r.rolcanlogin, r.rolname diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/variables.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/variables.sql deleted file mode 100644 index 2226cd8e1..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/variables.sql +++ /dev/null @@ -1,25 +0,0 @@ -SELECT - pg_catalog.split_part(rolconfig, '=', 1) AS name, pg_catalog.replace(rolconfig, pg_catalog.split_part(rolconfig, '=', 1) || '=', '') AS value, NULL::text AS database -FROM - (SELECT - pg_catalog.unnest(rolconfig) AS rolconfig, rolcanlogin, rolname - FROM - pg_catalog.pg_roles - WHERE - oid={{ rid|qtLiteral }}::OID - ) r - -UNION ALL -SELECT - pg_catalog.split_part(rolconfig, '=', 1) AS name, pg_catalog.replace(rolconfig, pg_catalog.split_part(rolconfig, '=', 1) || '=', '') AS value, datname AS database -FROM - (SELECT - d.datname, pg_catalog.unnest(c.setconfig) AS rolconfig - FROM - (SELECT * - FROM pg_catalog.pg_db_role_setting dr - WHERE - dr.setrole={{ rid|qtLiteral }}::OID AND dr.setdatabase!=0 - ) c - LEFT JOIN pg_catalog.pg_database d ON (d.oid = c.setdatabase) - ) a; diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/create.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/create.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/create.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/create.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/dependents.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/dependents.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/dependents.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/dependents.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/nodes.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/nodes.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/nodes.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/permission.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/permission.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/permission.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/permission.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/properties.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/properties.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/properties.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/reassign_own.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/reassign_own.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/reassign_own.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/reassign_own.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/sql.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/sql.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/sql.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/sql.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/update.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/update.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.4_plus/update.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/update.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/variables.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/variables.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/9.1_plus/variables.sql rename to web/pgadmin/browser/server_groups/servers/roles/templates/roles/sql/default/variables.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.msql deleted file mode 100644 index 7156049e1..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.msql +++ /dev/null @@ -1 +0,0 @@ -COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.sql deleted file mode 100644 index c2e3d46ca..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_description.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Role: "Role1_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH - LOGIN - SUPERUSER - INHERIT - CREATEDB - CREATEROLE - REPLICATION; - - -UPDATE pg_catalog.pg_authid SET rolcatupdate=false WHERE rolname = 'Role1_$%{}[]()&*^!@"''`\/#'; - -COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.msql deleted file mode 100644 index 0595fdb93..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.msql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER ROLE "Role1_$%{}[]()&*^!@""'`\/#" - RENAME TO "Role2_$%{}[]()&*^!@""'`\/#"; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.sql deleted file mode 100644 index 4ec6c0f98..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_name.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Role: "Role2_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH - LOGIN - SUPERUSER - INHERIT - CREATEDB - CREATEROLE - REPLICATION; - - -UPDATE pg_catalog.pg_authid SET rolcatupdate=false WHERE rolname = 'Role2_$%{}[]()&*^!@"''`\/#''; - -COMMENT ON ROLE "Role2_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.msql deleted file mode 100644 index bd025f963..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.msql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" - NOSUPERUSER - NOCREATEDB - NOREPLICATION - CONNECTION LIMIT 100 - - VALID UNTIL '2050-01-01T00:00:00+05:30' - PASSWORD 'xxxxxx'; - -ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres - SET application_name TO 'pg4'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.sql deleted file mode 100644 index 3d8db5d2c..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_login_role_options.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Role: "Role2_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH - LOGIN - NOSUPERUSER - INHERIT - NOCREATEDB - CREATEROLE - NOREPLICATION - CONNECTION LIMIT 100 - VALID UNTIL '2050-01-01 00:00:00+05:30'; - -ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres SET application_name TO 'pg4'; - -COMMENT ON ROLE "Role2_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.msql deleted file mode 100644 index 7156049e1..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.msql +++ /dev/null @@ -1 +0,0 @@ -COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.msql deleted file mode 100644 index 0595fdb93..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.msql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER ROLE "Role1_$%{}[]()&*^!@""'`\/#" - RENAME TO "Role2_$%{}[]()&*^!@""'`\/#"; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.msql deleted file mode 100644 index 429e0ac14..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.msql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" - SUPERUSER - CREATEDB - NOREPLICATION - CONNECTION LIMIT 100 - - VALID UNTIL '2050-01-01T00:00:00+05:30' - PASSWORD 'xxxxxx'; - -ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres - SET application_name TO 'pg4'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.sql deleted file mode 100644 index 5a0d12dfa..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_options.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Role: "Role2_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH - NOLOGIN - SUPERUSER - INHERIT - CREATEDB - NOCREATEROLE - NOREPLICATION - CONNECTION LIMIT 100 - VALID UNTIL '2050-01-01 00:00:00+05:30'; - -ALTER ROLE "Role2_$%{}[]()&*^!@""'`\/#" IN DATABASE postgres SET application_name TO 'pg4'; - -COMMENT ON ROLE "Role2_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.msql deleted file mode 100644 index f624a21d1..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.msql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH - LOGIN - SUPERUSER - CREATEDB - CREATEROLE - INHERIT - REPLICATION - CONNECTION LIMIT -1 - PASSWORD 'xxxxxx'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.sql deleted file mode 100644 index 478dec601..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_login_role.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Role: "Role1_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH - LOGIN - SUPERUSER - INHERIT - CREATEDB - CREATEROLE - REPLICATION; - - -UPDATE pg_authid SET rolcatupdate=false WHERE rolname = 'Role1_$%{}[]()&*^!@"''`\/#''; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.msql deleted file mode 100644 index a4ca80900..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.msql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH - NOLOGIN - NOSUPERUSER - NOCREATEDB - NOCREATEROLE - INHERIT - NOREPLICATION - CONNECTION LIMIT -1 - PASSWORD 'xxxxxx'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/test.json b/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/test.json deleted file mode 100644 index 17feb43ef..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/test.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "scenarios": [ - { - "type": "create", - "name": "Create Role", - "endpoint": "NODE-role.obj", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql", - "data": { - "rolname": "Role1_$%{}[]()&*^!@\"'`\\/#", - "rolcanlogin": false, - "rolpassword": null, - "rolconnlimit": -1, - "rolsuper": false, - "rolcreaterole": false, - "rolcreatedb": false, - "rolinherit": true, - "rolcatupdate": false, - "rolreplication": false, - "rolmembership": [], - "seclabels": [], - "variables": [] - }, - "expected_sql_file": "create_role.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "alter", - "name": "Alter Role description", - "endpoint": "NODE-role.obj_id", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql_id", - "data": { - "description": "This is detailed description" - }, - "expected_sql_file": "alter_role_description.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "alter", - "name": "Alter Role name", - "endpoint": "NODE-role.obj_id", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql_id", - "data": { - "rolname": "Role2_$%{}[]()&*^!@\"'`\\/#" - }, - "expected_sql_file": "alter_role_name.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "alter", - "name": "Alter Role options", - "endpoint": "NODE-role.obj_id", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql_id", - "data": { - "rolsuper": true, - "rolcreatedb": true, - "rolreplication": false, - "rolpassword": "abc123", - "rolconnlimit": 100, - "rolvaliduntil": "2050-01-01 00:00:00 +05:30", - "variables": { "added": [{"name":"application_name","value":"pg4","database":"postgres"}] } - }, - "expected_sql_file": "alter_role_options.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "delete", - "name": "Drop Role", - "endpoint": "NODE-role.obj_id", - "data": {} - }, - { - "type": "create", - "name": "Create Login Role", - "endpoint": "NODE-role.obj", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql", - "data": { - "rolname": "Role1_$%{}[]()&*^!@\"'`\\/#", - "rolcanlogin": true, - "rolpassword": null, - "rolconnlimit": -1, - "rolsuper": true, - "rolcreaterole": true, - "rolcreatedb": true, - "rolinherit": true, - "rolcatupdate": true, - "rolreplication": true, - "rolmembership": [], - "seclabels": [], - "variables": [] - }, - "expected_sql_file": "create_login_role.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "alter", - "name": "Alter Login Role description", - "endpoint": "NODE-role.obj_id", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql_id", - "data": { - "description": "This is detailed description" - }, - "expected_sql_file": "alter_login_role_description.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "alter", - "name": "Alter Login Role name", - "endpoint": "NODE-role.obj_id", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql_id", - "data": { - "rolname": "Role2_$%{}[]()&*^!@\"'`\\/#" - }, - "expected_sql_file": "alter_login_role_name.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "alter", - "name": "Alter Login Role options", - "endpoint": "NODE-role.obj_id", - "sql_endpoint": "NODE-role.sql_id", - "msql_endpoint": "NODE-role.msql_id", - "data": { - "rolsuper": false, - "rolcreatedb": false, - "rolreplication": false, - "rolpassword": "abc123", - "rolconnlimit": 100, - "rolvaliduntil": "2050-01-01 00:00:00 +05:30", - "variables": { "added": [{"name":"application_name","value":"pg4","database":"postgres"}] } - }, - "expected_sql_file": "alter_login_role_options.sql", - "expected_msql_file": "create_role.msql" - }, - { - "type": "delete", - "name": "Drop Login Role", - "endpoint": "NODE-role.obj_id", - "data": {} - } - ] -} diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.sql deleted file mode 100644 index c3998071f..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.sql +++ /dev/null @@ -1,12 +0,0 @@ --- Role: "Role1_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH - NOLOGIN - NOSUPERUSER - INHERIT - NOCREATEDB - NOCREATEROLE - NOREPLICATION; - -COMMENT ON ROLE "Role1_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.sql deleted file mode 100644 index 16fb44717..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.sql +++ /dev/null @@ -1,12 +0,0 @@ --- Role: "Role2_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role2_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role2_$%{}[]()&*^!@""'`\/#" WITH - NOLOGIN - NOSUPERUSER - INHERIT - NOCREATEDB - NOCREATEROLE - NOREPLICATION; - -COMMENT ON ROLE "Role2_$%{}[]()&*^!@""'`\/#" IS 'This is detailed description'; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.sql deleted file mode 100644 index fd191d4c8..000000000 --- a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.sql +++ /dev/null @@ -1,10 +0,0 @@ --- Role: "Role1_$%{}[]()&*^!@""'`\/#" --- DROP ROLE IF EXISTS "Role1_$%{}[]()&*^!@""'`\/#"; - -CREATE ROLE "Role1_$%{}[]()&*^!@""'`\/#" WITH - NOLOGIN - NOSUPERUSER - INHERIT - NOCREATEDB - NOCREATEROLE - NOREPLICATION; diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_description.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_name.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_name.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_name.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_options.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_options.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_options.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_login_role_options.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_login_role_options.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_description.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_description.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_description.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_description.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_description.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_description.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_name.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_name.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_name.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_name.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/alter_role_name.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_name.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options1.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options1.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options1.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options1.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options1.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options2.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options2.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options2.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options2.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options2.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options3.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options3.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options3.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options3.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options3.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options4.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options4.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options4.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/alter_role_options4.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/alter_role_options4.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/create_login_role.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/create_login_role.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/create_login_role.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_login_role.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/create_login_role.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.msql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/create_role.msql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/create_role.msql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/create_role.msql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.sql b/web/pgadmin/browser/server_groups/servers/roles/tests/default/create_role.sql similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.1_plus/create_role.sql rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/create_role.sql diff --git a/web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/test.json b/web/pgadmin/browser/server_groups/servers/roles/tests/default/test.json similarity index 100% rename from web/pgadmin/browser/server_groups/servers/roles/tests/9.4_plus/test.json rename to web/pgadmin/browser/server_groups/servers/roles/tests/default/test.json diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/nodes.sql deleted file mode 100644 index 637415ac6..000000000 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/nodes.sql +++ /dev/null @@ -1,9 +0,0 @@ -SELECT - ts.oid AS oid, spcname AS name, spcowner as owner -FROM - pg_catalog.pg_tablespace ts -{% if tsid %} -WHERE - ts.oid={{ tsid|qtLiteral }}::OID -{% endif %} -ORDER BY name; diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/properties.sql deleted file mode 100644 index 1c57e95cb..000000000 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/properties.sql +++ /dev/null @@ -1,16 +0,0 @@ -{### SQL to fetch tablespace object properties ###} -SELECT - ts.oid, spcname AS name, spcoptions, pg_catalog.pg_get_userbyid(spcowner) as spcuser, - pg_catalog.pg_tablespace_location(ts.oid) AS spclocation, - pg_catalog.array_to_string(spcacl::text[], ', ') as acl, - pg_catalog.shobj_description(oid, 'pg_tablespace') AS description, - (SELECT - pg_catalog.array_agg(provider || '=' || label) - FROM pg_catalog.pg_shseclabel sl1 - WHERE sl1.objoid=ts.oid) AS seclabels -FROM - pg_catalog.pg_tablespace ts -{% if tsid %} -WHERE ts.oid={{ tsid|qtLiteral }}::OID -{% endif %} -ORDER BY name diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/update.sql deleted file mode 100644 index 19cd3b00b..000000000 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.2_plus/update.sql +++ /dev/null @@ -1,80 +0,0 @@ -{### SQL to update tablespace object ###} -{% import 'macros/security.macros' as SECLABEL %} -{% import 'macros/variable.macros' as VARIABLE %} -{% import 'macros/privilege.macros' as PRIVILEGE %} -{% if data %} -{# ==== To update tablespace name ==== #} -{% if data.name and data.name != o_data.name %} -ALTER TABLESPACE {{ conn|qtIdent(o_data.name) }} - RENAME TO {{ conn|qtIdent(data.name) }}; - -{% endif %} -{# ==== To update tablespace user ==== #} -{% if data.spcuser and data.spcuser != o_data.spcuser %} -ALTER TABLESPACE {{ conn|qtIdent(data.name) }} - OWNER TO {{ conn|qtIdent(data.spcuser) }}; - -{% endif %} -{# ==== To update tablespace comments ==== #} -{% if data.description is defined and data.description != o_data.description %} -COMMENT ON TABLESPACE {{ conn|qtIdent(data.name) }} - IS {{ data.description|qtLiteral }}; - -{% endif %} -{# ==== To update tablespace variables ==== #} -{% if 'spcoptions' in data and data.spcoptions|length > 0 %} -{% set variables = data.spcoptions %} -{% if 'deleted' in variables and variables.deleted|length > 0 %} -{{ VARIABLE.UNSET(conn, 'TABLESPACE', data.name, variables.deleted) }} -{% endif %} -{% if 'added' in variables and variables.added|length > 0 %} -{{ VARIABLE.SET(conn, 'TABLESPACE', data.name, variables.added) }} -{% endif %} -{% if 'changed' in variables and variables.changed|length > 0 %} -{{ VARIABLE.SET(conn, 'TABLESPACE', data.name, variables.changed) }} -{% endif %} - -{% endif %} -{# ==== To update tablespace securitylabel ==== #} -{# The SQL generated below will change Security Label #} -{% if data.seclabels and data.seclabels|length > 0 %} -{% set seclabels = data.seclabels %} -{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} -{% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'TABLESPACE', data.name, r.provider) }} -{% endfor %} -{% endif %} -{% if 'added' in seclabels and seclabels.added|length > 0 %} -{% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'TABLESPACE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} -{% if 'changed' in seclabels and seclabels.changed|length > 0 %} -{% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'TABLESPACE', data.name, r.provider, r.label) }} -{% endfor %} -{% endif %} - -{% endif %} -{# ==== To update tablespace privileges ==== #} -{# Change the privileges #} -{% if data.spcacl %} -{% if 'deleted' in data.spcacl %} -{% for priv in data.spcacl.deleted %} -{{ PRIVILEGE.RESETALL(conn, 'TABLESPACE', priv.grantee, data.name) }} -{% endfor %} -{% endif %} -{% if 'changed' in data.spcacl %} -{% for priv in data.spcacl.changed %} -{{ PRIVILEGE.RESETALL(conn, 'TABLESPACE', priv.grantee, data.name) }} -{{ PRIVILEGE.APPLY(conn, 'TABLESPACE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} -{% if 'added' in data.spcacl %} -{% for priv in data.spcacl.added %} -{{ PRIVILEGE.APPLY(conn, 'TABLESPACE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }} -{% endfor %} -{% endif %} - -{% endif %} -{% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.6_plus/variables.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.6_plus/variables.sql deleted file mode 100644 index 72fd0bf07..000000000 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/9.6_plus/variables.sql +++ /dev/null @@ -1,4 +0,0 @@ -{### SQL to fetch tablespace object options ###} -SELECT name, vartype, min_val, max_val, enumvals -FROM pg_catalog.pg_settings -WHERE name IN ('seq_page_cost', 'random_page_cost', 'effective_io_concurrency'); diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/nodes.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/nodes.sql index b65390168..637415ac6 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/nodes.sql +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/nodes.sql @@ -1,5 +1,5 @@ SELECT - ts.oid, spcname AS name, spcowner as owner + ts.oid AS oid, spcname AS name, spcowner as owner FROM pg_catalog.pg_tablespace ts {% if tsid %} diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/properties.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/properties.sql index a876eaca0..1c57e95cb 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/properties.sql @@ -1,9 +1,13 @@ {### SQL to fetch tablespace object properties ###} SELECT - ts.oid, spcname AS name, spclocation, spcoptions, - pg_catalog.pg_get_userbyid(spcowner) as spcuser, + ts.oid, spcname AS name, spcoptions, pg_catalog.pg_get_userbyid(spcowner) as spcuser, + pg_catalog.pg_tablespace_location(ts.oid) AS spclocation, + pg_catalog.array_to_string(spcacl::text[], ', ') as acl, pg_catalog.shobj_description(oid, 'pg_tablespace') AS description, - pg_catalog.array_to_string(spcacl::text[], ', ') as acl + (SELECT + pg_catalog.array_agg(provider || '=' || label) + FROM pg_catalog.pg_shseclabel sl1 + WHERE sl1.objoid=ts.oid) AS seclabels FROM pg_catalog.pg_tablespace ts {% if tsid %} diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/update.sql index c4df42868..19cd3b00b 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/update.sql @@ -1,4 +1,5 @@ {### SQL to update tablespace object ###} +{% import 'macros/security.macros' as SECLABEL %} {% import 'macros/variable.macros' as VARIABLE %} {% import 'macros/privilege.macros' as PRIVILEGE %} {% if data %} @@ -15,7 +16,7 @@ ALTER TABLESPACE {{ conn|qtIdent(data.name) }} {% endif %} {# ==== To update tablespace comments ==== #} -{% if data.description is defined and data.description != o_data.description %} +{% if data.description is defined and data.description != o_data.description %} COMMENT ON TABLESPACE {{ conn|qtIdent(data.name) }} IS {{ data.description|qtLiteral }}; @@ -33,6 +34,27 @@ COMMENT ON TABLESPACE {{ conn|qtIdent(data.name) }} {{ VARIABLE.SET(conn, 'TABLESPACE', data.name, variables.changed) }} {% endif %} +{% endif %} +{# ==== To update tablespace securitylabel ==== #} +{# The SQL generated below will change Security Label #} +{% if data.seclabels and data.seclabels|length > 0 %} +{% set seclabels = data.seclabels %} +{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} +{% for r in seclabels.deleted %} +{{ SECLABEL.DROP(conn, 'TABLESPACE', data.name, r.provider) }} +{% endfor %} +{% endif %} +{% if 'added' in seclabels and seclabels.added|length > 0 %} +{% for r in seclabels.added %} +{{ SECLABEL.APPLY(conn, 'TABLESPACE', data.name, r.provider, r.label) }} +{% endfor %} +{% endif %} +{% if 'changed' in seclabels and seclabels.changed|length > 0 %} +{% for r in seclabels.changed %} +{{ SECLABEL.APPLY(conn, 'TABLESPACE', data.name, r.provider, r.label) }} +{% endfor %} +{% endif %} + {% endif %} {# ==== To update tablespace privileges ==== #} {# Change the privileges #} diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql index a7279d547..72fd0bf07 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql @@ -1,4 +1,4 @@ {### SQL to fetch tablespace object options ###} SELECT name, vartype, min_val, max_val, enumvals FROM pg_catalog.pg_settings -WHERE name IN ('seq_page_cost', 'random_page_cost'); +WHERE name IN ('seq_page_cost', 'random_page_cost', 'effective_io_concurrency'); diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/10_plus/stats.sql b/web/pgadmin/browser/server_groups/servers/templates/servers/sql/10_plus/stats.sql deleted file mode 100644 index b244ca72c..000000000 --- a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/10_plus/stats.sql +++ /dev/null @@ -1,51 +0,0 @@ -SELECT - pid AS "PID", - usename AS {{ conn|qtIdent(_('User')) }}, - datname AS {{ conn|qtIdent(_('Database')) }}, - backend_start AS {{ conn|qtIdent(_('Backend start')) }}, - CASE - WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN - client_hostname || ':' || client_port - WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN - client_addr::text || ':' || client_port - WHEN client_port = -1 THEN - 'local pipe' - ELSE - 'localhost:' || client_port - END AS {{ conn|qtIdent(_('Client')) }}, - application_name AS {{ conn|qtIdent(_('Application')) }}, - wait_event_type AS {{ conn|qtIdent(_('Wait event type')) }}, - wait_event AS {{ conn|qtIdent(_('Wait event name')) }}, - query AS {{ conn|qtIdent(_('Query')) }}, - query_start AS {{ conn|qtIdent(_('Query start')) }}, - xact_start AS {{ conn|qtIdent(_('Xact start')) }} -FROM - pg_catalog.pg_stat_activity sa -WHERE - (SELECT r.rolsuper OR r.oid = sa.usesysid FROM pg_catalog.pg_roles r WHERE r.rolname = current_user) -UNION -SELECT - pid AS "PID", - usename AS {{ conn|qtIdent(_('User')) }}, - '' AS {{ conn|qtIdent(_('Database')) }}, - backend_start AS {{ conn|qtIdent(_('Backend start')) }}, - CASE - WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN - client_hostname || ':' || client_port - WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN - client_addr::text || ':' || client_port - WHEN client_port = -1 THEN - 'local pipe' - ELSE - 'localhost:' || client_port - END AS {{ conn|qtIdent(_('Client')) }}, - {{ _('Streaming Replication')|qtLiteral }} AS {{ conn|qtIdent(_('Application')) }}, - null AS {{ conn|qtIdent(_('Wait event type')) }}, - null AS {{ conn|qtIdent(_('Wait event name')) }}, - state || ' [sync (state: ' || COALESCE(sync_state, '') || ', priority: ' || sync_priority::text || ')] (' || sent_lsn || ' sent, ' || write_lsn || ' written, ' || flush_lsn || ' flushed, ' || replay_lsn || ' applied)' AS {{ conn|qtIdent(_('Query')) }}, - null AS {{ conn|qtIdent(_('Query start')) }}, - null AS {{ conn|qtIdent(_('Xact start')) }} -FROM - pg_catalog.pg_stat_replication sa -WHERE - (SELECT r.rolsuper OR r.oid = sa.usesysid FROM pg_catalog.pg_roles r WHERE r.rolname = current_user) diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/9.2_plus/stats.sql b/web/pgadmin/browser/server_groups/servers/templates/servers/sql/9.2_plus/stats.sql deleted file mode 100644 index 36ccf1ec6..000000000 --- a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/9.2_plus/stats.sql +++ /dev/null @@ -1,49 +0,0 @@ -SELECT - pid AS "PID", - usename AS {{ conn|qtIdent(_('User')) }}, - datname AS {{ conn|qtIdent(_('Database')) }}, - backend_start AS {{ conn|qtIdent(_('Backend start')) }}, - CASE - WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN - client_hostname || ':' || client_port - WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN - client_addr::text || ':' || client_port - WHEN client_port = -1 THEN - 'local pipe' - ELSE - 'localhost:' || client_port - END AS {{ conn|qtIdent(_('Client')) }}, - application_name AS {{ conn|qtIdent(_('Application')) }}, - waiting AS {{ conn|qtIdent(_('Waiting?')) }}, - query AS {{ conn|qtIdent(_('Query')) }}, - query_start AS {{ conn|qtIdent(_('Query start')) }}, - xact_start AS {{ conn|qtIdent(_('Xact start')) }} -FROM - pg_catalog.pg_stat_activity sa -WHERE - (SELECT r.rolsuper OR r.oid = sa.usesysid FROM pg_catalog.pg_roles r WHERE r.rolname = current_user) -UNION -SELECT - pid AS "PID", - usename AS {{ conn|qtIdent(_('User')) }}, - '' AS {{ conn|qtIdent(_('Database')) }}, - backend_start AS {{ conn|qtIdent(_('Backend start')) }}, - CASE - WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN - client_hostname || ':' || client_port - WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN - client_addr::text || ':' || client_port - WHEN client_port = -1 THEN - 'local pipe' - ELSE - 'localhost:' || client_port - END AS {{ conn|qtIdent(_('Client')) }}, - {{ _('Streaming Replication')|qtLiteral }} AS {{ conn|qtIdent(_('Application')) }}, - null AS {{ conn|qtIdent(_('Waiting?')) }}, - state || ' [sync (state: ' || COALESCE(sync_state, '') || ', priority: ' || sync_priority::text || ')] (' || sent_location || ' sent, ' || write_location || ' written, ' || flush_location || ' flushed, ' || replay_location || ' applied)' AS {{ conn|qtIdent(_('Query')) }}, - null AS {{ conn|qtIdent(_('Query start')) }}, - null AS {{ conn|qtIdent(_('Xact start')) }} -FROM - pg_catalog.pg_stat_replication sa -WHERE - (SELECT r.rolsuper OR r.oid = sa.usesysid FROM pg_catalog.pg_roles r WHERE r.rolname = current_user) diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/9.6_plus/stats.sql b/web/pgadmin/browser/server_groups/servers/templates/servers/sql/9.6_plus/stats.sql deleted file mode 100644 index 8dc338fc3..000000000 --- a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/9.6_plus/stats.sql +++ /dev/null @@ -1,51 +0,0 @@ -SELECT - pid AS "PID", - usename AS {{ conn|qtIdent(_('User')) }}, - datname AS {{ conn|qtIdent(_('Database')) }}, - backend_start AS {{ conn|qtIdent(_('Backend start')) }}, - CASE - WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN - client_hostname || ':' || client_port - WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN - client_addr::text || ':' || client_port - WHEN client_port = -1 THEN - 'local pipe' - ELSE - 'localhost:' || client_port - END AS {{ conn|qtIdent(_('Client')) }}, - application_name AS {{ conn|qtIdent(_('Application')) }}, - wait_event_type AS {{ conn|qtIdent(_('Wait event type')) }}, - wait_event AS {{ conn|qtIdent(_('Wait event name')) }}, - query AS {{ conn|qtIdent(_('Query')) }}, - query_start AS {{ conn|qtIdent(_('Query start')) }}, - xact_start AS {{ conn|qtIdent(_('Xact start')) }} -FROM - pg_catalog.pg_stat_activity sa -WHERE - (SELECT r.rolsuper OR r.oid = sa.usesysid FROM pg_catalog.pg_roles r WHERE r.rolname = current_user) -UNION -SELECT - pid AS "PID", - usename AS {{ conn|qtIdent(_('User')) }}, - '' AS {{ conn|qtIdent(_('Database')) }}, - backend_start AS {{ conn|qtIdent(_('Backend start')) }}, - CASE - WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN - client_hostname || ':' || client_port - WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN - client_addr::text || ':' || client_port - WHEN client_port = -1 THEN - 'local pipe' - ELSE - 'localhost:' || client_port - END AS {{ conn|qtIdent(_('Client')) }}, - {{ _('Streaming Replication')|qtLiteral }} AS {{ conn|qtIdent(_('Application')) }}, - null AS {{ conn|qtIdent(_('Wait event type')) }}, - null AS {{ conn|qtIdent(_('Wait event name')) }}, - state || ' [sync (state: ' || COALESCE(sync_state, '') || ', priority: ' || sync_priority::text || ')] (' || sent_location || ' sent, ' || write_location || ' written, ' || flush_location || ' flushed, ' || replay_location || ' applied)' AS {{ conn|qtIdent(_('Query')) }}, - null AS {{ conn|qtIdent(_('Query start')) }}, - null AS {{ conn|qtIdent(_('Xact start')) }} -FROM - pg_catalog.pg_stat_replication sa -WHERE - (SELECT r.rolsuper OR r.oid = sa.usesysid FROM pg_catalog.pg_roles r WHERE r.rolname = current_user) diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/default/stats.sql b/web/pgadmin/browser/server_groups/servers/templates/servers/sql/default/stats.sql index 464702a25..b244ca72c 100644 --- a/web/pgadmin/browser/server_groups/servers/templates/servers/sql/default/stats.sql +++ b/web/pgadmin/browser/server_groups/servers/templates/servers/sql/default/stats.sql @@ -1,9 +1,11 @@ SELECT - procpid AS {{ conn|qtIdent('PID') }}, + pid AS "PID", usename AS {{ conn|qtIdent(_('User')) }}, datname AS {{ conn|qtIdent(_('Database')) }}, backend_start AS {{ conn|qtIdent(_('Backend start')) }}, CASE + WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN + client_hostname || ':' || client_port WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN client_addr::text || ':' || client_port WHEN client_port = -1 THEN @@ -12,8 +14,9 @@ SELECT 'localhost:' || client_port END AS {{ conn|qtIdent(_('Client')) }}, application_name AS {{ conn|qtIdent(_('Application')) }}, - waiting AS {{ conn|qtIdent(_('Waiting?')) }}, - current_query AS {{ conn|qtIdent(_('Query')) }}, + wait_event_type AS {{ conn|qtIdent(_('Wait event type')) }}, + wait_event AS {{ conn|qtIdent(_('Wait event name')) }}, + query AS {{ conn|qtIdent(_('Query')) }}, query_start AS {{ conn|qtIdent(_('Query start')) }}, xact_start AS {{ conn|qtIdent(_('Xact start')) }} FROM @@ -22,11 +25,13 @@ WHERE (SELECT r.rolsuper OR r.oid = sa.usesysid FROM pg_catalog.pg_roles r WHERE r.rolname = current_user) UNION SELECT - procpid AS "PID", + pid AS "PID", usename AS {{ conn|qtIdent(_('User')) }}, '' AS {{ conn|qtIdent(_('Database')) }}, backend_start AS {{ conn|qtIdent(_('Backend start')) }}, CASE + WHEN client_hostname IS NOT NULL AND client_hostname != '' THEN + client_hostname || ':' || client_port WHEN client_addr IS NOT NULL AND client_addr::text != '' THEN client_addr::text || ':' || client_port WHEN client_port = -1 THEN @@ -35,8 +40,9 @@ SELECT 'localhost:' || client_port END AS {{ conn|qtIdent(_('Client')) }}, {{ _('Streaming Replication')|qtLiteral }} AS {{ conn|qtIdent(_('Application')) }}, - null AS {{ conn|qtIdent(_('Waiting?')) }}, - state || ' [sync (state: ' || COALESCE(sync_state, '') || ', priority: ' || sync_priority::text || ')] (' || sent_location || ' sent, ' || write_location || ' written, ' || flush_location || ' flushed, ' || replay_location || ' applied)' AS {{ conn|qtIdent(_('Query')) }}, + null AS {{ conn|qtIdent(_('Wait event type')) }}, + null AS {{ conn|qtIdent(_('Wait event name')) }}, + state || ' [sync (state: ' || COALESCE(sync_state, '') || ', priority: ' || sync_priority::text || ')] (' || sent_lsn || ' sent, ' || write_lsn || ' written, ' || flush_lsn || ' flushed, ' || replay_lsn || ' applied)' AS {{ conn|qtIdent(_('Query')) }}, null AS {{ conn|qtIdent(_('Query start')) }}, null AS {{ conn|qtIdent(_('Xact start')) }} FROM diff --git a/web/pgadmin/dashboard/templates/dashboard/sql/10_plus/activity.sql b/web/pgadmin/dashboard/templates/dashboard/sql/10_plus/activity.sql deleted file mode 100644 index d02d071fc..000000000 --- a/web/pgadmin/dashboard/templates/dashboard/sql/10_plus/activity.sql +++ /dev/null @@ -1,22 +0,0 @@ -/*pga4dash*/ -SELECT - pid, - datname, - usename, - application_name, - client_addr, - pg_catalog.to_char(backend_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS backend_start, - state, - wait_event_type || ': ' || wait_event AS wait_event, - pg_catalog.pg_blocking_pids(pid) AS blocking_pids, - query, - pg_catalog.to_char(state_change, 'YYYY-MM-DD HH24:MI:SS TZ') AS state_change, - pg_catalog.to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start, - pg_catalog.to_char(xact_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS xact_start, - backend_type, - CASE WHEN state = 'active' THEN ROUND((extract(epoch from now() - query_start) / 60)::numeric, 2) ELSE 0 END AS active_since -FROM - pg_catalog.pg_stat_activity -{% if did %}WHERE - datname = (SELECT datname FROM pg_catalog.pg_database WHERE oid = {{ did }}){% endif %} -ORDER BY pid diff --git a/web/pgadmin/dashboard/templates/dashboard/sql/9.6_plus/activity.sql b/web/pgadmin/dashboard/templates/dashboard/sql/9.6_plus/activity.sql deleted file mode 100644 index 67cb4588f..000000000 --- a/web/pgadmin/dashboard/templates/dashboard/sql/9.6_plus/activity.sql +++ /dev/null @@ -1,21 +0,0 @@ -/*pga4dash*/ -SELECT - pid, - datname, - usename, - application_name, - client_addr, - pg_catalog.to_char(backend_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS backend_start, - state, - wait_event_type || ': ' || wait_event AS wait_event, - pg_catalog.pg_blocking_pids(pid) AS blocking_pids, - query, - pg_catalog.to_char(state_change, 'YYYY-MM-DD HH24:MI:SS TZ') AS state_change, - pg_catalog.to_char(xact_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS xact_start, - pg_catalog.to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start, - CASE WHEN state = 'active' THEN ROUND((extract(epoch from now() - query_start) / 60)::numeric, 2) ELSE 0 END AS active_since -FROM - pg_catalog.pg_stat_activity -{% if did %}WHERE - datname = (SELECT datname FROM pg_catalog.pg_database WHERE oid = {{ did }}){% endif %} -ORDER BY pid diff --git a/web/pgadmin/dashboard/templates/dashboard/sql/default/activity.sql b/web/pgadmin/dashboard/templates/dashboard/sql/default/activity.sql index 3e6cf81b0..d02d071fc 100644 --- a/web/pgadmin/dashboard/templates/dashboard/sql/default/activity.sql +++ b/web/pgadmin/dashboard/templates/dashboard/sql/default/activity.sql @@ -7,11 +7,13 @@ SELECT client_addr, pg_catalog.to_char(backend_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS backend_start, state, - CASE WHEN waiting THEN '{{ _('yes') }}' ELSE '{{ _('no') }}' END AS waiting, + wait_event_type || ': ' || wait_event AS wait_event, + pg_catalog.pg_blocking_pids(pid) AS blocking_pids, query, pg_catalog.to_char(state_change, 'YYYY-MM-DD HH24:MI:SS TZ') AS state_change, - pg_catalog.to_char(xact_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS xact_start, pg_catalog.to_char(query_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS query_start, + pg_catalog.to_char(xact_start, 'YYYY-MM-DD HH24:MI:SS TZ') AS xact_start, + backend_type, CASE WHEN state = 'active' THEN ROUND((extract(epoch from now() - query_start) / 60)::numeric, 2) ELSE 0 END AS active_since FROM pg_catalog.pg_stat_activity