Fixed the query generated when creating subscription where copy_data parameter was missing. #6817
parent
01d1e6f706
commit
6062084128
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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']]
|
||||
|
|
|
|||
|
|
@ -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?'),
|
||||
|
|
|
|||
|
|
@ -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}}');
|
||||
|
|
|
|||
|
|
@ -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}});
|
||||
|
|
|
|||
|
|
@ -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}}');
|
||||
|
|
|
|||
|
|
@ -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 %});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue