mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-11-02 08:10:03 -06:00
Fixed the failure of python test cases of EPAS and JS tests for publication node. #5868
This commit is contained in:
1 parent
396a22b6be
commit
05b595d32d
55 files changed
+401
-53
No files matched your search
@@ -72,7 +72,7 @@ class PublicationModule(CollectionNodeModule):
|
||||
did: Database Id
|
||||
"""
|
||||
if self.has_nodes(
|
||||
sid, did,
|
||||
sid, did,
|
||||
base_template_path=PublicationView.BASE_TEMPLATE_PATH):
|
||||
yield self.generate_browser_collection_node(did)
|
||||
|
||||
@@ -168,7 +168,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
_NOT_FOUND_PUB_INFORMATION = \
|
||||
gettext("Could not find the publication information.")
|
||||
node_type = blueprint.node_type
|
||||
BASE_TEMPLATE_PATH = "publications/sql/#{0}#"
|
||||
BASE_TEMPLATE_PATH = 'publications/{0}/#{1}#/sql'
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -226,9 +226,8 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
self.manager = self.driver.connection_manager(kwargs['sid'])
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
# Set the template path for the SQL scripts
|
||||
self.template_path = (
|
||||
self.BASE_TEMPLATE_PATH.format(self.manager.version)
|
||||
)
|
||||
self.template_path = self.BASE_TEMPLATE_PATH.format(
|
||||
self.manager.server_type, self.manager.version)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
@@ -798,12 +797,10 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
res = []
|
||||
|
||||
sql = render_template("/".join([self.template_path,
|
||||
'get_all_schemas.sql']),
|
||||
show_sys_objects=self.blueprint.
|
||||
show_system_objects,
|
||||
server_type=self.manager.server_type
|
||||
)
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'get_all_schemas.sql']),
|
||||
conn=self.conn
|
||||
)
|
||||
status, rset = self.conn.execute_2darray(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
@@ -1124,5 +1121,4 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return sql
|
||||
|
||||
|
||||
# SchemaDiffRegistry(blueprint.node_type, PublicationView, 'Database')
|
||||
PublicationView.register_node_view(blueprint)
|
||||
+2
-2
@@ -284,7 +284,7 @@ export default class PublicationSchema extends BaseUISchema {
|
||||
{
|
||||
id: 'pubtable_names', label: gettext('Tables'), cell: 'string',
|
||||
type: (state)=>{
|
||||
let table= (!_.isUndefined(state?.pubtable_names) && state?.pubtable_names.length > 0) && state?.pubtable_names;
|
||||
let table= (!_.isUndefined(state?.pubtable_names) && state?.pubtable_names.length > 0) ? state?.pubtable_names : [];
|
||||
return {
|
||||
type: 'select',
|
||||
options: table,
|
||||
@@ -298,7 +298,7 @@ export default class PublicationSchema extends BaseUISchema {
|
||||
id: 'pubtable', label: this.version < 150000 ? gettext('Tables') : gettext(''),
|
||||
type: this.version < 150000 ? 'select' : 'collection',
|
||||
controlProps: this.version < 150000 ? { allowClear: true, multiple: true, creatable: true } : null,
|
||||
options: this.version < 150000 ? this.fieldOptions.allTables : null,
|
||||
options: this.version < 150000 ? this.fieldOptions.allTables : [],
|
||||
group: this.version < 150000 ? gettext('Definition') : gettext('Tables'), mode: ['edit', 'create'],
|
||||
deps: ['all_table'], disabled: obj.isAllTable, schema: this.version < 150000 ? null : this.paramSchema,
|
||||
uniqueCol: this.version < 150000 ? null : ['table_name'],
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+9
@@ -0,0 +1,9 @@
|
||||
{% import 'catalog/pg/macros/catalogs.sql' as CATALOGS %}
|
||||
SELECT
|
||||
nsp.nspname
|
||||
FROM
|
||||
pg_catalog.pg_namespace nsp
|
||||
WHERE
|
||||
nspname NOT LIKE E'pg\\_%' AND
|
||||
NOT ({{ CATALOGS.LIST('nsp') }})
|
||||
ORDER BY nspname;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+20
@@ -0,0 +1,20 @@
|
||||
{% 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
@@ -0,0 +1,8 @@
|
||||
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
@@ -0,0 +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 %}
|
||||
|
||||
{% 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
@@ -0,0 +1,9 @@
|
||||
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
@@ -0,0 +1,48 @@
|
||||
{% 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 %}
|
||||
|
||||
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
{% 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 or data.pubschema %}
|
||||
FOR {% if data.pubtable %}TABLE {% if data.only_table%}ONLY {% endif %}{% for pub_table in data.pubtable %}{% if loop.index != 1 %}, {% endif %}{{pub_table['table_name']}}{% if pub_table['columns'] %} ({% for column in pub_table['columns'] %}{% if loop.index != 1 %}, {% endif %}{{column}}{% endfor %}){% endif %}{% if pub_table['where'] %} WHERE ({{pub_table['where']}}){% endif %}{% endfor %}{% endif %}{% if data.pubtable and data.pubschema %},{% endif %}
|
||||
{% if data.pubschema %}
|
||||
TABLES IN SCHEMA {% for pub_schema in data.pubschema %}{% if loop.index != 1 %}, {% endif %}{{ pub_schema }}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% 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 %}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{% import 'catalog/ppas/macros/catalogs.sql' as CATALOGS %}
|
||||
SELECT
|
||||
nsp.nspname
|
||||
FROM
|
||||
pg_catalog.pg_namespace nsp
|
||||
WHERE
|
||||
nsp.nspparent = 0 AND
|
||||
nspname NOT LIKE 'pg!_%' escape '!' AND
|
||||
NOT ({{ CATALOGS.LIST('nsp') }})
|
||||
ORDER BY nspname;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
SELECT n.nspname AS sname
|
||||
FROM pg_catalog.pg_publication_namespace pubnsp
|
||||
JOIN pg_catalog.pg_namespace n ON pubnsp.pnnspid = n.oid
|
||||
WHERE pnpubid = {{pbid}} :: oid;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
SELECT pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(cls.relname) AS table_name,
|
||||
(SELECT array_agg(attname) FROM pg_attribute att WHERE attrelid = prel.prrelid AND attnum IN (SELECT unnest(prattrs) FROM pg_publication_rel WHERE oid = prel.oid ) ) AS columns,
|
||||
pg_catalog.pg_get_expr(prel.prqual, prel.prrelid) AS where
|
||||
FROM pg_publication_rel prel
|
||||
JOIN pg_class cls ON cls.oid = prel.prrelid
|
||||
JOIN pg_catalog.pg_namespace n ON cls.relnamespace = n.oid WHERE prel.prpubid = {{pbid}} :: oid;
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
{% 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['table_name'] or pub_table }}{% endfor %};
|
||||
|
||||
{% endif %}
|
||||
|
||||
{### Alter drop publication schema ###}
|
||||
{% if drop_schema %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
DROP TABLES IN SCHEMA {% for pub_schema in drop_schema_data %}{% if loop.index != 1 %}, {% endif %}{{ pub_schema }}{% endfor %};
|
||||
|
||||
{% endif %}
|
||||
|
||||
{### Alter update publication table ###}
|
||||
{% if update_table %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
SET TABLE {% for pub_table in update_table_data %}{% if loop.index != 1 %}, TABLE {% endif %}{{ pub_table['table_name'] or pub_table }}{% if pub_table['columns'] %} ({% for column in pub_table['columns'] %}{% if loop.index != 1 %}, {% endif %}{{ column }}{% endfor %}){% endif %}{% if pub_table['where'] %} WHERE ({{pub_table['where']}}){% endif %}{% 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['table_name'] or pub_table }}{% if pub_table['columns'] %} ({% for column in pub_table['columns'] %}{% if loop.index != 1 %}, {% endif %}{{ column }}{% endfor %}){% endif %}{% if pub_table['where'] %} WHERE ({{pub_table['where']}}){% endif %}{% endfor %};
|
||||
|
||||
{% endif %}
|
||||
|
||||
{### Alter add publication schema ###}
|
||||
{% if add_schema %}
|
||||
ALTER PUBLICATION {{ conn|qtIdent(o_data.name) }}
|
||||
ADD TABLES IN SCHEMA {% for pub_schema in add_schema_data %}{% if loop.index != 1 %}, {% endif %}{{ pub_schema }}{% 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 %}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
SELECT COUNT(*)
|
||||
FROM pg_catalog.pg_publication c
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{% if data.evnt_delete or data.evnt_update or data.evnt_truncate %}
|
||||
{% set add_comma_after_insert = 'insert' %}
|
||||
{% endif %}
|
||||
{% if data.evnt_delete or data.evnt_truncate%}
|
||||
{% set add_comma_after_update = 'update' %}
|
||||
{% endif %}
|
||||
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{% endif %}');
|
||||
{% endif %}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{# ============= Get the publication name using oid ============= #}
|
||||
{% if pbid %}
|
||||
SELECT pubname FROM pg_catalog.pg_publication WHERE oid = {{pbid}}::oid;
|
||||
{% endif %}
|
||||
{# ============= Drop the publication ============= #}
|
||||
{% if pname %}
|
||||
DROP PUBLICATION IF EXISTS {{ conn|qtIdent(pname) }}{% if cascade %} CASCADE{% endif%};
|
||||
{% endif %}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
SELECT cl.oid AS oid,
|
||||
pg_catalog.quote_ident(pgb_table.schemaname)||'.'||pg_catalog.quote_ident(pgb_table.tablename) AS pubtable
|
||||
FROM pg_catalog.pg_publication_tables pgb_table
|
||||
LEFT JOIN pg_catalog.pg_class cl ON pgb_table.tablename = cl.relname
|
||||
WHERE pubname = '{{ pname }}' AND pgb_table.schemaname NOT LIKE 'pgagent';
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
SELECT
|
||||
pg_catalog.quote_ident(attname) as column
|
||||
FROM
|
||||
pg_attribute
|
||||
WHERE
|
||||
attrelid = '{{ tid }}' :: regclass
|
||||
and attstattarget =-1;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
SELECT
|
||||
pg_catalog.quote_ident(c.table_schema)|| '.' || pg_catalog.quote_ident(c.table_name) AS table,
|
||||
(
|
||||
pg_catalog.quote_ident(c.table_schema)|| '.' || pg_catalog.quote_ident(c.table_name)
|
||||
):: regclass :: oid as tid
|
||||
FROM
|
||||
information_schema.tables c
|
||||
WHERE
|
||||
c.table_type = 'BASE TABLE'
|
||||
AND c.table_schema NOT LIKE 'pg\_%'
|
||||
AND c.table_schema NOT LIKE 'pgagent'
|
||||
AND c.table_schema NOT LIKE 'sys'
|
||||
AND c.table_schema NOT IN ('information_schema')
|
||||
ORDER BY
|
||||
1;
|
||||
+1
@@ -0,0 +1 @@
|
||||
SELECT oid, pubname AS name FROM pg_catalog.pg_publication WHERE pubname = '{{ pubname }}';
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
SELECT pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(cls.relname) AS table_name
|
||||
FROM pg_publication_rel prel
|
||||
JOIN pg_class cls ON cls.oid = prel.prrelid
|
||||
JOIN pg_catalog.pg_namespace n ON cls.relnamespace = n.oid WHERE prel.prpubid = {{pbid}} :: oid;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
SELECT oid , pubname AS name
|
||||
FROM pg_catalog.pg_publication
|
||||
{% if schema_diff %}
|
||||
WHERE CASE WHEN (SELECT COUNT(*) FROM pg_catalog.pg_depend
|
||||
WHERE objid = oid AND deptype = 'e') > 0 THEN FALSE ELSE TRUE END
|
||||
{% endif %}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
SELECT c.oid AS oid, c.pubname AS name,
|
||||
pubinsert AS evnt_insert, pubupdate AS evnt_update, pubdelete AS evnt_delete,
|
||||
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 %}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
{% 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 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 %}
|
||||
|
||||
|
||||
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
select nspname from pg_catalog.pg_namespace c WHERE
|
||||
c.nspname NOT LIKE 'pg\_%'
|
||||
AND c.nspname NOT IN ('information_schema')
|
||||
ORDER BY
|
||||
1;
|
||||
+33
-33
@@ -11,7 +11,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": true,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -34,7 +34,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": ""
|
||||
@@ -58,7 +58,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": "PLACE_HOLDER"
|
||||
@@ -83,7 +83,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "PLACE_HOLDER"
|
||||
@@ -108,7 +108,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": ""
|
||||
@@ -133,7 +133,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": ""
|
||||
@@ -159,7 +159,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": ""
|
||||
@@ -185,7 +185,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "PLACE_HOLDER"
|
||||
@@ -210,7 +210,7 @@
|
||||
"evnt_update": true,
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": true,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -231,7 +231,7 @@
|
||||
"evnt_update": true,
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": true,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -256,7 +256,7 @@
|
||||
"evnt_update": true,
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": true,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -439,7 +439,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": "",
|
||||
@@ -464,7 +464,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -488,7 +488,7 @@
|
||||
"evnt_delete": "PLACE_HOLDER",
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -512,7 +512,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -539,7 +539,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": ""
|
||||
@@ -563,7 +563,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -588,7 +588,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -613,7 +613,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -638,7 +638,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -665,7 +665,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -690,7 +690,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -715,7 +715,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -740,7 +740,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -765,7 +765,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -790,7 +790,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -815,7 +815,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "PLACE_HOLDER",
|
||||
@@ -841,7 +841,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -866,7 +866,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -891,7 +891,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "PLACE_HOLDER",
|
||||
"pubschema": "",
|
||||
@@ -917,7 +917,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": "",
|
||||
@@ -943,7 +943,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": "PLACE_HOLDER",
|
||||
@@ -969,7 +969,7 @@
|
||||
"evnt_delete": false,
|
||||
"evnt_truncate": false,
|
||||
"publish_via_partition_root": false,
|
||||
"pubowner": "postgres",
|
||||
"pubowner": "PLACE_HOLDER",
|
||||
"all_table": false,
|
||||
"pubtable": "",
|
||||
"pubschema": "PLACE_HOLDER",
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ class PublicationsAddTestCase(BaseTestGenerator):
|
||||
self.server_id = schema_info["server_id"]
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
self.server_version = schema_info["server_version"]
|
||||
if self.server_version < 99999:
|
||||
|
||||
+2
@@ -35,6 +35,8 @@ class PublicationUpdateTestCase(BaseTestGenerator):
|
||||
self.server_id = schema_info["server_id"]
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.server_version = schema_info["server_version"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
if self.server_version < 99999:
|
||||
self.skipTest(
|
||||
"Logical replication is not supported "
|
||||
|
||||
+2
@@ -30,6 +30,8 @@ class PublicationUpdateAddSchemaTestCase(BaseTestGenerator):
|
||||
self.server_id = schema_info["server_id"]
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.server_version = schema_info["server_version"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
if self.server_version < 99999:
|
||||
self.skipTest(
|
||||
"Logical replication is not supported "
|
||||
|
||||
+2
@@ -31,6 +31,8 @@ class PublicationUpdateAddTableTestCase(BaseTestGenerator):
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.server_version = schema_info["server_version"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
if self.server_version < 99999:
|
||||
self.skipTest(
|
||||
"Logical replication is not supported "
|
||||
|
||||
+2
@@ -32,6 +32,8 @@ class PublicationUpdateDropSchemaTestCase(BaseTestGenerator):
|
||||
self.server_id = schema_info["server_id"]
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.server_version = schema_info["server_version"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
if self.server_version < 99999:
|
||||
self.skipTest(
|
||||
"Logical replication is not supported "
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ class PublicationUpdateDropTableTestCase(BaseTestGenerator):
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.server_version = schema_info["server_version"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
if self.server_version < 99999:
|
||||
self.skipTest(
|
||||
|
||||
+2
@@ -32,6 +32,8 @@ class PublicationUpdateSchemaUpdateTestCase(BaseTestGenerator):
|
||||
self.server_id = schema_info["server_id"]
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.server_version = schema_info["server_version"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
if self.server_version < 99999:
|
||||
self.skipTest(
|
||||
"Logical replication is not supported "
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ class PublicationUpdateTableUpdateTestCase(BaseTestGenerator):
|
||||
self.db_id = schema_info["db_id"]
|
||||
self.server_version = schema_info["server_version"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
self.test_data['pubowner'] = self.server['username']
|
||||
|
||||
if self.server_version < 99999:
|
||||
self.skipTest(
|
||||
|
||||
Reference in new issue
Block a user