Fixed the query generated when creating subscription where copy_data parameter was missing. #6817

pull/6929/head
Anil Sahoo 2023-11-03 14:58:48 +05:30 committed by GitHub
parent 01d1e6f706
commit 6062084128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 51 additions and 33 deletions

View File

@ -414,7 +414,7 @@ class PublicationView(PGChildNodeView, SchemaDiffObjectCompare):
pub_table.append(table['table_name'])
res['rows'][0]['pubtable'] = pub_table
res['rows'][0]['pubtable_names'] = pub_table_names_list
res['rows'][0]['pubtable_names'] = ', '.join(pub_table_names_list)
return True, res['rows'][0]

View File

@ -161,7 +161,7 @@ export default class PublicationSchema extends BaseUISchema {
name: undefined,
pubowner: (node_info) ? node_info['node_info']?.user.name: undefined,
pubtable: [],
pubtable_names: [],
pubtable_names: '',
pubschema: undefined,
all_table: false,
evnt_insert:true,
@ -282,15 +282,7 @@ export default class PublicationSchema extends BaseUISchema {
min_version: 150000,
},
{
id: 'pubtable_names', label: gettext('Tables'), cell: 'string',
type: (state)=>{
let table= (!_.isUndefined(state?.pubtable_names) && state?.pubtable_names.length > 0) ? state?.pubtable_names : [];
return {
type: 'select',
options: table,
controlProps: { allowClear: true, multiple: true, creatable: true },
};
},
id: 'pubtable_names', label: gettext('Tables'), type: 'text',
group: gettext('Tables'), mode: ['properties'],
deps: ['all_table'], disabled: obj.isAllTable,
},

View File

@ -187,6 +187,11 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
't': True,
'f': False
}
two_phase_mapping = {
'p': True,
'e': True,
'd': False
}
parent_ids = [
{'type': 'int', 'id': 'gid'},
@ -377,6 +382,10 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
if len(res['rows']) == 0:
return False, gone(self._NOT_FOUND_PUB_INFORMATION)
if self.manager.version >= 150000:
res['rows'][0]['two_phase'] = \
self.two_phase_mapping[res['rows'][0]['two_phase']]
if self.manager.version >= 160000:
res['rows'][0]['streaming'] = \
self.streaming_mapping[res['rows'][0]['streaming']]
@ -478,7 +487,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
sql = render_template(
"/".join([self.template_path, 'get_position.sql']),
conn=self.conn, subname=data['name']
conn=self.conn, subname=data['name'], did=did
)
status, r_set = self.conn.execute_dict(sql)
@ -787,6 +796,10 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
else:
old_data['connect'] = False
if self.manager.version >= 150000:
old_data['two_phase'] = \
self.two_phase_mapping[old_data['two_phase']]
if self.manager.version >= 160000:
old_data['streaming'] = \
self.streaming_mapping[old_data['streaming']]

View File

@ -75,6 +75,8 @@ export default class SubscriptionSchema extends BaseUISchema{
if (host == this.node_info['node_info'].host && port == this.node_info['node_info'].port){
state.create_slot = false;
return true;
} else {
state.create_slot = true;
}
return false;
}
@ -96,7 +98,6 @@ export default class SubscriptionSchema extends BaseUISchema{
}
isRefresh(state){
if (!state.refresh_pub || _.isUndefined(state.refresh_pub)){
state.copy_data_after_refresh = false;
return true;
}
return false;
@ -332,7 +333,10 @@ export default class SubscriptionSchema extends BaseUISchema{
if (state.enabled)
return false;
state.refresh_pub = false;
state.copy_data_after_refresh = false;
return true;
}, depChange: (state)=>{
state.copy_data_after_refresh = state.refresh_pub ? state.copy_data_after_refresh ? false : true : false;
},
},{
id: 'connect', label: gettext('Connect?'),

View File

@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
{% endif %}
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 %}
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 %}
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
{% 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}}');

View File

@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
{% endif %}
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 %}
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 %}
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
{% 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}});

View File

@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
{% endif %}
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 %}
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 %}
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
{% 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}}');

View File

@ -19,6 +19,6 @@ CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %}
{% endif %}
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 %}
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 %}
{% if data.create_slot is defined %}create_slot = {{ data.create_slot|lower }}{% if add_semicolon_after_create_slot == 'create_slot' %}, {% endif %}{% endif %}
{% 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 %});

View File

@ -1 +1 @@
SELECT oid, subname AS name FROM pg_catalog.pg_subscription WHERE subname = '{{ subname }}';
SELECT oid, subname AS name FROM pg_catalog.pg_subscription WHERE subname = '{{ subname }}' and subdbid={{did}} :: oid;

View File

@ -1,4 +1,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
PUBLICATION test_pub
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True');
WITH (connect = false, enabled = false, copy_data = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True');

View File

@ -36,11 +36,13 @@
"name": "Alter parameters of subscription",
"endpoint": "NODE-subscription.obj_id",
"sql_endpoint": "NODE-subscription.sql_id",
"msql_endpoint": "NODE-subscription.msql_id",
"data": {
"binary": false,
"streaming": false
},
"expected_sql_file": "alter_parameters.sql"
"expected_sql_file": "alter_parameters.sql",
"expected_msql_file": "alter_parameters_msql.sql"
},
{
"type": "delete",

View File

@ -5,4 +5,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
PUBLICATION test_pub
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off', binary = false, streaming = 'False', two_phase = p, disable_on_error = false);
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off', binary = false, streaming = 'False', two_phase = true, disable_on_error = false);

View File

@ -5,4 +5,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
PUBLICATION test_pub
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True', two_phase = p, disable_on_error = true);
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);

View File

@ -1,4 +1,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
PUBLICATION test_pub
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);
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);

View File

@ -37,6 +37,7 @@
"name": "Alter parameters of subscription",
"endpoint": "NODE-subscription.obj_id",
"sql_endpoint": "NODE-subscription.sql_id",
"msql_endpoint": "NODE-subscription.msql_id",
"data": {
"sync": "off",
"binary": false,

View File

@ -5,4 +5,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
PUBLICATION test_pub
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off', binary = false, streaming = 'False', two_phase = p, disable_on_error = false, run_as_owner = true, password_required = true, origin = 'none');
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off', binary = false, streaming = 'False', two_phase = true, disable_on_error = false, run_as_owner = true, password_required = true, origin = 'none');

View File

@ -5,4 +5,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
PUBLICATION test_pub
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply', binary = true, streaming = 'True', two_phase = p, disable_on_error = true, run_as_owner = true, password_required = true, origin = 'any');
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');

View File

@ -1,4 +1,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5434 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
PUBLICATION test_pub
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');
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');

View File

@ -40,6 +40,7 @@
"name": "Alter parameters of subscription",
"endpoint": "NODE-subscription.obj_id",
"sql_endpoint": "NODE-subscription.sql_id",
"msql_endpoint": "NODE-subscription.msql_id",
"data": {
"sync": "off",
"binary": false,

View File

@ -3,6 +3,6 @@
-- DROP SUBSCRIPTION IF EXISTS test_alter_subscription;
CREATE SUBSCRIPTION test_alter_subscription
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb'
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb connect_timeout=10 sslmode=prefer'
PUBLICATION sample__1
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'remote_apply');

View File

@ -1,2 +1,2 @@
ALTER SUBSCRIPTION test_alter_subscription
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb';
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb connect_timeout=10 sslmode=prefer';

View File

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

View File

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

View File

@ -3,6 +3,6 @@
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres'
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres connect_timeout=10 sslmode=prefer'
PUBLICATION sample__1
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');

View File

@ -1,4 +1,4 @@
CREATE SUBSCRIPTION test_create_subscription
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres password=xxxxxx'
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres connect_timeout=10 password=xxxxxx sslmode=prefer'
PUBLICATION sample__1
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
WITH (connect = false, enabled = false, copy_data = false, create_slot = false, slot_name = None, synchronous_commit = 'off');

View File

@ -21,6 +21,8 @@
"port": 5432,
"password": "edb",
"sync": "off",
"connect_timeout": 10,
"sslmode": "prefer",
"pub": ["sample__1"]
},
"expected_sql_file": "create_subscription.sql",
@ -31,6 +33,7 @@
"name": "Alter Subscription",
"endpoint": "NODE-subscription.obj_id",
"sql_endpoint": "NODE-subscription.sql_id",
"msql_endpoint": "NODE-subscription.msql_id",
"data": {
"name": "test_alter_subscription"
},
@ -42,6 +45,7 @@
"name": "Alter sync of subscription",
"endpoint": "NODE-subscription.obj_id",
"sql_endpoint": "NODE-subscription.sql_id",
"msql_endpoint": "NODE-subscription.msql_id",
"data": {
"sync": "remote_apply"
},
@ -54,6 +58,7 @@
"name": "Alter maintainance DB in connection string of subscription",
"endpoint": "NODE-subscription.obj_id",
"sql_endpoint": "NODE-subscription.sql_id",
"msql_endpoint": "NODE-subscription.msql_id",
"data": {
"db": "edb"
},