Skip to content

Commit b798a06

Browse files
committed
Fixed CREATE SUBSCRIPTION's generated query for copy_data parameter when it is set to false. #6817
1 parent 8997f61 commit b798a06

File tree

19 files changed

+26
-17
lines changed

19 files changed

+26
-17
lines changed

web/pgadmin/browser/server_groups/servers/databases/subscriptions/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def create(self, gid, sid, did):
478478

479479
sql = render_template(
480480
"/".join([self.template_path, 'get_position.sql']),
481-
conn=self.conn, subname=data['name']
481+
conn=self.conn, subname=data['name'], did=did
482482
)
483483

484484
status, r_set = self.conn.execute_dict(sql)

web/pgadmin/browser/server_groups/servers/databases/subscriptions/templates/subscriptions/sql/14_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
1919
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
2020
{% endif %}
2121

22-
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
22+
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data is defined %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
2323
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
2424
{% if data.slot_name is defined and data.slot_name != ''%}slot_name = {{ data.slot_name }}{% if add_semicolon_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync %}synchronous_commit = '{{ data.sync }}', {% endif %}binary = {{ data.binary|lower}}, streaming = '{{ data.streaming}}');

web/pgadmin/browser/server_groups/servers/databases/subscriptions/templates/subscriptions/sql/15_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
1919
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
2020
{% endif %}
2121

22-
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
22+
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data is defined %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
2323
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
2424
{% if data.slot_name is defined and data.slot_name != ''%}slot_name = {{ data.slot_name }}{% if add_semicolon_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync %}synchronous_commit = '{{ data.sync }}', {% endif %}binary = {{ data.binary|lower}}, streaming = '{{ data.streaming}}', two_phase = {{ data.two_phase|lower}}, disable_on_error = {{ data.disable_on_error|lower}});

web/pgadmin/browser/server_groups/servers/databases/subscriptions/templates/subscriptions/sql/16_plus/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
1919
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
2020
{% endif %}
2121

22-
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
22+
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data is defined %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
2323
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
2424
{% if data.slot_name is defined and data.slot_name != ''%}slot_name = {{ data.slot_name }}{% if add_semicolon_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync %}synchronous_commit = '{{ data.sync }}', {% endif %}binary = {{ data.binary|lower}}, streaming = '{{ data.streaming}}', two_phase = {{ data.two_phase|lower}}, disable_on_error = {{ data.disable_on_error|lower}}, run_as_owner = {{ data.run_as_owner|lower}}, password_required = {{ data.password_required|lower}}, origin = '{{ data.origin}}');

web/pgadmin/browser/server_groups/servers/databases/subscriptions/templates/subscriptions/sql/default/create.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
1919
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
2020
{% endif %}
2121

22-
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
22+
WITH ({% if data.connect is defined %}connect = {{ data.connect|lower}}, {% endif %}enabled = {{ data.enabled|lower}}, {% if data.copy_data is defined %}copy_data = {{ data.copy_data|lower}}{% if add_semicolon_after_copy_data == 'copy_data' %}, {% endif %}{% endif %}
2323
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
2424
{% if data.slot_name is defined and data.slot_name != ''%}slot_name = {{ data.slot_name }}{% if add_semicolon_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync %}synchronous_commit = '{{ data.sync }}'{% endif %});
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SELECT oid, subname AS name FROM pg_catalog.pg_subscription WHERE subname = '{{ subname }}';
1+
SELECT oid, subname AS name FROM pg_catalog.pg_subscription WHERE subname = '{{ subname }}' and subdbid={{did}} :: oid;
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
CREATE SUBSCRIPTION test_create_subscription
22
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
33
PUBLICATION test_pub
4-
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True');
4+
WITH (connect = false, enabled = false, copy_data = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True');

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/14_plus/test.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
"name": "Alter parameters of subscription",
3737
"endpoint": "NODE-subscription.obj_id",
3838
"sql_endpoint": "NODE-subscription.sql_id",
39+
"msql_endpoint": "NODE-subscription.msql_id",
3940
"data": {
4041
"binary": false,
4142
"streaming": false
4243
},
43-
"expected_sql_file": "alter_parameters.sql"
44+
"expected_sql_file": "alter_parameters.sql",
45+
"expected_msql_file": "alter_parameters_msql.sql"
4446
},
4547
{
4648
"type": "delete",
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
CREATE SUBSCRIPTION test_create_subscription
22
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
33
PUBLICATION test_pub
4-
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True', two_phase = true, disable_on_error = true);
4+
WITH (connect = false, enabled = false, copy_data = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True', two_phase = true, disable_on_error = true);

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/15_plus/test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"name": "Alter parameters of subscription",
3838
"endpoint": "NODE-subscription.obj_id",
3939
"sql_endpoint": "NODE-subscription.sql_id",
40+
"msql_endpoint": "NODE-subscription.msql_id",
4041
"data": {
4142
"sync": "off",
4243
"binary": false,
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
CREATE SUBSCRIPTION test_create_subscription
22
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
33
PUBLICATION test_pub
4-
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True', two_phase = true, disable_on_error = true, run_as_owner = true, password_required = true, origin = 'any');
4+
WITH (connect = false, enabled = false, copy_data = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True', two_phase = true, disable_on_error = true, run_as_owner = true, password_required = true, origin = 'any');

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/16_plus/test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"name": "Alter parameters of subscription",
4141
"endpoint": "NODE-subscription.obj_id",
4242
"sql_endpoint": "NODE-subscription.sql_id",
43+
"msql_endpoint": "NODE-subscription.msql_id",
4344
"data": {
4445
"sync": "off",
4546
"binary": false,

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_maintenance_db.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
-- DROP SUBSCRIPTION IF EXISTS test_alter_subscription;
44

55
CREATE SUBSCRIPTION test_alter_subscription
6-
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb'
6+
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb connect_timeout=10 sslmode=prefer'
77
PUBLICATION sample__1
88
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply');
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ALTER SUBSCRIPTION test_alter_subscription
2-
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb';
2+
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb connect_timeout=10 sslmode=prefer';

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_subscription.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
-- DROP SUBSCRIPTION IF EXISTS test_alter_subscription;
44

55
CREATE SUBSCRIPTION test_alter_subscription
6-
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres'
6+
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
77
PUBLICATION sample__1
88
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/alter_sync.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
-- DROP SUBSCRIPTION IF EXISTS test_alter_subscription;
44

55
CREATE SUBSCRIPTION test_alter_subscription
6-
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres'
6+
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
77
PUBLICATION sample__1
88
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply');

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/create_subscription.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
44

55
CREATE SUBSCRIPTION test_create_subscription
6-
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres'
6+
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
77
PUBLICATION sample__1
88
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
CREATE SUBSCRIPTION test_create_subscription
2-
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres password=xxxxxx'
2+
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
33
PUBLICATION sample__1
4-
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
4+
WITH (connect = false, enabled = false, copy_data = false, create_slot = false, slot_name = None, synchronous_commit = 'off');

web/pgadmin/browser/server_groups/servers/databases/subscriptions/tests/default/test.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"port": 5432,
2222
"password": "edb",
2323
"sync": "off",
24+
"connect_timeout": 10,
25+
"sslmode": "prefer",
2426
"pub": ["sample__1"]
2527
},
2628
"expected_sql_file": "create_subscription.sql",
@@ -31,6 +33,7 @@
3133
"name": "Alter Subscription",
3234
"endpoint": "NODE-subscription.obj_id",
3335
"sql_endpoint": "NODE-subscription.sql_id",
36+
"msql_endpoint": "NODE-subscription.msql_id",
3437
"data": {
3538
"name": "test_alter_subscription"
3639
},
@@ -42,6 +45,7 @@
4245
"name": "Alter sync of subscription",
4346
"endpoint": "NODE-subscription.obj_id",
4447
"sql_endpoint": "NODE-subscription.sql_id",
48+
"msql_endpoint": "NODE-subscription.msql_id",
4549
"data": {
4650
"sync": "remote_apply"
4751
},
@@ -54,6 +58,7 @@
5458
"name": "Alter maintainance DB in connection string of subscription",
5559
"endpoint": "NODE-subscription.obj_id",
5660
"sql_endpoint": "NODE-subscription.sql_id",
61+
"msql_endpoint": "NODE-subscription.msql_id",
5762
"data": {
5863
"db": "edb"
5964
},

0 commit comments

Comments
 (0)