mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-18 17:04:53 -05:00
Rebase the version-specific SQL templates to target PostgreSQL 14 (#10054)
The base (default) SQL templates previously targeted PostgreSQL < 12. Re-base them so the default target is 14 - the oldest supported server version - by collapsing every version bucket <= 14 (11_plus, 12_plus, 13_plus, 14_plus and the old default) into a single `default`, keeping per file the content a v14 server resolves today. Buckets for newer versions (15_plus, 16_plus, 17_plus, 18_plus) are retained as overrides. The transformation is behaviour-preserving for every server version >= 14: template (and test-fixture) resolution is byte-identical before and after for all supported versions, verified programmatically across every bucket container and confirmed by the resql, ERD and Schema Diff suites against PostgreSQL 18. Also drop PostgreSQL/EDB Advanced Server 13 from the 9.16 supported-server list and repoint the sqleditor explain_plan tests (which referenced the removed 12_plus/13_plus buckets) at the new default template. Closes #10050
This commit is contained in:
@@ -14,9 +14,9 @@ This release contains a number of bug fixes and new features since the release o
|
||||
|
||||
Supported Database Servers
|
||||
**************************
|
||||
**PostgreSQL**: 13, 14, 15, 16, 17 and 18
|
||||
**PostgreSQL**: 14, 15, 16, 17 and 18
|
||||
|
||||
**EDB Advanced Server**: 13, 14, 15, 16, 17 and 18
|
||||
**EDB Advanced Server**: 14, 15, 16, 17 and 18
|
||||
|
||||
Bundled PostgreSQL Utilities
|
||||
****************************
|
||||
@@ -36,6 +36,7 @@ Housekeeping
|
||||
| `Issue #9981 <https://github.com/pgadmin-org/pgadmin4/issues/9981>`_ - Clarify the SSH tunnel "Prompt for identity file password?" switch label and help text to indicate it applies only to identity-file authentication.
|
||||
| `Issue #10018 <https://github.com/pgadmin-org/pgadmin4/issues/10018>`_ - Remove the EDB BigAnimal cloud deployment support.
|
||||
| `Issue #10049 <https://github.com/pgadmin-org/pgadmin4/issues/10049>`_ - Bump vulnerable transitive dependencies (tar, flatted) to clear security advisories.
|
||||
| `Issue #10050 <https://github.com/pgadmin-org/pgadmin4/issues/10050>`_ - Rebase the version-specific SQL templates so the default targets PostgreSQL 14, the oldest supported server version, dropping the obsolete sub-14 template buckets.
|
||||
| `Issue #10063 <https://github.com/pgadmin-org/pgadmin4/issues/10063>`_ - Strip the foreign-architecture slice from the macOS bundle so single-arch builds no longer ship the universal2 Python framework's unused arm64/x86_64 code.
|
||||
|
||||
Bug fixes
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{### Create PUBLICATION ###}
|
||||
CREATE PUBLICATION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.all_table %}
|
||||
FOR ALL TABLES
|
||||
{% elif data.pubtable %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %}
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}');
|
||||
{% endif %}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
SELECT c.oid AS oid, c.pubname AS name,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
|
||||
puballtables AS all_table,
|
||||
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
|
||||
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
|
||||
{% if pbid %}
|
||||
WHERE c.oid = {{ pbid }}
|
||||
{% endif %}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{% if data.publish_via_partition_root%}
|
||||
{% set add_comma_after_truncate = 'truncate' %}
|
||||
{% endif %}
|
||||
{### Create PUBLICATION ###}
|
||||
CREATE PUBLICATION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.all_table %}
|
||||
FOR ALL TABLES
|
||||
{% elif data.pubtable %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %}
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
{% endif %}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
SELECT c.oid AS oid, c.pubname AS name,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
|
||||
puballtables AS all_table,
|
||||
pubviaroot AS publish_via_partition_root,
|
||||
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
|
||||
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
|
||||
{% if pbid %}
|
||||
WHERE c.oid = {{ pbid }}
|
||||
{% endif %}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{### Alter publication owner ###}
|
||||
{% if data.pubowner %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.pubowner) }};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication event ###}
|
||||
{% if (data.evnt_insert is defined and data.evnt_insert != o_data.evnt_insert) or (data.evnt_update is defined and data.evnt_update != o_data.evnt_update) or (data.evnt_delete is defined and data.evnt_delete != o_data.evnt_delete) or (data.evnt_truncate is defined and data.evnt_truncate != o_data.evnt_truncate) %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}');
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication partition root ###}
|
||||
{% if data.publish_via_partition_root is defined and data.publish_via_partition_root != o_data.publish_via_partition_root%}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
|
||||
{% endif %}
|
||||
{### Alter drop publication table ###}
|
||||
{% if drop_table %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
DROP TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in drop_table_data %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication table ###}
|
||||
{% if add_table %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
ADD TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in add_table_data %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication name ###}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
+9
-2
@@ -1,16 +1,23 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{% if data.publish_via_partition_root%}
|
||||
{% set add_comma_after_truncate = 'truncate' %}
|
||||
{% endif %}
|
||||
{### Create PUBLICATION ###}
|
||||
CREATE PUBLICATION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.all_table %}
|
||||
FOR ALL TABLES
|
||||
{% elif data.pubtable %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{pub_table}}{% endfor %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %}
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% endif %}');
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
{% endif %}
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
SELECT c.oid AS oid, c.pubname AS name,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
|
||||
puballtables AS all_table,
|
||||
pubviaroot AS publish_via_partition_root,
|
||||
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
|
||||
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
|
||||
{% if pbid %}
|
||||
where c.oid = {{ pbid }}
|
||||
WHERE c.oid = {{ pbid }}
|
||||
{% endif %}
|
||||
|
||||
+6
@@ -18,6 +18,12 @@ ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}');
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication partition root ###}
|
||||
{% if data.publish_via_partition_root is defined and data.publish_via_partition_root != o_data.publish_via_partition_root%}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
|
||||
{% endif %}
|
||||
{### Alter drop publication table ###}
|
||||
{% if drop_table %}
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{### Create PUBLICATION ###}
|
||||
CREATE PUBLICATION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.all_table %}
|
||||
FOR ALL TABLES
|
||||
{% elif data.pubtable %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %}
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}');
|
||||
{% endif %}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
SELECT c.oid AS oid, c.pubname AS name,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
|
||||
puballtables AS all_table,
|
||||
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
|
||||
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
|
||||
{% if pbid %}
|
||||
WHERE c.oid = {{ pbid }}
|
||||
{% endif %}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{% if data.publish_via_partition_root%}
|
||||
{% set add_comma_after_truncate = 'truncate' %}
|
||||
{% endif %}
|
||||
{### Create PUBLICATION ###}
|
||||
CREATE PUBLICATION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.all_table %}
|
||||
FOR ALL TABLES
|
||||
{% elif data.pubtable %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %}
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
{% endif %}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
SELECT c.oid AS oid, c.pubname AS name,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
|
||||
puballtables AS all_table,
|
||||
pubviaroot AS publish_via_partition_root,
|
||||
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
|
||||
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
|
||||
{% if pbid %}
|
||||
WHERE c.oid = {{ pbid }}
|
||||
{% endif %}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{### Alter publication owner ###}
|
||||
{% if data.pubowner %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.pubowner) }};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication event ###}
|
||||
{% if (data.evnt_insert is defined and data.evnt_insert != o_data.evnt_insert) or (data.evnt_update is defined and data.evnt_update != o_data.evnt_update) or (data.evnt_delete is defined and data.evnt_delete != o_data.evnt_delete) or (data.evnt_truncate is defined and data.evnt_truncate != o_data.evnt_truncate) %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}');
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication partition root ###}
|
||||
{% if data.publish_via_partition_root is defined and data.publish_via_partition_root != o_data.publish_via_partition_root%}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
|
||||
{% endif %}
|
||||
{### Alter drop publication table ###}
|
||||
{% if drop_table %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
DROP TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in drop_table_data %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication table ###}
|
||||
{% if add_table %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
ADD TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in add_table_data %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication name ###}
|
||||
{% if data.name != o_data.name %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
+9
-2
@@ -1,16 +1,23 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_truncate %}
|
||||
{% set add_comma_after_delete = 'delete' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
{% if data.publish_via_partition_root%}
|
||||
{% set add_comma_after_truncate = 'truncate' %}
|
||||
{% endif %}
|
||||
{### Create PUBLICATION ###}
|
||||
CREATE PUBLICATION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.all_table %}
|
||||
FOR ALL TABLES
|
||||
{% elif data.pubtable %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{pub_table}}{% endfor %}
|
||||
FOR TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{ pub_table }}{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% if data.evnt_insert or data.evnt_update or data.evnt_delete or data.evnt_truncate %}
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% endif %}');
|
||||
WITH (publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}', publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
{% endif %}
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
SELECT c.oid AS oid, c.pubname AS name,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete, pubtruncate AS evnt_truncate,
|
||||
puballtables AS all_table,
|
||||
pubviaroot AS publish_via_partition_root,
|
||||
pga.rolname AS pubowner FROM pg_catalog.pg_publication c
|
||||
JOIN pg_catalog.pg_roles pga ON c.pubowner= pga.oid
|
||||
{% if pbid %}
|
||||
where c.oid = {{ pbid }}
|
||||
WHERE c.oid = {{ pbid }}
|
||||
{% endif %}
|
||||
|
||||
+6
@@ -18,6 +18,12 @@ ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish = '{% if data.evnt_insert %}insert{% if add_comma_after_insert == 'insert' %}, {% endif %}{% endif %}{% if data.evnt_update %}update{% if add_comma_after_update == 'update' %}, {% endif %}{% endif %}{% if data.evnt_delete %}delete{% if add_comma_after_delete == 'delete' %}, {% endif %}{% endif %}{% if data.evnt_truncate %}truncate{% endif %}');
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication partition root ###}
|
||||
{% if data.publish_via_partition_root is defined and data.publish_via_partition_root != o_data.publish_via_partition_root%}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }} SET
|
||||
(publish_via_partition_root = {{ data.publish_via_partition_root|lower }});
|
||||
|
||||
{% endif %}
|
||||
{### Alter drop publication table ###}
|
||||
{% if drop_table %}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
-- Publication: alterd_publication
|
||||
|
||||
-- DROP PUBLICATION IF EXISTS alterd_publication;
|
||||
|
||||
CREATE PUBLICATION alterd_publication
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update', publish_via_partition_root = false);
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
-- Publication: test_publication_create
|
||||
|
||||
-- DROP PUBLICATION IF EXISTS test_publication_create;
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication, public.test_table_publication_2
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
ALTER PUBLICATION test_publication_create
|
||||
ADD TABLE public.test_table_publication_2;
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
-- Publication: test_publication_create
|
||||
|
||||
-- DROP PUBLICATION IF EXISTS test_publication_create;
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication_2
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
ALTER PUBLICATION test_publication_create
|
||||
DROP TABLE public.test_table_publication;
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
-- Publication: alterd_publication
|
||||
|
||||
-- DROP PUBLICATION IF EXISTS alterd_publication;
|
||||
|
||||
CREATE PUBLICATION alterd_publication
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update, delete', publish_via_partition_root = false);
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
ALTER PUBLICATION alterd_publication SET
|
||||
(publish = 'insert, update, delete');
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
ALTER PUBLICATION test_publication_create
|
||||
RENAME TO alterd_publication;
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
-- Publication: test_publication_create
|
||||
|
||||
-- DROP PUBLICATION IF EXISTS test_publication_create;
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update', publish_via_partition_root = false);
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
-- Publication: test_publication_create
|
||||
|
||||
-- DROP PUBLICATION IF EXISTS test_publication_create;
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update', publish_via_partition_root = false);
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
-- Publication: test_publication_with_update
|
||||
|
||||
-- DROP PUBLICATION test_publication_with_update;
|
||||
|
||||
CREATE PUBLICATION test_publication_with_update
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'update', publish_via_partition_root = false);
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
CREATE PUBLICATION test_publication_with_update
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'update', publish_via_partition_root = false);
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Table For publication",
|
||||
"endpoint": "NODE-table.obj",
|
||||
"sql_endpoint": "NODE-table.sql_id",
|
||||
"data": {
|
||||
"name": "test_table_publication",
|
||||
"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 Second Table For Publication",
|
||||
"endpoint": "NODE-table.obj",
|
||||
"sql_endpoint": "NODE-table.sql_id",
|
||||
"data": {
|
||||
"name": "test_table_publication_2",
|
||||
"columns": [
|
||||
{
|
||||
"name": "dept_id",
|
||||
"cltype": "integer",
|
||||
"is_primary_key": true
|
||||
},
|
||||
{
|
||||
"name": "dept_name",
|
||||
"cltype": "text"
|
||||
}
|
||||
],
|
||||
"is_partitioned": false,
|
||||
"schema": "public",
|
||||
"spcname": "pg_default"
|
||||
},
|
||||
"store_object_id": true
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Publication",
|
||||
"endpoint": "NODE-publication.obj",
|
||||
"sql_endpoint": "NODE-publication.sql_id",
|
||||
"msql_endpoint": "NODE-publication.msql",
|
||||
"data": {
|
||||
"name": "test_publication_create",
|
||||
"evnt_insert": true,
|
||||
"evnt_update": true,
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"pubowner": "<OWNER>",
|
||||
"publish_via_partition_root": false,
|
||||
"all_table": true,
|
||||
"pubtable": ""
|
||||
},
|
||||
"expected_sql_file": "create_publication.sql",
|
||||
"expected_msql_file": "create_publication_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Publication name",
|
||||
"endpoint": "NODE-publication.obj_id",
|
||||
"sql_endpoint": "NODE-publication.sql_id",
|
||||
"msql_endpoint": "NODE-publication.msql_id",
|
||||
"data": {
|
||||
"name": "alterd_publication"
|
||||
},
|
||||
"expected_sql_file": "alter_publication.sql",
|
||||
"expected_msql_file": "alter_publication_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Publication event",
|
||||
"endpoint": "NODE-publication.obj_id",
|
||||
"sql_endpoint": "NODE-publication.sql_id",
|
||||
"msql_endpoint": "NODE-publication.msql_id",
|
||||
"data": {
|
||||
"evnt_delete": true
|
||||
},
|
||||
"expected_sql_file": "alter_publication_event.sql",
|
||||
"expected_msql_file": "alter_publication_event_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop publication",
|
||||
"endpoint": "NODE-publication.delete_id",
|
||||
"data": {
|
||||
"name": "alterd_publication"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Publication for few tables",
|
||||
"endpoint": "NODE-publication.obj",
|
||||
"sql_endpoint": "NODE-publication.sql_id",
|
||||
"msql_endpoint": "NODE-publication.msql",
|
||||
"data": {
|
||||
"name": "test_publication_create",
|
||||
"evnt_insert": true,
|
||||
"evnt_update": true,
|
||||
"evnt_delete": true,
|
||||
"evnt_truncate": true,
|
||||
"pubowner": "<OWNER>",
|
||||
"publish_via_partition_root": false,
|
||||
"all_table": false,
|
||||
"only_table": false,
|
||||
"pubtable": [
|
||||
"public.test_table_publication"
|
||||
]
|
||||
},
|
||||
"expected_sql_file": "create_publication_few_tables.sql",
|
||||
"expected_msql_file": "create_publication_few_tables_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Publication for few tables via adding new tables",
|
||||
"endpoint": "NODE-publication.obj_id",
|
||||
"sql_endpoint": "NODE-publication.sql_id",
|
||||
"msql_endpoint": "NODE-publication.msql_id",
|
||||
"data": {
|
||||
"pubtable": [
|
||||
"public.test_table_publication",
|
||||
"public.test_table_publication_2"
|
||||
]
|
||||
},
|
||||
"expected_sql_file": "alter_publication_add_tables.sql",
|
||||
"expected_msql_file": "alter_publication_add_tables_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter Publication for few tables via deleting tables",
|
||||
"endpoint": "NODE-publication.obj_id",
|
||||
"sql_endpoint": "NODE-publication.sql_id",
|
||||
"msql_endpoint": "NODE-publication.msql_id",
|
||||
"data": {
|
||||
"pubtable": [
|
||||
"public.test_table_publication_2"
|
||||
]
|
||||
},
|
||||
"expected_sql_file": "alter_publication_drop_tables.sql",
|
||||
"expected_msql_file": "alter_publication_drop_tables_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop publication for few tables",
|
||||
"endpoint": "NODE-publication.delete_id",
|
||||
"data": {
|
||||
"name": "test_publication_create"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
CREATE PUBLICATION alterd_publication
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update');
|
||||
WITH (publish = 'insert, update', publish_via_partition_root = false);
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication, public.test_table_publication_2
|
||||
WITH (publish = 'insert, update, delete, truncate');
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication_2
|
||||
WITH (publish = 'insert, update, delete, truncate');
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
CREATE PUBLICATION alterd_publication
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update, delete');
|
||||
WITH (publish = 'insert, update, delete', publish_via_partition_root = false);
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update');
|
||||
WITH (publish = 'insert, update', publish_via_partition_root = false);
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication
|
||||
WITH (publish = 'insert, update, delete, truncate');
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR TABLE public.test_table_publication
|
||||
WITH (publish = 'insert, update, delete, truncate');
|
||||
WITH (publish = 'insert, update, delete, truncate', publish_via_partition_root = false);
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
CREATE PUBLICATION test_publication_create
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'insert, update');
|
||||
WITH (publish = 'insert, update', publish_via_partition_root = false);
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
|
||||
CREATE PUBLICATION test_publication_with_update
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'update');
|
||||
WITH (publish = 'update', publish_via_partition_root = false);
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
CREATE PUBLICATION test_publication_with_update
|
||||
FOR ALL TABLES
|
||||
WITH (publish = 'update');
|
||||
WITH (publish = 'update', publish_via_partition_root = false);
|
||||
|
||||
+2
@@ -65,6 +65,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"pubowner": "<OWNER>",
|
||||
"publish_via_partition_root": false,
|
||||
"all_table": true,
|
||||
"pubtable": ""
|
||||
},
|
||||
@@ -116,6 +117,7 @@
|
||||
"evnt_delete": true,
|
||||
"evnt_truncate": true,
|
||||
"pubowner": "<OWNER>",
|
||||
"publish_via_partition_root": false,
|
||||
"all_table": false,
|
||||
"only_table": false,
|
||||
"pubtable": [
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
{% if data %}
|
||||
CREATE AGGREGATE {{conn|qtIdent(data.schema, data.name)}}({% if data.input_types %}{{data.input_types}}{% endif %}) (
|
||||
SFUNC = {{data.state_func}},
|
||||
STYPE = {{data.state_type}} {% if data.state_data_size %},
|
||||
SSPACE = {{data.state_data_size}}{% endif %}{% if data.final_func %},
|
||||
FINALFUNC = {{data.final_func}}{% endif %}{% if data.final_extra_param %},
|
||||
FINALFUNC_EXTRA{% endif %}{% if data.final_func_modify %},
|
||||
FINALFUNC_MODIFY = {{data.final_func_modify}}{% endif %}{% if data.combine_func %},
|
||||
COMBINEFUNC = {{data.combine_func}}{% endif %}{% if data.serialization_func %},
|
||||
SERIALFUNC = {{data.serialization_func}}{% endif %}{% if data.deserialization_func %},
|
||||
DESERIALFUNC = {{data.deserialization_func}}{% endif %}{% if data.initial_val %},
|
||||
INITCOND = '{{data.initial_val}}'{% endif %}{% if data.moving_state_func %},
|
||||
MSFUNC = {{data.moving_state_func}}{% endif %}{% if data.moving_inverse_func %},
|
||||
MINVFUNC = {{data.moving_inverse_func}}{% endif %}{% if data.moving_state_type %},
|
||||
MSTYPE = {{data.moving_state_type}}{% endif %}{% if data.moving_state_data_size %},
|
||||
MSSPACE = {{data.moving_state_data_size}}{% endif %}{% if data.moving_final_func %},
|
||||
MFINALFUNC = {{data.moving_final_func}}{% endif %}{% if data.moving_final_extra_param %},
|
||||
MFINALFUNC_EXTRA{% endif %}{% if data.moving_final_func_modify %},
|
||||
MFINALFUNC_MODIFY = {{data.moving_final_func_modify}}{% endif %}{% if data.moving_initial_val %},
|
||||
MINITCOND = '{{data.moving_initial_val}}'{% endif %}{% if data.sort_oper %},
|
||||
SORTOP = {{data.sort_oper}}{% endif %}
|
||||
|
||||
);
|
||||
{% endif %}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
SELECT aggfnoid::oid as oid, proname as name, ns.nspname as schema,
|
||||
pg_catalog.pg_get_userbyid(proowner) as owner,
|
||||
COALESCE(pg_catalog.pg_get_function_arguments(aggfnoid::oid), '') as input_types, proacl,
|
||||
CASE WHEN ag.aggkind = 'n' THEN 'normal'
|
||||
WHEN ag.aggkind = 'o' THEN 'ordered-set'
|
||||
WHEN ag.aggkind = 'h' THEN 'hypothetical-set'
|
||||
ELSE 'unknown' END as kind,
|
||||
CASE WHEN aggtransfn = '-'::regproc THEN null ELSE aggtransfn END as state_func,
|
||||
CASE WHEN aggfinalfn = '-'::regproc THEN null ELSE aggfinalfn END as final_func,
|
||||
CASE WHEN aggcombinefn = '-'::regproc THEN null ELSE aggcombinefn END as combine_func,
|
||||
CASE WHEN aggserialfn = '-'::regproc THEN null ELSE aggserialfn END as serialization_func,
|
||||
CASE WHEN aggdeserialfn = '-'::regproc THEN null ELSE aggdeserialfn END as deserialization_func,
|
||||
CASE WHEN aggmtransfn = '-'::regproc THEN null ELSE aggmtransfn END as moving_state_func,
|
||||
CASE WHEN aggmfinalfn = '-'::regproc THEN null ELSE aggmfinalfn END as moving_final_func,
|
||||
CASE WHEN aggminvtransfn = '-'::regproc THEN null ELSE aggminvtransfn END as moving_inverse_func,
|
||||
CASE WHEN ag.aggfinalmodify = 'r' THEN 'READ_ONLY'
|
||||
WHEN ag.aggfinalmodify = 's' THEN 'SHAREABLE'
|
||||
WHEN ag.aggfinalmodify = 'w' THEN 'READ_WRITE'
|
||||
ELSE 'unknown' END as final_func_modify,
|
||||
CASE WHEN ag.aggmfinalmodify = 'r' THEN 'READ_ONLY'
|
||||
WHEN ag.aggmfinalmodify = 's' THEN 'SHAREABLE'
|
||||
WHEN ag.aggmfinalmodify = 'w' THEN 'READ_WRITE'
|
||||
ELSE 'unknown' END as moving_final_func_modify,
|
||||
agginitval as initial_val, aggminitval as moving_initial_val,
|
||||
op.oprname as sort_oper, aggfinalextra as final_extra_param, aggmfinalextra as moving_final_extra_param,
|
||||
aggtransspace as state_data_size, aggmtransspace as moving_state_data_size,
|
||||
CASE WHEN (tt.typlen = -1 AND tt.typelem != 0) THEN
|
||||
(SELECT at.typname FROM pg_catalog.pg_type at WHERE at.oid = tt.typelem) || '[]'
|
||||
ELSE tt.typname END as state_type,
|
||||
CASE WHEN (tf.typlen = -1 AND tf.typelem != 0) THEN
|
||||
(SELECT at.typname FROM pg_catalog.pg_type at WHERE at.oid = tf.typelem) || '[]'
|
||||
ELSE tf.typname END as final_type,
|
||||
CASE WHEN (tm.typlen = -1 AND tm.typelem != 0) THEN
|
||||
(SELECT at.typname FROM pg_catalog.pg_type at WHERE at.oid = tm.typelem) || '[]'
|
||||
ELSE tm.typname END as moving_state_type,
|
||||
description
|
||||
FROM pg_catalog.pg_aggregate ag
|
||||
LEFT OUTER JOIN pg_catalog.pg_proc pr ON pr.oid = ag.aggfnoid
|
||||
LEFT OUTER JOIN pg_catalog.pg_namespace ns ON ns.oid=pr.pronamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_type tt on tt.oid=aggtranstype
|
||||
LEFT OUTER JOIN pg_catalog.pg_type tf on tf.oid=prorettype
|
||||
LEFT OUTER JOIN pg_catalog.pg_type tm on tm.oid=aggmtranstype
|
||||
LEFT OUTER JOIN pg_catalog.pg_operator op on op.oid = ag.aggsortop
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=aggfnoid::oid AND des.classoid='pg_aggregate'::regclass)
|
||||
WHERE pronamespace = {{scid}}::oid
|
||||
{% if agid %} AND ag.aggfnoid = {{agid}}::oid {% endif %}
|
||||
ORDER BY name;
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
{% if data %}
|
||||
CREATE OR REPLACE AGGREGATE {{conn|qtIdent(data.schema, data.name)}}({% if data.input_types %}{{data.input_types}}{% endif %}) (
|
||||
SFUNC = {{data.state_func}},
|
||||
STYPE = {{data.state_type}} {% if data.state_data_size %},
|
||||
SSPACE = {{data.state_data_size}}{% endif %}{% if data.final_func %},
|
||||
FINALFUNC = {{data.final_func}}{% endif %}{% if data.final_extra_param %},
|
||||
FINALFUNC_EXTRA{% endif %}{% if data.final_func_modify %},
|
||||
FINALFUNC_MODIFY = {{data.final_func_modify}}{% endif %}{% if data.combine_func %},
|
||||
COMBINEFUNC = {{data.combine_func}}{% endif %}{% if data.serialization_func %},
|
||||
SERIALFUNC = {{data.serialization_func}}{% endif %}{% if data.deserialization_func %},
|
||||
DESERIALFUNC = {{data.deserialization_func}}{% endif %}{% if data.initial_val %},
|
||||
INITCOND = '{{data.initial_val}}'{% endif %}{% if data.moving_state_func %},
|
||||
MSFUNC = {{data.moving_state_func}}{% endif %}{% if data.moving_inverse_func %},
|
||||
MINVFUNC = {{data.moving_inverse_func}}{% endif %}{% if data.moving_state_type %},
|
||||
MSTYPE = {{data.moving_state_type}}{% endif %}{% if data.moving_state_data_size %},
|
||||
MSSPACE = {{data.moving_state_data_size}}{% endif %}{% if data.moving_final_func %},
|
||||
MFINALFUNC = {{data.moving_final_func}}{% endif %}{% if data.moving_final_extra_param %},
|
||||
MFINALFUNC_EXTRA{% endif %}{% if data.moving_final_func_modify %},
|
||||
MFINALFUNC_MODIFY = {{data.moving_final_func_modify}}{% endif %}{% if data.moving_initial_val %},
|
||||
MINITCOND = '{{data.moving_initial_val}}'{% endif %}{% if data.sort_oper %},
|
||||
SORTOP = {{data.sort_oper}}{% endif %}
|
||||
|
||||
);
|
||||
{% endif %}
|
||||
+5
-3
@@ -1,10 +1,11 @@
|
||||
{% if data %}
|
||||
CREATE AGGREGATE {{conn|qtIdent(data.schema, data.name)}}({% if data.input_types %}{{data.input_types}}{% endif %}) (
|
||||
CREATE OR REPLACE AGGREGATE {{conn|qtIdent(data.schema, data.name)}}({% if data.input_types %}{{data.input_types}}{% endif %}) (
|
||||
SFUNC = {{data.state_func}},
|
||||
STYPE = {{data.state_type}} {% if data.state_data_size %},
|
||||
SSPACE = {{data.state_data_size}}{% endif %}{% if data.final_func %},
|
||||
FINALFUNC = {{data.final_func}}{% endif %}{% if data.final_extra_param %},
|
||||
FINALFUNC_EXTRA{% endif %}{% if data.combine_func %},
|
||||
FINALFUNC_EXTRA{% endif %}{% if data.final_func_modify %},
|
||||
FINALFUNC_MODIFY = {{data.final_func_modify}}{% endif %}{% if data.combine_func %},
|
||||
COMBINEFUNC = {{data.combine_func}}{% endif %}{% if data.serialization_func %},
|
||||
SERIALFUNC = {{data.serialization_func}}{% endif %}{% if data.deserialization_func %},
|
||||
DESERIALFUNC = {{data.deserialization_func}}{% endif %}{% if data.initial_val %},
|
||||
@@ -14,7 +15,8 @@ CREATE AGGREGATE {{conn|qtIdent(data.schema, data.name)}}({% if data.input_types
|
||||
MSTYPE = {{data.moving_state_type}}{% endif %}{% if data.moving_state_data_size %},
|
||||
MSSPACE = {{data.moving_state_data_size}}{% endif %}{% if data.moving_final_func %},
|
||||
MFINALFUNC = {{data.moving_final_func}}{% endif %}{% if data.moving_final_extra_param %},
|
||||
MFINALFUNC_EXTRA{% endif %}{% if data.moving_initial_val %},
|
||||
MFINALFUNC_EXTRA{% endif %}{% if data.moving_final_func_modify %},
|
||||
MFINALFUNC_MODIFY = {{data.moving_final_func_modify}}{% endif %}{% if data.moving_initial_val %},
|
||||
MINITCOND = '{{data.moving_initial_val}}'{% endif %}{% if data.sort_oper %},
|
||||
SORTOP = {{data.sort_oper}}{% endif %}
|
||||
|
||||
|
||||
+8
@@ -13,6 +13,14 @@ SELECT aggfnoid::oid as oid, proname as name, ns.nspname as schema,
|
||||
CASE WHEN aggmtransfn = '-'::regproc THEN null ELSE aggmtransfn END as moving_state_func,
|
||||
CASE WHEN aggmfinalfn = '-'::regproc THEN null ELSE aggmfinalfn END as moving_final_func,
|
||||
CASE WHEN aggminvtransfn = '-'::regproc THEN null ELSE aggminvtransfn END as moving_inverse_func,
|
||||
CASE WHEN ag.aggfinalmodify = 'r' THEN 'READ_ONLY'
|
||||
WHEN ag.aggfinalmodify = 's' THEN 'SHAREABLE'
|
||||
WHEN ag.aggfinalmodify = 'w' THEN 'READ_WRITE'
|
||||
ELSE 'unknown' END as final_func_modify,
|
||||
CASE WHEN ag.aggmfinalmodify = 'r' THEN 'READ_ONLY'
|
||||
WHEN ag.aggmfinalmodify = 's' THEN 'SHAREABLE'
|
||||
WHEN ag.aggmfinalmodify = 'w' THEN 'READ_WRITE'
|
||||
ELSE 'unknown' END as moving_final_func_modify,
|
||||
agginitval as initial_val, aggminitval as moving_initial_val,
|
||||
op.oprname as sort_oper, aggfinalextra as final_extra_param, aggmfinalextra as moving_final_extra_param,
|
||||
aggtransspace as state_data_size, aggmtransspace as moving_state_data_size,
|
||||
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
{% if data %}
|
||||
CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|qtIdent(data.schema, data.name) }}
|
||||
{% if not data.copy_collation %}
|
||||
{% set options = [] %}
|
||||
{# if user has provided lc_collate & lc_type #}
|
||||
{% if data.lc_collate and data.lc_type %}
|
||||
{% if data.lc_collate and data.lc_type %}
|
||||
{% set options = options + ['LC_COLLATE = ' ~ data.lc_collate|qtLiteral(conn), 'LC_CTYPE = ' ~ data.lc_type|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.provider %}
|
||||
{% set options = options + ['PROVIDER = ' ~ data.provider|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.is_deterministic is defined %}
|
||||
{% set options = options + ['DETERMINISTIC = ' ~ data.is_deterministic|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.rules %}
|
||||
{% set options = options + ['RULES = ' ~ data.rules|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.version %}
|
||||
{% set options = options + ['VERSION = ' ~ data.version|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# if user has provided locale only #}
|
||||
{% if data.locale %}
|
||||
{% if data.locale %}
|
||||
{% set options = options + ['LOCALE = ' ~ data.locale|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.provider %}
|
||||
{% set options = options + ['PROVIDER = ' ~ data.provider|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.is_deterministic is defined %}
|
||||
{% set options = options + ['DETERMINISTIC = ' ~ data.is_deterministic|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.rules %}
|
||||
{% set options = options + ['RULES = ' ~ data.rules|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.version %}
|
||||
{% set options = options + ['VERSION = ' ~ data.version|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if options %}
|
||||
({{ options|join(', ') }});
|
||||
{% endif %}
|
||||
{% 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(conn) }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
SELECT c.oid, c.collname AS name, c.collcollate AS lc_collate, c.collctype AS lc_type,
|
||||
pg_catalog.pg_get_userbyid(c.collowner) AS owner, c.collisdeterministic AS is_deterministic, c.collversion AS version,
|
||||
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
|
||||
des.description, n.nspname AS schema
|
||||
FROM pg_catalog.pg_collation c
|
||||
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_collation'::regclass)
|
||||
WHERE c.collnamespace = {{scid}}::oid
|
||||
{% if coid %} AND c.oid = {{coid}}::oid {% endif %}
|
||||
ORDER BY c.collname;
|
||||
+12
@@ -10,6 +10,12 @@ CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|
|
||||
{% if data.provider %}
|
||||
{% set options = options + ['PROVIDER = ' ~ data.provider|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.is_deterministic is defined %}
|
||||
{% set options = options + ['DETERMINISTIC = ' ~ data.is_deterministic|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.rules %}
|
||||
{% set options = options + ['RULES = ' ~ data.rules|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.version %}
|
||||
{% set options = options + ['VERSION = ' ~ data.version|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
@@ -22,6 +28,12 @@ CREATE COLLATION{% if add_not_exists_clause %} IF NOT EXISTS{% endif %} {{ conn|
|
||||
{% if data.provider %}
|
||||
{% set options = options + ['PROVIDER = ' ~ data.provider|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.is_deterministic is defined %}
|
||||
{% set options = options + ['DETERMINISTIC = ' ~ data.is_deterministic|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.rules %}
|
||||
{% set options = options + ['RULES = ' ~ data.rules|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
{% if data.version %}
|
||||
{% set options = options + ['VERSION = ' ~ data.version|qtLiteral(conn)] %}
|
||||
{% endif %}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
SELECT c.oid, c.collname AS name, c.collcollate AS lc_collate, c.collctype AS lc_type,
|
||||
pg_catalog.pg_get_userbyid(c.collowner) AS owner, c.collversion AS version,
|
||||
c.collprovider AS provider, des.description, n.nspname AS schema
|
||||
|
||||
pg_catalog.pg_get_userbyid(c.collowner) AS owner, c.collisdeterministic AS is_deterministic, c.collversion AS version,
|
||||
CASE WHEN c.collprovider = 'i' THEN 'icu' ELSE 'libc' END provider,
|
||||
des.description, n.nspname AS schema
|
||||
FROM pg_catalog.pg_collation c
|
||||
JOIN pg_catalog.pg_namespace n ON n.oid=c.collnamespace
|
||||
LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=c.oid AND des.classoid='pg_collation'::regclass)
|
||||
|
||||
-247
@@ -1,247 +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_columns",
|
||||
"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_column"
|
||||
},
|
||||
"store_object_id": "True"
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Foreign Table for testing column node.",
|
||||
"endpoint": "NODE-foreign_table.obj",
|
||||
"sql_endpoint": "NODE-foreign_table.sql_id",
|
||||
"data": {
|
||||
"name": "foreign_table_2_$%{}[]()&*^!@\"'`\\/#",
|
||||
"columns": [],
|
||||
"schema": "public",
|
||||
"basensp": "public",
|
||||
"ftsrvname": "test_fs_for_foreign_table_column",
|
||||
"owner": "<OWNER>",
|
||||
"ftoptions": [],
|
||||
"inherits": [],
|
||||
"relacl": [],
|
||||
"seclabels": []
|
||||
},
|
||||
"store_object_id": "True"
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column (Integer/Numeric type)",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description": "Comment for create",
|
||||
"cltype": "numeric",
|
||||
"attlen": "10",
|
||||
"attprecision": "5",
|
||||
"colconstype": "n",
|
||||
"attnotnull": true,
|
||||
"attoptions": [],
|
||||
"seclabels": [],
|
||||
"defval": "1"
|
||||
},
|
||||
"expected_sql_file": "create_column_numeric.sql",
|
||||
"expected_msql_file": "create_column_numeric.msql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter FT Column (Integer/Numeric type)",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attnum": 1,
|
||||
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description": "Comment for alter",
|
||||
"cltype": "real",
|
||||
"coloptions": {
|
||||
"added": [
|
||||
{
|
||||
"option": "column_name",
|
||||
"value": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"expected_sql_file": "alter_column_numeric.sql",
|
||||
"expected_msql_file": "alter_column_numeric.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT Column (Integer/Numeric type)",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with text & default value",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_2_$%{}[]()&*^!@\"'`\\/#",
|
||||
"cltype": "text",
|
||||
"description": "test comment",
|
||||
"attnotnull": true,
|
||||
"colconstype": "n",
|
||||
"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 FT Column with text & update default value",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attnum": 2,
|
||||
"defval": "'changed default value'"
|
||||
},
|
||||
"expected_sql_file": "alter_column_text_with_default_value.sql",
|
||||
"expected_msql_file": "alter_column_text_with_default_value.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT column with text & update default value",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "col_2_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with time with time zone & default value using function",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/#",
|
||||
"cltype": "time with time zone",
|
||||
"attacl": [],
|
||||
"description": "test comment",
|
||||
"attnotnull": true,
|
||||
"colconstype": "n",
|
||||
"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 FT Column with time with time zone & update length",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attlen": "10",
|
||||
"attnotnull": false,
|
||||
"attnum": 3,
|
||||
"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 FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_4_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description": "test comment",
|
||||
"cltype": "bigint",
|
||||
"attnotnull": true,
|
||||
"coloptions": [
|
||||
{
|
||||
"option": "column_name",
|
||||
"value": "test_options"
|
||||
}
|
||||
],
|
||||
"colconstype": "g",
|
||||
"is_tlength": false,
|
||||
"is_precision": false,
|
||||
"genexpr": "1000+1",
|
||||
"attoptions": [
|
||||
{
|
||||
"name": "n_distinct",
|
||||
"value": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"expected_sql_file": "create_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "create_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attoptions": {
|
||||
"changed": [
|
||||
{
|
||||
"name": "n_distinct",
|
||||
"value": "111"
|
||||
}
|
||||
]
|
||||
},
|
||||
"coloptions": {
|
||||
"changed": [
|
||||
{
|
||||
"option": "column_name",
|
||||
"value": "test_options_update"
|
||||
}
|
||||
]
|
||||
},
|
||||
"attnum": 4
|
||||
},
|
||||
"expected_sql_file": "alter_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "alter_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_columnn.sql_id",
|
||||
"data": {
|
||||
"name": "col_4_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+110
-1
@@ -53,7 +53,6 @@
|
||||
"cltype": "numeric",
|
||||
"attlen": "10",
|
||||
"attprecision": "5",
|
||||
"coloptions": [],
|
||||
"colconstype": "n",
|
||||
"attnotnull": true,
|
||||
"attoptions": [],
|
||||
@@ -133,6 +132,116 @@
|
||||
"data": {
|
||||
"name": "col_2_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with time with time zone & default value using function",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/#",
|
||||
"cltype": "time with time zone",
|
||||
"attacl": [],
|
||||
"description": "test comment",
|
||||
"attnotnull": true,
|
||||
"colconstype": "n",
|
||||
"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 FT Column with time with time zone & update length",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attlen": "10",
|
||||
"attnotnull": false,
|
||||
"attnum": 3,
|
||||
"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 FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_4_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description": "test comment",
|
||||
"cltype": "bigint",
|
||||
"attnotnull": true,
|
||||
"coloptions": [
|
||||
{
|
||||
"option": "column_name",
|
||||
"value": "test_options"
|
||||
}
|
||||
],
|
||||
"colconstype": "g",
|
||||
"is_tlength": false,
|
||||
"is_precision": false,
|
||||
"genexpr": "1000+1",
|
||||
"attoptions": [
|
||||
{
|
||||
"name": "n_distinct",
|
||||
"value": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"expected_sql_file": "create_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "create_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attoptions": {
|
||||
"changed": [
|
||||
{
|
||||
"name": "n_distinct",
|
||||
"value": "111"
|
||||
}
|
||||
]
|
||||
},
|
||||
"coloptions": {
|
||||
"changed": [
|
||||
{
|
||||
"option": "column_name",
|
||||
"value": "test_options_update"
|
||||
}
|
||||
]
|
||||
},
|
||||
"attnum": 4
|
||||
},
|
||||
"expected_sql_file": "alter_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "alter_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_columnn.sql_id",
|
||||
"data": {
|
||||
"name": "col_4_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
-213
@@ -1,213 +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_columns",
|
||||
"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_column"
|
||||
},
|
||||
"store_object_id": "True"
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Foreign Table for testing column node.",
|
||||
"endpoint": "NODE-foreign_table.obj",
|
||||
"sql_endpoint": "NODE-foreign_table.sql_id",
|
||||
"data": {
|
||||
"name": "foreign_table_2_$%{}[]()&*^!@\"'`\\/#",
|
||||
"columns": [],
|
||||
"schema": "public",
|
||||
"basensp": "public",
|
||||
"ftsrvname": "test_fs_for_foreign_table_column",
|
||||
"owner": "enterprisedb",
|
||||
"ftoptions": [],
|
||||
"inherits": [],
|
||||
"relacl": [],
|
||||
"seclabels": []
|
||||
},
|
||||
"store_object_id": "True"
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column (Integer/Numeric type)",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description": "Comment for create",
|
||||
"cltype": "numeric",
|
||||
"attlen":"10",
|
||||
"attprecision":"5",
|
||||
"colconstype":"n",
|
||||
"attnotnull": true,
|
||||
"attoptions": [],
|
||||
"seclabels": [],
|
||||
"defval": "1"
|
||||
},
|
||||
"expected_sql_file": "create_column_numeric.sql",
|
||||
"expected_msql_file": "create_column_numeric.msql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter FT Column (Integer/Numeric type)",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attnum": 1,
|
||||
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description": "Comment for alter",
|
||||
"cltype": "real",
|
||||
"coloptions":{"added":[{"option":"column_name","value":"test"}]}
|
||||
},
|
||||
"expected_sql_file": "alter_column_numeric.sql",
|
||||
"expected_msql_file": "alter_column_numeric.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT Column (Integer/Numeric type)",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "new_col_1_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with text & default value",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_2_$%{}[]()&*^!@\"'`\\/#",
|
||||
"cltype": "text",
|
||||
"description": "test comment",
|
||||
"attnotnull": true,
|
||||
"colconstype": "n",
|
||||
"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 FT Column with text & update default value",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attnum": 2,
|
||||
"defval": "'changed default value'"
|
||||
},
|
||||
"expected_sql_file": "alter_column_text_with_default_value.sql",
|
||||
"expected_msql_file": "alter_column_text_with_default_value.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT column with text & update default value",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "col_2_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with time with time zone & default value using function",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/#",
|
||||
"cltype": "time with time zone",
|
||||
"attacl": [],
|
||||
"description": "test comment",
|
||||
"attnotnull": true,
|
||||
"colconstype": "n",
|
||||
"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 FT Column with time with time zone & update length",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attlen": "10",
|
||||
"attnotnull": false,
|
||||
"attnum":3,
|
||||
"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 FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {"name":"col_4_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description":"test comment",
|
||||
"cltype":"bigint",
|
||||
"attnotnull":true,
|
||||
"coloptions":[{"option":"column_name","value":"test_options"}],
|
||||
"colconstype":"g",
|
||||
"is_tlength":false,
|
||||
"is_precision":false,
|
||||
"genexpr":"1000+1",
|
||||
"attoptions":[{"name":"n_distinct","value":"1"}]},
|
||||
"expected_sql_file": "create_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "create_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data":{
|
||||
"attoptions":{
|
||||
"changed":[{"name":"n_distinct","value":"111"}]},
|
||||
"coloptions":{"changed":[{"option":"column_name","value":"test_options_update"}]},
|
||||
"attnum":4},
|
||||
"expected_sql_file": "alter_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "alter_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_columnn.sql_id",
|
||||
"data": {
|
||||
"name":"col_4_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]}
|
||||
+84
-1
@@ -53,7 +53,6 @@
|
||||
"cltype": "numeric",
|
||||
"attlen":"10",
|
||||
"attprecision":"5",
|
||||
"coloptions":[],
|
||||
"colconstype":"n",
|
||||
"attnotnull": true,
|
||||
"attoptions": [],
|
||||
@@ -126,5 +125,89 @@
|
||||
"data": {
|
||||
"name": "col_2_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with time with time zone & default value using function",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/#",
|
||||
"cltype": "time with time zone",
|
||||
"attacl": [],
|
||||
"description": "test comment",
|
||||
"attnotnull": true,
|
||||
"colconstype": "n",
|
||||
"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 FT Column with time with time zone & update length",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data": {
|
||||
"attlen": "10",
|
||||
"attnotnull": false,
|
||||
"attnum":3,
|
||||
"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 FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"data": {
|
||||
"name": "col_3_$%{}[]()&*^!@\"'`\\/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql",
|
||||
"data": {"name":"col_4_$%{}[]()&*^!@\"'`\\/#",
|
||||
"description":"test comment",
|
||||
"cltype":"bigint",
|
||||
"attnotnull":true,
|
||||
"coloptions":[{"option":"column_name","value":"test_options"}],
|
||||
"colconstype":"g",
|
||||
"is_tlength":false,
|
||||
"is_precision":false,
|
||||
"genexpr":"1000+1",
|
||||
"attoptions":[{"name":"n_distinct","value":"1"}]},
|
||||
"expected_sql_file": "create_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "create_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter FT Column with integer & generated always with expression, column option, variables",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_column.sql_id",
|
||||
"msql_endpoint": "NODE-foreign_table_column.msql_id",
|
||||
"data":{
|
||||
"attoptions":{
|
||||
"changed":[{"name":"n_distinct","value":"111"}]},
|
||||
"coloptions":{"changed":[{"option":"column_name","value":"test_options_update"}]},
|
||||
"attnum":4},
|
||||
"expected_sql_file": "alter_column_with_integer_generated_always_column_option_variables.sql",
|
||||
"expected_msql_file": "alter_column_with_integer_generated_always_column_option_variables.msql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop FT Column with time with time zone",
|
||||
"endpoint": "NODE-foreign_table_column.obj_id",
|
||||
"sql_endpoint": "NODE-foreign_table_columnn.sql_id",
|
||||
"data": {
|
||||
"name":"col_4_$%{}[]()&*^!@\"'`\\/#"
|
||||
}
|
||||
}
|
||||
]}
|
||||
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
WITH INH_TABLES AS
|
||||
(SELECT
|
||||
at.attname AS name, 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, att.atttypid, attfdwoptions,
|
||||
att.attname as name, att.attndims, att.atttypmod, pg_catalog.format_type(t.oid,NULL) AS cltype,
|
||||
att.attnotnull, att.attstorage, att.attstattarget, att.attnum, pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype,
|
||||
t.typstorage AS defaultstorage,
|
||||
CASE WHEN t.typelem > 0 THEN t.typelem ELSE t.oid END as elemoid,
|
||||
(CASE WHEN (att.attidentity in ('a', 'd')) THEN 'i' WHEN (att.attgenerated in ('s')) THEN 'g' ELSE 'n' END) AS colconstype,
|
||||
(CASE WHEN (att.attgenerated in ('s')) THEN pg_catalog.pg_get_expr(def.adbin, def.adrelid) END) AS genexpr,
|
||||
(SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = t.typnamespace) as typnspname,
|
||||
pg_catalog.format_type(t.oid,NULL) AS typname,
|
||||
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 defval,
|
||||
(SELECT COUNT(1) from pg_catalog.pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup,
|
||||
des.description
|
||||
FROM
|
||||
pg_catalog.pg_attribute att
|
||||
LEFT JOIN
|
||||
INH_TABLES as INH ON att.attname = INH.name
|
||||
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
|
||||
LEFT OUTER JOIN
|
||||
pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.classoid='pg_class'::regclass AND des.objsubid = att.attnum)
|
||||
WHERE
|
||||
att.attrelid={{foid}}::oid
|
||||
AND att.attnum>0
|
||||
ORDER BY att.attnum;
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
SELECT
|
||||
oid as conoid, conname, contype,
|
||||
pg_catalog.BTRIM(substring(pg_catalog.pg_get_constraintdef(oid, true) from '\(.+\)'), '()') as consrc,
|
||||
connoinherit, convalidated, conislocal
|
||||
FROM
|
||||
pg_catalog.pg_constraint
|
||||
WHERE
|
||||
conrelid={{foid}}::oid AND contype != 'n'
|
||||
ORDER by conname;
|
||||
+2
@@ -18,6 +18,8 @@ SELECT INH.inheritedfrom, INH.inheritedid, att.attoptions, att.atttypid, attfdwo
|
||||
att.attnotnull, att.attstorage, att.attstattarget, att.attnum, pg_catalog.format_type(t.oid, att.atttypmod) AS fulltype,
|
||||
t.typstorage AS defaultstorage,
|
||||
CASE WHEN t.typelem > 0 THEN t.typelem ELSE t.oid END as elemoid,
|
||||
(CASE WHEN (att.attidentity in ('a', 'd')) THEN 'i' WHEN (att.attgenerated in ('s')) THEN 'g' ELSE 'n' END) AS colconstype,
|
||||
(CASE WHEN (att.attgenerated in ('s')) THEN pg_catalog.pg_get_expr(def.adbin, def.adrelid) END) AS genexpr,
|
||||
(SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = t.typnamespace) as typnspname,
|
||||
pg_catalog.format_type(t.oid,NULL) AS typname,
|
||||
CASE WHEN length(cn.nspname::text) > 0 AND length(cl.collname::text) > 0 THEN
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
SELECT
|
||||
oid as conoid, conname, contype, consrc, connoinherit, convalidated, conislocal
|
||||
oid as conoid, conname, contype,
|
||||
pg_catalog.BTRIM(substring(pg_catalog.pg_get_constraintdef(oid, true) from '\(.+\)'), '()') as consrc,
|
||||
connoinherit, convalidated, conislocal
|
||||
FROM
|
||||
pg_catalog.pg_constraint
|
||||
WHERE
|
||||
conrelid={{foid}}::oid
|
||||
conrelid={{foid}}::oid AND contype != 'n'
|
||||
ORDER by conname;
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
SELECT
|
||||
funcname AS {{ conn|qtIdent(_('Name')) }},
|
||||
calls AS {{ conn|qtIdent(_('Number of calls')) }},
|
||||
total_time AS {{ conn|qtIdent(_('Total time')) }},
|
||||
self_time AS {{ conn|qtIdent(_('Self time')) }}
|
||||
FROM
|
||||
pg_catalog.pg_stat_user_functions
|
||||
WHERE
|
||||
schemaname = {{schema_name|qtLiteral(conn)}}
|
||||
AND funcid IN (
|
||||
SELECT p.oid
|
||||
FROM
|
||||
pg_catalog.pg_proc p
|
||||
JOIN
|
||||
pg_catalog.pg_type typ ON typ.oid=p.prorettype
|
||||
WHERE
|
||||
p.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
)
|
||||
ORDER BY funcname;
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
SELECT COUNT(*)
|
||||
FROM
|
||||
pg_catalog.pg_proc pr
|
||||
JOIN
|
||||
pg_catalog.pg_type typ ON typ.oid=prorettype
|
||||
WHERE
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
AND pronamespace = {{scid}}::oid;
|
||||
-21
@@ -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
|
||||
pr.prokind IN ('f', 'w')
|
||||
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 %}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
SELECT
|
||||
pg_catalog.pg_get_functiondef({{fnid}}::oid) AS func_def,
|
||||
COALESCE(pg_catalog.pg_get_function_identity_arguments(pr.oid), '') as
|
||||
func_with_identity_arguments,
|
||||
nspname,
|
||||
pr.proname as proname,
|
||||
COALESCE(pg_catalog.pg_get_function_arguments(pr.oid), '') as func_args
|
||||
FROM
|
||||
pg_catalog.pg_proc pr
|
||||
JOIN
|
||||
pg_catalog.pg_namespace nsp ON nsp.oid=pr.pronamespace
|
||||
WHERE
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND pronamespace = {{scid}}::oid
|
||||
AND pr.oid = {{fnid}}::oid;
|
||||
-17
@@ -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(conn) }}
|
||||
WHERE
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
AND pr.proname = {{ name|qtLiteral(conn) }};
|
||||
-26
@@ -1,26 +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, 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
|
||||
pr.prokind IN ('f', 'w')
|
||||
{% if fnid %}
|
||||
AND pr.oid = {{ fnid|qtLiteral(conn) }}
|
||||
{% 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 NOT IN ('trigger', 'event_trigger')
|
||||
ORDER BY
|
||||
proname;
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
SELECT
|
||||
pr.oid, pr.xmin,
|
||||
CASE WHEN pr.prokind = 'w' THEN true ELSE false END AS proiswindow,
|
||||
pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, pr.prokind,
|
||||
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
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
{% if fnid %}
|
||||
AND pr.oid = {{fnid}}::oid
|
||||
{% else %}
|
||||
AND pronamespace = {{scid}}::oid
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
proname;
|
||||
-73
@@ -1,73 +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(conn) }}
|
||||
{% 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.prosupportfunc %}
|
||||
SUPPORT {{ data.prosupportfunc }}
|
||||
{% 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(conn) }}{% endif %}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
AS {% if data.lanname == 'c' %}
|
||||
{{ data.probin|qtLiteral(conn) }}, {{ data.prosrc_c|qtLiteral(conn) }}
|
||||
{% 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(conn) }};
|
||||
{% 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 %}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
SELECT
|
||||
pr.oid, pr.xmin,
|
||||
CASE WHEN pr.prokind = 'w' THEN true ELSE false END AS proiswindow,
|
||||
pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, pr.prokind,
|
||||
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,
|
||||
CASE WHEN prosupport = 0::oid THEN ''
|
||||
ELSE (
|
||||
SELECT pg_catalog.quote_ident(nspname) || '.' || pg_catalog.quote_ident(proname) AS tfunctions
|
||||
FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n
|
||||
WHERE p.pronamespace = n.oid
|
||||
AND p.oid = pr.prosupport::OID
|
||||
) END AS prosupportfunc,
|
||||
(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
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
{% if fnid %}
|
||||
AND pr.oid = {{fnid}}::oid
|
||||
{% else %}
|
||||
AND pronamespace = {{scid}}::oid
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
proname;
|
||||
-130
@@ -1,130 +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'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% 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(conn) }} {% else %}
|
||||
LANGUAGE {{ o_data.lanname|qtLiteral(conn) }}
|
||||
{% 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.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% 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(conn) }}{% else %}{{ o_data.probin|qtLiteral(conn) }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral(conn) }}{% else %}{{ o_data.prosrc_c|qtLiteral(conn) }}{% endif %}{% elif 'prosrc' in data %}
|
||||
$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %}
|
||||
{{ o_data.probin|qtLiteral(conn) }}, {{ o_data.prosrc_c|qtLiteral(conn) }}{% 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(conn) }};
|
||||
{% endif -%}
|
||||
|
||||
{% if data.pronamespace %}
|
||||
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
|
||||
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
|
||||
{% endif -%}
|
||||
|
||||
{% endif %}
|
||||
-82
@@ -1,82 +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(conn) }}
|
||||
{% 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.prosupportfunc %}
|
||||
SUPPORT {{ data.prosupportfunc }}
|
||||
{% 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(conn) }}{% endif %}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
AS {% if data.lanname == 'c' %}
|
||||
{{ data.probin|qtLiteral(conn) }}, {{ data.prosrc_c|qtLiteral(conn) }}
|
||||
{% 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.dependsonextensions %}
|
||||
{% for ext in data.dependsonextensions %}
|
||||
|
||||
ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
|
||||
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
|
||||
{% endfor %}
|
||||
{% 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(conn) }};
|
||||
{% 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 %}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
SELECT
|
||||
pr.oid, pr.xmin,
|
||||
CASE WHEN pr.prokind = 'w' THEN true ELSE false END AS proiswindow,
|
||||
pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, pr.prokind,
|
||||
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 array_agg(DISTINCT e.extname)
|
||||
FROM pg_catalog.pg_depend d
|
||||
JOIN pg_catalog.pg_extension e ON d.refobjid = e.oid
|
||||
WHERE d.objid = pr.oid
|
||||
) AS dependsonextensions,
|
||||
CASE WHEN prosupport = 0::oid THEN ''
|
||||
ELSE (
|
||||
SELECT pg_catalog.quote_ident(nspname) || '.' || pg_catalog.quote_ident(proname) AS tfunctions
|
||||
FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n
|
||||
WHERE p.pronamespace = n.oid
|
||||
AND p.oid = pr.prosupport::OID
|
||||
) END AS prosupportfunc,
|
||||
(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
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
{% if fnid %}
|
||||
AND pr.oid = {{fnid}}::oid
|
||||
{% else %}
|
||||
AND pronamespace = {{scid}}::oid
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
proname;
|
||||
-146
@@ -1,146 +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'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% 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(conn) }} {% else %}
|
||||
LANGUAGE {{ o_data.lanname|qtLiteral(conn) }}
|
||||
{% 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.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% 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(conn) }}{% else %}{{ o_data.probin|qtLiteral(conn) }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral(conn) }}{% else %}{{ o_data.prosrc_c|qtLiteral(conn) }}{% endif %}{% elif 'prosrc' in data %}
|
||||
$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %}
|
||||
{{ o_data.probin|qtLiteral(conn) }}, {{ o_data.prosrc_c|qtLiteral(conn) }}{% 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(conn) }};
|
||||
{% endif -%}
|
||||
|
||||
{% if data.pronamespace %}
|
||||
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
|
||||
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
|
||||
{% endif -%}
|
||||
|
||||
{% set old_exts = (o_data.dependsonextensions or []) | list %}
|
||||
{% set new_exts = data.dependsonextensions if 'dependsonextensions' in data else None %}
|
||||
|
||||
{% if new_exts is not none and old_exts != new_exts %}
|
||||
{% for ext in (old_exts + new_exts) | unique %}
|
||||
|
||||
{% if ext in new_exts and ext not in old_exts %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
|
||||
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
|
||||
{% elif ext in old_exts and ext not in new_exts %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
|
||||
NO DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
-85
@@ -1,85 +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(conn) }}
|
||||
{% 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.prosupportfunc %}
|
||||
SUPPORT {{ data.prosupportfunc }}
|
||||
{% 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(conn) }}{% endif %}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if data.is_pure_sql %}{{ data.prosrc }}
|
||||
{% else %}
|
||||
AS {% if data.lanname == 'c' %}
|
||||
{{ data.probin|qtLiteral(conn) }}, {{ data.prosrc_c|qtLiteral(conn) }}
|
||||
{% else %}
|
||||
$BODY${{ data.prosrc }}$BODY${% endif -%};
|
||||
{% 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.dependsonextensions %}
|
||||
{% for ext in data.dependsonextensions %}
|
||||
|
||||
ALTER FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func_args_without}})
|
||||
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
|
||||
{% endfor %}
|
||||
{% 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(conn) }};
|
||||
{% 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 %}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
SELECT
|
||||
pr.oid, pr.xmin,
|
||||
CASE WHEN pr.prokind = 'w' THEN true ELSE false END AS proiswindow,
|
||||
pr.prosrc, pr.prosrc AS prosrc_c, pr.pronamespace, pr.prolang, pr.procost, pr.prorows, pr.prokind,
|
||||
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,
|
||||
pg_catalog.pg_get_function_sqlbody(pr.oid) AS prosrc_sql,
|
||||
CASE WHEN pr.prosqlbody IS NOT NULL THEN true ELSE false END as is_pure_sql,
|
||||
pr.pronargdefaults, proconfig, pg_catalog.pg_get_userbyid(proowner) AS funcowner, description,
|
||||
(
|
||||
SELECT array_agg(DISTINCT e.extname)
|
||||
FROM pg_catalog.pg_depend d
|
||||
JOIN pg_catalog.pg_extension e ON d.refobjid = e.oid
|
||||
WHERE d.objid = pr.oid
|
||||
) AS dependsonextensions,
|
||||
CASE WHEN prosupport = 0::oid THEN ''
|
||||
ELSE (
|
||||
SELECT pg_catalog.quote_ident(nspname) || '.' || pg_catalog.quote_ident(proname) AS tfunctions
|
||||
FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n
|
||||
WHERE p.pronamespace = n.oid
|
||||
AND p.oid = pr.prosupport::OID
|
||||
) END AS prosupportfunc,
|
||||
(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
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
{% if fnid %}
|
||||
AND pr.oid = {{fnid}}::oid
|
||||
{% else %}
|
||||
AND pronamespace = {{scid}}::oid
|
||||
{% endif %}
|
||||
ORDER BY
|
||||
proname;
|
||||
-149
@@ -1,149 +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'] %}
|
||||
{% set set_variables = [] %}
|
||||
{% if 'merged_variables' in data and data.merged_variables|length > 0 %}
|
||||
{% set set_variables = data.merged_variables %}
|
||||
{% elif 'variables' in o_data and o_data.variables|length > 0 %}
|
||||
{% set set_variables = o_data.variables %}
|
||||
{% endif %}
|
||||
{% 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(conn) }} {% else %}
|
||||
LANGUAGE {{ o_data.lanname|qtLiteral(conn) }}
|
||||
{% 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.prosupportfunc %}SUPPORT {{ data.prosupportfunc }}{% elif data.prosupportfunc is not defined and o_data.prosupportfunc %}SUPPORT {{ o_data.prosupportfunc }}{% endif -%}{% if set_variables and set_variables|length > 0 %}{% for v in set_variables %}
|
||||
|
||||
SET {{ conn|qtIdent(v.name) }}={% if v.name in exclude_quoting %}{{ v.value }}{% else %}{{ v.value|qtLiteral(conn) }}{% endif %}{% endfor -%}
|
||||
{% endif %}
|
||||
|
||||
{% if data.is_pure_sql %}{{ data.prosrc }}
|
||||
{% else %}
|
||||
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(conn) }}{% else %}{{ o_data.probin|qtLiteral(conn) }}{% endif %}, {% if 'prosrc_c' in data %}{{ data.prosrc_c|qtLiteral(conn) }}{% else %}{{ o_data.prosrc_c|qtLiteral(conn) }}{% endif %}{% elif 'prosrc' in data %}
|
||||
$BODY${{ data.prosrc }}$BODY${% elif o_data.lanname == 'c' %}
|
||||
{{ o_data.probin|qtLiteral(conn) }}, {{ o_data.prosrc_c|qtLiteral(conn) }}{% else %}
|
||||
$BODY${{ o_data.prosrc }}$BODY${% endif -%};
|
||||
{% 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(conn) }};
|
||||
{% endif -%}
|
||||
|
||||
{% if data.pronamespace %}
|
||||
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{o_data.proargtypenames }})
|
||||
SET SCHEMA {{ conn|qtIdent(data.pronamespace) }};
|
||||
{% endif -%}
|
||||
|
||||
{% set old_exts = (o_data.dependsonextensions or []) | list %}
|
||||
{% set new_exts = data.dependsonextensions if 'dependsonextensions' in data else None %}
|
||||
|
||||
{% if new_exts is not none and old_exts != new_exts %}
|
||||
{% for ext in (old_exts + new_exts) | unique %}
|
||||
|
||||
{% if ext in new_exts and ext not in old_exts %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
|
||||
DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
|
||||
{% elif ext in old_exts and ext not in new_exts %}
|
||||
ALTER FUNCTION {{ conn|qtIdent(o_data.pronamespace, name) }}({{ o_data.proargtypenames }})
|
||||
NO DEPENDS ON EXTENSION {{ conn|qtIdent(ext) }};
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
+1
-1
@@ -14,7 +14,7 @@ WHERE
|
||||
JOIN
|
||||
pg_catalog.pg_type typ ON typ.oid=p.prorettype
|
||||
WHERE
|
||||
p.proisagg = FALSE
|
||||
p.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
)
|
||||
ORDER BY funcname;
|
||||
|
||||
+2
-6
@@ -3,11 +3,7 @@ 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
|
||||
WHERE
|
||||
proisagg = FALSE
|
||||
pr.prokind IN ('f', 'w')
|
||||
AND typname NOT IN ('trigger', 'event_trigger')
|
||||
AND pronamespace = {{scid}}::oid
|
||||
AND pronamespace = {{scid}}::oid;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user