mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added all the new options of the 'WITH' clause in the subscription dialog. #4805
This commit is contained in:
@@ -181,6 +181,13 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
node_type = blueprint.node_type
|
||||
BASE_TEMPLATE_PATH = "subscriptions/sql/#{0}#"
|
||||
|
||||
# This mapping will be used PostgresSQL 16 above
|
||||
streaming_mapping = {
|
||||
'p': 'parallel',
|
||||
't': True,
|
||||
'f': False
|
||||
}
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
@@ -370,6 +377,10 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(self._NOT_FOUND_PUB_INFORMATION)
|
||||
|
||||
if self.manager.version >= 160000:
|
||||
res['rows'][0]['streaming'] = \
|
||||
self.streaming_mapping[res['rows'][0]['streaming']]
|
||||
|
||||
return True, res['rows'][0]
|
||||
|
||||
@check_precondition
|
||||
@@ -633,6 +644,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return gone(self._NOT_FOUND_PUB_INFORMATION)
|
||||
|
||||
old_data = res['rows'][0]
|
||||
|
||||
data, old_data = self.get_required_details(data, old_data)
|
||||
|
||||
if 'slot_name' in data and data['slot_name'] == '':
|
||||
@@ -775,6 +787,10 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
else:
|
||||
old_data['connect'] = False
|
||||
|
||||
if self.manager.version >= 160000:
|
||||
old_data['streaming'] = \
|
||||
self.streaming_mapping[old_data['streaming']]
|
||||
|
||||
sql = render_template("/".join([self.template_path,
|
||||
self._CREATE_SQL]),
|
||||
data=old_data, conn=self.conn, dummy=True)
|
||||
|
||||
@@ -23,6 +23,13 @@ export default class SubscriptionSchema extends BaseUISchema{
|
||||
create_slot: true,
|
||||
copy_data:true,
|
||||
connect:true,
|
||||
binary:false,
|
||||
two_phase:false,
|
||||
disable_on_error:false,
|
||||
streaming:false,
|
||||
password_required:true,
|
||||
run_as_owner:false,
|
||||
origin:'any',
|
||||
copy_data_after_refresh:false,
|
||||
sync:'off',
|
||||
refresh_pub: false,
|
||||
@@ -45,6 +52,8 @@ export default class SubscriptionSchema extends BaseUISchema{
|
||||
...fieldOptions,
|
||||
};
|
||||
this.node_info = node_info;
|
||||
this.version=!_.isUndefined(this.node_info['node_info']) && !_.isUndefined(this.node_info['node_info'].version) && this.node_info['node_info'].version;
|
||||
|
||||
}
|
||||
get idAttribute() {
|
||||
return 'oid';
|
||||
@@ -357,6 +366,94 @@ export default class SubscriptionSchema extends BaseUISchema{
|
||||
{label: 'off', value: 'off'},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'streaming',
|
||||
label: gettext('Streaming'),
|
||||
cell: 'text',
|
||||
group: gettext('With'), mode: ['create', 'edit', 'properties'],
|
||||
type: ()=>{
|
||||
let options = [
|
||||
{
|
||||
'label': gettext('On'),
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
'label': gettext('Off'),
|
||||
value: false,
|
||||
}
|
||||
];
|
||||
|
||||
if (obj.version >= 160000) {
|
||||
options.push({
|
||||
'label': gettext('Parallel'),
|
||||
value: 'parallel',
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'toggle',
|
||||
options: options,
|
||||
};
|
||||
},
|
||||
min_version: 140000,
|
||||
helpMessage: gettext('Specifies whether to enable streaming of in-progress transactions for this subscription. By default, all transactions are fully decoded on the publisher and only then sent to the subscriber as a whole.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
},
|
||||
{
|
||||
id: 'binary', label: gettext('Binary?'),
|
||||
type: 'switch', mode: ['create', 'edit', 'properties'],
|
||||
group: gettext('With'),
|
||||
min_version: 140000,
|
||||
helpMessage: gettext('Specifies whether the subscription will request the publisher to send the data in binary format (as opposed to text). Even when this option is enabled, only data types having binary send and receive functions will be transferred in binary.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
},
|
||||
{
|
||||
id: 'two_phase', label: gettext('Two phase?'),
|
||||
type: 'switch', mode: ['create', 'properties'],
|
||||
group: gettext('With'),
|
||||
min_version: 150000,
|
||||
helpMessage: gettext('Specifies whether two-phase commit is enabled for this subscription.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
},
|
||||
{
|
||||
id: 'disable_on_error', label: gettext('Disable on error?'),
|
||||
type: 'switch', mode: ['create', 'edit', 'properties'],
|
||||
group: gettext('With'),
|
||||
min_version: 150000,
|
||||
helpMessage: gettext('Specifies whether the subscription should be automatically disabled if any errors are detected by subscription workers during data replication from the publisher.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
},
|
||||
{
|
||||
id: 'run_as_owner', label: gettext('Run as owner?'),
|
||||
type: 'switch', mode: ['create', 'properties'],
|
||||
group: gettext('With'),
|
||||
min_version: 160000,
|
||||
helpMessage: gettext('If true, all replication actions are performed as the subscription owner. If false, replication workers will perform actions on each table as the owner of that table.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
},
|
||||
{
|
||||
id: 'password_required', label: gettext('Password required?'),
|
||||
type: 'switch', mode: ['create', 'edit', 'properties'],
|
||||
group: gettext('With'),
|
||||
min_version: 160000,
|
||||
helpMessage: gettext('Specifies whether connections to the publisher made as a result of this subscription must use password authentication. Only superusers can set this value to false.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
},
|
||||
{
|
||||
id: 'origin', label: gettext('Origin'),
|
||||
type: 'select', mode: ['create', 'edit', 'properties'],
|
||||
group: gettext('With'),
|
||||
controlProps: {
|
||||
allowClear: false,
|
||||
},
|
||||
options: [
|
||||
{label: gettext('none'), value: 'none'},
|
||||
{label: gettext('any'), value: 'any'},
|
||||
],
|
||||
min_version: 160000,
|
||||
helpMessage: gettext('Specifies whether the subscription will request the publisher to only send changes that do not have an origin or send changes regardless of origin. Setting origin to none means that the subscription will request the publisher to only send changes that do not have an origin. Setting origin to any means that the publisher sends changes regardless of their origin.'),
|
||||
helpMessageMode: ['edit', 'create'],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{% if data.copy_data is defined or data.create_slot is defined or data.slot_name is defined or data.sync is defined %}
|
||||
{% set add_semicolon_after_enabled = 'enabled' %}
|
||||
{% endif %}
|
||||
{% if data.create_slot is defined or data.slot_name is defined %}
|
||||
{% set add_semicolon_after_copy_data = 'copy_data' %}
|
||||
{% endif %}
|
||||
{% if data.slot_name is defined or data.sync is defined %}
|
||||
{% set add_semicolon_after_create_slot = 'create_slot' %}
|
||||
{% endif %}
|
||||
{% if data.sync is defined %}
|
||||
{% set add_semicolon_after_slot_name = 'slot_name' %}
|
||||
{% endif %}
|
||||
|
||||
CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.host or data.port or data.username or data.password or data.db or data.connect_timeout or data.passfile or data.sslmode or data.sslcompression or data.sslcert or data.sslkey or data.sslrootcert or data.sslcrl%}
|
||||
CONNECTION '{% if data.host %}host={{data.host}}{% endif %}{% if data.port %} port={{ data.port }}{% endif %}{% if data.username %} user={{ data.username }}{% endif %}{% if data.db %} dbname={{ data.db }}{% endif %}{% if data.connect_timeout %} connect_timeout={{ data.connect_timeout }}{% endif %}{% if data.passfile %} passfile={{ data.passfile }}{% endif %}{% if data.password %} {% if dummy %}password=xxxxxx{% else %}password={{ data.password}}{% endif %}{% endif %}{% if data.sslmode %} sslmode={{ data.sslmode }}{% endif %}{% if data.sslcompression %} sslcompression={{ data.sslcompression }}{% endif %}{% if data.sslcert %} sslcert={{ data.sslcert }}{% endif %}{% if data.sslkey %} sslkey={{ data.sslkey }}{% endif %}{% if data.sslrootcert %} sslrootcert={{ data.sslrootcert }}{% endif %}{% if data.sslcrl %} sslcrl={{ data.sslcrl }}{% endif %}'
|
||||
{% endif %}
|
||||
{% if data.pub %}
|
||||
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 %}
|
||||
{% 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}}');
|
||||
@@ -0,0 +1,29 @@
|
||||
SELECT sub.oid as oid,
|
||||
subname as name,
|
||||
subpublications as pub,
|
||||
subpublications as proppub,
|
||||
sub.subsynccommit as sync,
|
||||
pga.rolname as subowner,
|
||||
subslotname as slot_name,
|
||||
subenabled as enabled,
|
||||
subbinary as binary,
|
||||
substream as streaming,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,' port',1), '=',2) as host,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'port=',2), ' ',1) as port,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'user=',2), ' ',1) as username,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'dbname=',2), ' ',1) as db,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'connect_timeout=',2), ' ',1) as connect_timeout,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'passfile=',2), ' ',1) as passfile,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslmode=',2), ' ',1) as sslmode,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcompression=',2), ' ',1) as sslcompression,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcert=',2), ' ',1) as sslcert,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslkey=',2), ' ',1) as sslkey,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslrootcert=',2), ' ',1) as sslrootcert,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcrl=',2), ' ',1) as sslcrl
|
||||
FROM pg_catalog.pg_subscription sub join pg_catalog.pg_roles pga on sub.subowner= pga.oid
|
||||
WHERE
|
||||
{% if subid %}
|
||||
sub.oid = {{ subid }};
|
||||
{% else %}
|
||||
sub.subdbid = {{ did }};
|
||||
{% endif %}
|
||||
@@ -0,0 +1,65 @@
|
||||
{% if data.sync is defined %}
|
||||
{% set add_comma_after_slot_name = 'slot_name' %}
|
||||
{% endif %}
|
||||
{% if data.binary is defined or data.streaming is defined %}
|
||||
{% set add_comma_after_sync = 'sync' %}
|
||||
{% endif %}
|
||||
{% if data.streaming is defined %}
|
||||
{% set add_comma_after_binary = 'binary' %}
|
||||
{% endif %}
|
||||
{#####################################################}
|
||||
{## Change owner of subscription ##}
|
||||
{#####################################################}
|
||||
{% if data.subowner and data.subowner != o_data.subowner %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
OWNER TO {{ data.subowner }};
|
||||
|
||||
{% endif %}
|
||||
{### Disable subscription ###}
|
||||
{% if data.enabled is defined and data.enabled != o_data.enabled %}
|
||||
{% if not data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }} DISABLE;
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Alter parameters of subscription ###}
|
||||
{% if (data.slot_name is defined and data.slot_name != o_data.slot_name) or (data.sync is defined and data.sync != o_data.sync) or (data.binary is defined and data.binary!=o_data.binary) or (data.streaming is defined and data.streaming!=o_data.streaming) %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET ({% if data.slot_name is defined and data.slot_name != o_data.slot_name %}slot_name = {{ data.slot_name }}{% if add_comma_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync is defined and data.sync != o_data.sync %}synchronous_commit = '{{ data.sync }}'{% if add_comma_after_sync == 'sync' %}, {% endif %}{% endif %}{% if data.binary is defined and data.binary!=o_data.binary %}binary = {{ data.binary|lower}}{% if add_comma_after_binary == 'binary' %}, {% endif %}{% endif %}{% if data.streaming is defined and data.streaming!=o_data.streaming %}streaming = '{{ data.streaming}}'{% endif %});
|
||||
|
||||
{% endif %}
|
||||
{### Enable subscription ###}
|
||||
{% if data.enabled is defined and data.enabled != o_data.enabled %}
|
||||
{% if data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }} ENABLE;
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Refresh publication ###}
|
||||
{% if data.refresh_pub %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
REFRESH PUBLICATION{% if not data.copy_data_after_refresh %} WITH (copy_data = false){% else %} WITH (copy_data = true){% endif %};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication of subscription ###}
|
||||
{% if data.pub%}
|
||||
{% if data.pub and not data.refresh_pub and not data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %} WITH (refresh = false);
|
||||
{% else %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %};
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Alter subscription connection info ###}
|
||||
{% if data.host or data.port or data.username or data.db or data.connect_timeout or data.passfile or data.sslmode or data.sslcompression or data.sslcert or data.sslkey or data.sslrootcert or data.sslcrl %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
CONNECTION 'host={{ o_data.host}} port={{ o_data.port }} user={{ o_data.username }} dbname={{ o_data.db }} connect_timeout={{ o_data.connect_timeout }} {% if data.passfile %} passfile={{ o_data.passfile }}{% endif %} sslmode={{ o_data.sslmode }}{% if data.sslcompression %} sslcompression={{ data.sslcompression }}{% endif %}{% if data.sslcert %} sslcert={{ data.sslcert }}{% endif %}{% if data.sslkey %} sslkey={{ data.sslkey }}{% endif %}{% if data.sslrootcert %} sslrootcert={{ data.sslrootcert }}{% endif %}{% if data.sslcrl %} sslcrl={{ data.sslcrl }}{% endif %}';
|
||||
{% endif %}
|
||||
{### Alter subscription name ###}
|
||||
{% if data.name and data.name != o_data.name %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
|
||||
{% endif %}
|
||||
@@ -0,0 +1,24 @@
|
||||
{% if data.copy_data is defined or data.create_slot is defined or data.slot_name is defined or data.sync is defined %}
|
||||
{% set add_semicolon_after_enabled = 'enabled' %}
|
||||
{% endif %}
|
||||
{% if data.create_slot is defined or data.slot_name is defined %}
|
||||
{% set add_semicolon_after_copy_data = 'copy_data' %}
|
||||
{% endif %}
|
||||
{% if data.slot_name is defined or data.sync is defined %}
|
||||
{% set add_semicolon_after_create_slot = 'create_slot' %}
|
||||
{% endif %}
|
||||
{% if data.sync is defined %}
|
||||
{% set add_semicolon_after_slot_name = 'slot_name' %}
|
||||
{% endif %}
|
||||
|
||||
CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.host or data.port or data.username or data.password or data.db or data.connect_timeout or data.passfile or data.sslmode or data.sslcompression or data.sslcert or data.sslkey or data.sslrootcert or data.sslcrl%}
|
||||
CONNECTION '{% if data.host %}host={{data.host}}{% endif %}{% if data.port %} port={{ data.port }}{% endif %}{% if data.username %} user={{ data.username }}{% endif %}{% if data.db %} dbname={{ data.db }}{% endif %}{% if data.connect_timeout %} connect_timeout={{ data.connect_timeout }}{% endif %}{% if data.passfile %} passfile={{ data.passfile }}{% endif %}{% if data.password %} {% if dummy %}password=xxxxxx{% else %}password={{ data.password}}{% endif %}{% endif %}{% if data.sslmode %} sslmode={{ data.sslmode }}{% endif %}{% if data.sslcompression %} sslcompression={{ data.sslcompression }}{% endif %}{% if data.sslcert %} sslcert={{ data.sslcert }}{% endif %}{% if data.sslkey %} sslkey={{ data.sslkey }}{% endif %}{% if data.sslrootcert %} sslrootcert={{ data.sslrootcert }}{% endif %}{% if data.sslcrl %} sslcrl={{ data.sslcrl }}{% endif %}'
|
||||
{% endif %}
|
||||
{% if data.pub %}
|
||||
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 %}
|
||||
{% 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}});
|
||||
@@ -0,0 +1,31 @@
|
||||
SELECT sub.oid as oid,
|
||||
subname as name,
|
||||
subpublications as pub,
|
||||
subpublications as proppub,
|
||||
sub.subsynccommit as sync,
|
||||
pga.rolname as subowner,
|
||||
subslotname as slot_name,
|
||||
subenabled as enabled,
|
||||
subbinary as binary,
|
||||
substream as streaming,
|
||||
subtwophasestate as two_phase,
|
||||
subdisableonerr as disable_on_error,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,' port',1), '=',2) as host,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'port=',2), ' ',1) as port,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'user=',2), ' ',1) as username,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'dbname=',2), ' ',1) as db,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'connect_timeout=',2), ' ',1) as connect_timeout,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'passfile=',2), ' ',1) as passfile,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslmode=',2), ' ',1) as sslmode,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcompression=',2), ' ',1) as sslcompression,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcert=',2), ' ',1) as sslcert,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslkey=',2), ' ',1) as sslkey,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslrootcert=',2), ' ',1) as sslrootcert,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcrl=',2), ' ',1) as sslcrl
|
||||
FROM pg_catalog.pg_subscription sub join pg_catalog.pg_roles pga on sub.subowner= pga.oid
|
||||
WHERE
|
||||
{% if subid %}
|
||||
sub.oid = {{ subid }};
|
||||
{% else %}
|
||||
sub.subdbid = {{ did }};
|
||||
{% endif %}
|
||||
@@ -0,0 +1,68 @@
|
||||
{% if data.sync is defined %}
|
||||
{% set add_comma_after_slot_name = 'slot_name' %}
|
||||
{% endif %}
|
||||
{% if data.binary is defined or data.streaming is defined or data.disable_on_error is defined %}
|
||||
{% set add_comma_after_sync = 'sync' %}
|
||||
{% endif %}
|
||||
{% if data.streaming is defined or data.disable_on_error is defined %}
|
||||
{% set add_comma_after_binary = 'binary' %}
|
||||
{% endif %}
|
||||
{% if data.disable_on_error is defined %}
|
||||
{% set add_comma_after_streaming = 'streaming' %}
|
||||
{% endif %}
|
||||
{#####################################################}
|
||||
{## Change owner of subscription ##}
|
||||
{#####################################################}
|
||||
{% if data.subowner and data.subowner != o_data.subowner %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
OWNER TO {{ data.subowner }};
|
||||
|
||||
{% endif %}
|
||||
{### Disable subscription ###}
|
||||
{% if data.enabled is defined and data.enabled != o_data.enabled %}
|
||||
{% if not data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }} DISABLE;
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Alter parameters of subscription ###}
|
||||
{% if (data.slot_name is defined and data.slot_name != o_data.slot_name) or (data.sync is defined and data.sync != o_data.sync) or (data.binary is defined and data.binary!=o_data.binary) or (data.streaming is defined and data.streaming!=o_data.streaming) or (data.disable_on_error is defined and data.disable_on_error!=o_data.disable_on_error) %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET ({% if data.slot_name is defined and data.slot_name != o_data.slot_name %}slot_name = {{ data.slot_name }}{% if add_comma_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync is defined and data.sync != o_data.sync %}synchronous_commit = '{{ data.sync }}'{% if add_comma_after_sync == 'sync' %}, {% endif %}{% endif %}{% if data.binary is defined and data.binary!=o_data.binary %}binary = {{ data.binary|lower}}{% if add_comma_after_binary == 'binary' %}, {% endif %}{% endif %}{% if data.streaming is defined and data.streaming!=o_data.streaming %}streaming = '{{ data.streaming}}'{% if add_comma_after_streaming == 'streaming' %}, {% endif %}{% endif %}{% if data.disable_on_error is defined and data.disable_on_error!=o_data.disable_on_error %}disable_on_error = {{ data.disable_on_error|lower}}{% endif %});
|
||||
|
||||
{% endif %}
|
||||
{### Enable subscription ###}
|
||||
{% if data.enabled is defined and data.enabled != o_data.enabled %}
|
||||
{% if data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }} ENABLE;
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Refresh publication ###}
|
||||
{% if data.refresh_pub %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
REFRESH PUBLICATION{% if not data.copy_data_after_refresh %} WITH (copy_data = false){% else %} WITH (copy_data = true){% endif %};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication of subscription ###}
|
||||
{% if data.pub%}
|
||||
{% if data.pub and not data.refresh_pub and not data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %} WITH (refresh = false);
|
||||
{% else %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %};
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Alter subscription connection info ###}
|
||||
{% if data.host or data.port or data.username or data.db or data.connect_timeout or data.passfile or data.sslmode or data.sslcompression or data.sslcert or data.sslkey or data.sslrootcert or data.sslcrl %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
CONNECTION 'host={{ o_data.host}} port={{ o_data.port }} user={{ o_data.username }} dbname={{ o_data.db }} connect_timeout={{ o_data.connect_timeout }} {% if data.passfile %} passfile={{ o_data.passfile }}{% endif %} sslmode={{ o_data.sslmode }}{% if data.sslcompression %} sslcompression={{ data.sslcompression }}{% endif %}{% if data.sslcert %} sslcert={{ data.sslcert }}{% endif %}{% if data.sslkey %} sslkey={{ data.sslkey }}{% endif %}{% if data.sslrootcert %} sslrootcert={{ data.sslrootcert }}{% endif %}{% if data.sslcrl %} sslcrl={{ data.sslcrl }}{% endif %}';
|
||||
{% endif %}
|
||||
{### Alter subscription name ###}
|
||||
{% if data.name and data.name != o_data.name %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
|
||||
{% endif %}
|
||||
@@ -0,0 +1,24 @@
|
||||
{% if data.copy_data is defined or data.create_slot is defined or data.slot_name is defined or data.sync is defined %}
|
||||
{% set add_semicolon_after_enabled = 'enabled' %}
|
||||
{% endif %}
|
||||
{% if data.create_slot is defined or data.slot_name is defined %}
|
||||
{% set add_semicolon_after_copy_data = 'copy_data' %}
|
||||
{% endif %}
|
||||
{% if data.slot_name is defined or data.sync is defined %}
|
||||
{% set add_semicolon_after_create_slot = 'create_slot' %}
|
||||
{% endif %}
|
||||
{% if data.sync is defined %}
|
||||
{% set add_semicolon_after_slot_name = 'slot_name' %}
|
||||
{% endif %}
|
||||
|
||||
CREATE SUBSCRIPTION {{ conn|qtIdent(data.name) }}
|
||||
{% if data.host or data.port or data.username or data.password or data.db or data.connect_timeout or data.passfile or data.sslmode or data.sslcompression or data.sslcert or data.sslkey or data.sslrootcert or data.sslcrl%}
|
||||
CONNECTION '{% if data.host %}host={{data.host}}{% endif %}{% if data.port %} port={{ data.port }}{% endif %}{% if data.username %} user={{ data.username }}{% endif %}{% if data.db %} dbname={{ data.db }}{% endif %}{% if data.connect_timeout %} connect_timeout={{ data.connect_timeout }}{% endif %}{% if data.passfile %} passfile={{ data.passfile }}{% endif %}{% if data.password %} {% if dummy %}password=xxxxxx{% else %}password={{ data.password}}{% endif %}{% endif %}{% if data.sslmode %} sslmode={{ data.sslmode }}{% endif %}{% if data.sslcompression %} sslcompression={{ data.sslcompression }}{% endif %}{% if data.sslcert %} sslcert={{ data.sslcert }}{% endif %}{% if data.sslkey %} sslkey={{ data.sslkey }}{% endif %}{% if data.sslrootcert %} sslrootcert={{ data.sslrootcert }}{% endif %}{% if data.sslcrl %} sslcrl={{ data.sslcrl }}{% endif %}'
|
||||
{% endif %}
|
||||
{% if data.pub %}
|
||||
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 %}
|
||||
{% 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}}');
|
||||
@@ -0,0 +1,34 @@
|
||||
SELECT sub.oid as oid,
|
||||
subname as name,
|
||||
subpublications as pub,
|
||||
subpublications as proppub,
|
||||
sub.subsynccommit as sync,
|
||||
pga.rolname as subowner,
|
||||
subslotname as slot_name,
|
||||
subenabled as enabled,
|
||||
subbinary as binary,
|
||||
substream as streaming,
|
||||
subtwophasestate as two_phase,
|
||||
subdisableonerr as disable_on_error,
|
||||
subpasswordrequired as password_required,
|
||||
subrunasowner as run_as_owner,
|
||||
suborigin as origin,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,' port',1), '=',2) as host,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'port=',2), ' ',1) as port,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'user=',2), ' ',1) as username,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'dbname=',2), ' ',1) as db,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'connect_timeout=',2), ' ',1) as connect_timeout,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'passfile=',2), ' ',1) as passfile,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslmode=',2), ' ',1) as sslmode,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcompression=',2), ' ',1) as sslcompression,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcert=',2), ' ',1) as sslcert,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslkey=',2), ' ',1) as sslkey,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslrootcert=',2), ' ',1) as sslrootcert,
|
||||
pg_catalog.SPLIT_PART(pg_catalog.SPLIT_PART(subconninfo,'sslcrl=',2), ' ',1) as sslcrl
|
||||
FROM pg_catalog.pg_subscription sub join pg_catalog.pg_roles pga on sub.subowner= pga.oid
|
||||
WHERE
|
||||
{% if subid %}
|
||||
sub.oid = {{ subid }};
|
||||
{% else %}
|
||||
sub.subdbid = {{ did }};
|
||||
{% endif %}
|
||||
@@ -0,0 +1,77 @@
|
||||
{% if data.sync is defined %}
|
||||
{% set add_comma_after_slot_name = 'slot_name' %}
|
||||
{% endif %}
|
||||
{% if data.binary is defined or data.streaming is defined or data.disable_on_error is defined or data.run_as_owner is defined or data.password_required is defined or data.origin is defined %}
|
||||
{% set add_comma_after_sync = 'sync' %}
|
||||
{% endif %}
|
||||
{% if data.streaming is defined or data.disable_on_error is defined or data.run_as_owner is defined or data.password_required is defined or data.origin is defined %}
|
||||
{% set add_comma_after_binary = 'binary' %}
|
||||
{% endif %}
|
||||
{% if data.disable_on_error is defined or data.run_as_owner is defined or data.password_required is defined or data.origin is defined %}
|
||||
{% set add_comma_after_streaming = 'streaming' %}
|
||||
{% endif %}
|
||||
{% if data.run_as_owner is defined or data.password_required is defined or data.origin is defined %}
|
||||
{% set add_comma_after_disable_on_error = 'disable_on_error' %}
|
||||
{% endif %}
|
||||
{% if data.password_required is defined or data.origin is defined %}
|
||||
{% set add_comma_after_run_as_owner = 'run_as_owner' %}
|
||||
{% endif %}
|
||||
{% if data.origin is defined %}
|
||||
{% set add_comma_after_password_required = 'password_required' %}
|
||||
{% endif %}
|
||||
{#####################################################}
|
||||
{## Change owner of subscription ##}
|
||||
{#####################################################}
|
||||
{% if data.subowner and data.subowner != o_data.subowner %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
OWNER TO {{ data.subowner }};
|
||||
|
||||
{% endif %}
|
||||
{### Disable subscription ###}
|
||||
{% if data.enabled is defined and data.enabled != o_data.enabled %}
|
||||
{% if not data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }} DISABLE;
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Alter parameters of subscription ###}
|
||||
{% if (data.slot_name is defined and data.slot_name != o_data.slot_name) or (data.sync is defined and data.sync != o_data.sync) or (data.binary is defined and data.binary!=o_data.binary) or (data.streaming is defined and data.streaming!=o_data.streaming) or (data.disable_on_error is defined and data.disable_on_error!=o_data.disable_on_error) or (data.run_as_owner is defined and data.run_as_owner!=o_data.run_as_owner) or (data.password_required is defined and data.password_required!=o_data.password_required) or (data.origin is defined and data.origin!=o_data.origin) %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET ({% if data.slot_name is defined and data.slot_name != o_data.slot_name %}slot_name = {{ data.slot_name }}{% if add_comma_after_slot_name == 'slot_name' %}, {% endif %}{% endif %}{% if data.sync is defined and data.sync != o_data.sync %}synchronous_commit = '{{ data.sync }}'{% if add_comma_after_sync == 'sync' %}, {% endif %}{% endif %}{% if data.binary is defined and data.binary!=o_data.binary %}binary = {{ data.binary|lower}}{% if add_comma_after_binary == 'binary' %}, {% endif %}{% endif %}{% if data.streaming is defined and data.streaming!=o_data.streaming %}streaming = '{{ data.streaming }}'{% if add_comma_after_streaming == 'streaming' %}, {% endif %}{% endif %}{% if data.disable_on_error is defined and data.disable_on_error!=o_data.disable_on_error %}disable_on_error = {{ data.disable_on_error|lower}}{% if add_comma_after_disable_on_error == 'disable_on_error' %}, {% endif %}{% endif %}{% if data.run_as_owner is defined and data.run_as_owner!=o_data.run_as_owner %}run_as_owner = {{ data.run_as_owner|lower}}{% if add_comma_after_run_as_owner == 'run_as_owner' %}, {% endif %}{% endif %}{% if data.password_required is defined and data.password_required!=o_data.password_required %}password_required = {{ data.password_required|lower}}{% if add_comma_after_password_required == 'password_required' %}, {% endif %}{% endif %}{% if data.origin is defined and data.origin!=o_data.origin %}origin = '{{ data.origin }}'{% endif %});
|
||||
|
||||
{% endif %}
|
||||
{### Enable subscription ###}
|
||||
{% if data.enabled is defined and data.enabled != o_data.enabled %}
|
||||
{% if data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }} ENABLE;
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Refresh publication ###}
|
||||
{% if data.refresh_pub %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
REFRESH PUBLICATION{% if not data.copy_data_after_refresh %} WITH (copy_data = false){% else %} WITH (copy_data = true){% endif %};
|
||||
|
||||
{% endif %}
|
||||
{### Alter publication of subscription ###}
|
||||
{% if data.pub%}
|
||||
{% if data.pub and not data.refresh_pub and not data.enabled %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %} WITH (refresh = false);
|
||||
{% else %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
SET PUBLICATION {% for pub in data.pub %}{% if loop.index != 1 %},{% endif %}{{ conn|qtIdent(pub) }}{% endfor %};
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{### Alter subscription connection info ###}
|
||||
{% if data.host or data.port or data.username or data.db or data.connect_timeout or data.passfile or data.sslmode or data.sslcompression or data.sslcert or data.sslkey or data.sslrootcert or data.sslcrl %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
CONNECTION 'host={{ o_data.host}} port={{ o_data.port }} user={{ o_data.username }} dbname={{ o_data.db }} connect_timeout={{ o_data.connect_timeout }} {% if data.passfile %} passfile={{ o_data.passfile }}{% endif %} sslmode={{ o_data.sslmode }}{% if data.sslcompression %} sslcompression={{ data.sslcompression }}{% endif %}{% if data.sslcert %} sslcert={{ data.sslcert }}{% endif %}{% if data.sslkey %} sslkey={{ data.sslkey }}{% endif %}{% if data.sslrootcert %} sslrootcert={{ data.sslrootcert }}{% endif %}{% if data.sslcrl %} sslcrl={{ data.sslcrl }}{% endif %}';
|
||||
{% endif %}
|
||||
{### Alter subscription name ###}
|
||||
{% if data.name and data.name != o_data.name %}
|
||||
ALTER SUBSCRIPTION {{ conn|qtIdent(o_data.name) }}
|
||||
RENAME TO {{ conn|qtIdent(data.name) }};
|
||||
|
||||
{% endif %}
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Subscription: test_create_subscription
|
||||
|
||||
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
|
||||
|
||||
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 = false, streaming = 'False');
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER SUBSCRIPTION test_create_subscription
|
||||
SET (binary = false, streaming = 'False');
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Subscription: test_create_subscription
|
||||
|
||||
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
|
||||
|
||||
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');
|
||||
@@ -0,0 +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');
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Subscription",
|
||||
"endpoint": "NODE-subscription.obj",
|
||||
"sql_endpoint": "NODE-subscription.sql_id",
|
||||
"msql_endpoint": "NODE-subscription.msql",
|
||||
"data": {
|
||||
"username": "postgres",
|
||||
"name": "test_create_subscription",
|
||||
"connect": false,
|
||||
"connect_timeout": 10,
|
||||
"copy_data": false,
|
||||
"create_slot": false,
|
||||
"db": "postgres",
|
||||
"subowner": "postgres",
|
||||
"enabled": false,
|
||||
"host": "localhost",
|
||||
"slot_name": "None",
|
||||
"service": "",
|
||||
"port": 5434,
|
||||
"password": "edb",
|
||||
"sync": "remote_apply",
|
||||
"binary": true,
|
||||
"streaming": true,
|
||||
"sslmode": "prefer",
|
||||
"pub": ["test_pub"]
|
||||
},
|
||||
"expected_sql_file": "create_subscription.sql",
|
||||
"expected_msql_file": "create_subscription_msql.sql"
|
||||
}
|
||||
,
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter parameters of subscription",
|
||||
"endpoint": "NODE-subscription.obj_id",
|
||||
"sql_endpoint": "NODE-subscription.sql_id",
|
||||
"data": {
|
||||
"binary": false,
|
||||
"streaming": false
|
||||
},
|
||||
"expected_sql_file": "alter_parameters.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop subscription",
|
||||
"endpoint": "NODE-subscription.delete_id",
|
||||
"data": {
|
||||
"name": "test_create_subscription"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Subscription: test_create_subscription
|
||||
|
||||
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
|
||||
|
||||
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);
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER SUBSCRIPTION test_create_subscription
|
||||
SET (synchronous_commit = 'off', binary = false, streaming = 'False', disable_on_error = false);
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Subscription: test_create_subscription
|
||||
|
||||
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
|
||||
|
||||
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);
|
||||
@@ -0,0 +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);
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Subscription",
|
||||
"endpoint": "NODE-subscription.obj",
|
||||
"sql_endpoint": "NODE-subscription.sql_id",
|
||||
"msql_endpoint": "NODE-subscription.msql",
|
||||
"data": {
|
||||
"username": "postgres",
|
||||
"name": "test_create_subscription",
|
||||
"connect": false,
|
||||
"connect_timeout": 10,
|
||||
"copy_data": false,
|
||||
"create_slot": false,
|
||||
"db": "postgres",
|
||||
"subowner": "postgres",
|
||||
"enabled": false,
|
||||
"host": "localhost",
|
||||
"slot_name": "None",
|
||||
"service": "",
|
||||
"port": 5434,
|
||||
"password": "edb",
|
||||
"sync": "remote_apply",
|
||||
"binary": true,
|
||||
"streaming": true,
|
||||
"disable_on_error": true,
|
||||
"two_phase": true,
|
||||
"sslmode": "prefer",
|
||||
"pub": ["test_pub"]
|
||||
},
|
||||
"expected_sql_file": "create_subscription.sql",
|
||||
"expected_msql_file": "create_subscription_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter parameters of subscription",
|
||||
"endpoint": "NODE-subscription.obj_id",
|
||||
"sql_endpoint": "NODE-subscription.sql_id",
|
||||
"data": {
|
||||
"sync": "off",
|
||||
"binary": false,
|
||||
"streaming": false,
|
||||
"disable_on_error": false
|
||||
},
|
||||
"expected_sql_file": "alter_parameters.sql",
|
||||
"expected_msql_file": "alter_parameters_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop subscription",
|
||||
"endpoint": "NODE-subscription.delete_id",
|
||||
"data": {
|
||||
"name": "test_create_subscription"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Subscription: test_create_subscription
|
||||
|
||||
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
|
||||
|
||||
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 = false, password_required = true, origin = 'none');
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER SUBSCRIPTION test_create_subscription
|
||||
SET (synchronous_commit = 'off', binary = false, streaming = 'False', disable_on_error = false, run_as_owner = false, origin = 'none');
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Subscription: test_create_subscription
|
||||
|
||||
-- DROP SUBSCRIPTION IF EXISTS test_create_subscription;
|
||||
|
||||
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');
|
||||
@@ -0,0 +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');
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"scenarios": [
|
||||
{
|
||||
"type": "create",
|
||||
"name": "Create Subscription",
|
||||
"endpoint": "NODE-subscription.obj",
|
||||
"sql_endpoint": "NODE-subscription.sql_id",
|
||||
"msql_endpoint": "NODE-subscription.msql",
|
||||
"data": {
|
||||
"username": "postgres",
|
||||
"name": "test_create_subscription",
|
||||
"connect": false,
|
||||
"connect_timeout": 10,
|
||||
"copy_data": false,
|
||||
"create_slot": false,
|
||||
"db": "postgres",
|
||||
"subowner": "postgres",
|
||||
"enabled": false,
|
||||
"host": "localhost",
|
||||
"slot_name": "None",
|
||||
"service": "",
|
||||
"port": 5434,
|
||||
"password": "edb",
|
||||
"sync": "remote_apply",
|
||||
"binary": true,
|
||||
"streaming": true,
|
||||
"disable_on_error": true,
|
||||
"two_phase": true,
|
||||
"password_required": true,
|
||||
"run_as_owner": true,
|
||||
"origin": "any",
|
||||
"sslmode": "prefer",
|
||||
"pub": ["test_pub"]
|
||||
},
|
||||
"expected_sql_file": "create_subscription.sql",
|
||||
"expected_msql_file": "create_subscription_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
"name": "Alter parameters of subscription",
|
||||
"endpoint": "NODE-subscription.obj_id",
|
||||
"sql_endpoint": "NODE-subscription.sql_id",
|
||||
"data": {
|
||||
"sync": "off",
|
||||
"binary": false,
|
||||
"streaming": false,
|
||||
"disable_on_error": false,
|
||||
"run_as_owner": false,
|
||||
"origin": "none"
|
||||
},
|
||||
"expected_sql_file": "alter_parameters.sql",
|
||||
"expected_msql_file": "alter_parameters_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop subscription",
|
||||
"endpoint": "NODE-subscription.delete_id",
|
||||
"data": {
|
||||
"name": "test_create_subscription"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER SUBSCRIPTION test_alter_subscription
|
||||
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb';
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER SUBSCRIPTION test_create_subscription
|
||||
RENAME TO test_alter_subscription;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER SUBSCRIPTION test_alter_subscription
|
||||
SET (synchronous_commit = 'remote_apply');
|
||||
@@ -34,7 +34,8 @@
|
||||
"data": {
|
||||
"name": "test_alter_subscription"
|
||||
},
|
||||
"expected_sql_file": "alter_subscription.sql"
|
||||
"expected_sql_file": "alter_subscription.sql",
|
||||
"expected_msql_file": "alter_subscription_msql.sql"
|
||||
},
|
||||
{
|
||||
"type": "alter",
|
||||
@@ -44,7 +45,8 @@
|
||||
"data": {
|
||||
"sync": "remote_apply"
|
||||
},
|
||||
"expected_sql_file": "alter_sync.sql"
|
||||
"expected_sql_file": "alter_sync.sql",
|
||||
"expected_msql_file": "alter_sync_msql.sql"
|
||||
},
|
||||
|
||||
{
|
||||
@@ -55,9 +57,9 @@
|
||||
"data": {
|
||||
"db": "edb"
|
||||
},
|
||||
"expected_sql_file": "alter_maintenance_db.sql"
|
||||
"expected_sql_file": "alter_maintenance_db.sql",
|
||||
"expected_msql_file": "alter_maintenance_db_msql.sql"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "delete",
|
||||
"name": "Drop subscription",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"add_subscription": [
|
||||
{
|
||||
"name": "Create subscription with insert and update",
|
||||
"name": "Create subscription along with few publications",
|
||||
"url": "/browser/subscription/obj/",
|
||||
"is_positive_test": true,
|
||||
"test_data": {
|
||||
@@ -19,34 +19,13 @@
|
||||
"port": 5432,
|
||||
"password": "",
|
||||
"sync": "off",
|
||||
"pub": ["sample__1"]
|
||||
},
|
||||
"mocking_required": false,
|
||||
"mock_data": {},
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Create subscription for few tables",
|
||||
"url": "/browser/subscription/obj/",
|
||||
"is_positive_test": true,
|
||||
"get_publication": true,
|
||||
"test_data": {
|
||||
"username": "postgres",
|
||||
"name": "PLACEHOLDER",
|
||||
"connect": false,
|
||||
"copy_data": false,
|
||||
"create_slot": false,
|
||||
"db": "postgres",
|
||||
"subowner": "postgres",
|
||||
"enabled": false,
|
||||
"host": "localhost",
|
||||
"slot_name": "None",
|
||||
"service": "",
|
||||
"port": 5432,
|
||||
"password": "",
|
||||
"sync": "off",
|
||||
"binary":false,
|
||||
"two_phase":false,
|
||||
"disable_on_error":false,
|
||||
"streaming":false,
|
||||
"password_required":true,
|
||||
"run_as_owner":false,
|
||||
"origin":"any",
|
||||
"pub": ["sample__1"]
|
||||
},
|
||||
"mocking_required": false,
|
||||
@@ -75,6 +54,13 @@
|
||||
"port": 5432,
|
||||
"password": "",
|
||||
"sync": "off",
|
||||
"binary":false,
|
||||
"two_phase":false,
|
||||
"disable_on_error":false,
|
||||
"streaming":false,
|
||||
"password_required":true,
|
||||
"run_as_owner":false,
|
||||
"origin":"any",
|
||||
"pub": ["sample__1"]
|
||||
},
|
||||
"mocking_required": false,
|
||||
@@ -103,6 +89,13 @@
|
||||
"port": 5432,
|
||||
"password": "",
|
||||
"sync": "off",
|
||||
"binary":false,
|
||||
"two_phase":false,
|
||||
"disable_on_error":false,
|
||||
"streaming":false,
|
||||
"password_required":true,
|
||||
"run_as_owner":false,
|
||||
"origin":"any",
|
||||
"pub": ["sample__1"]
|
||||
},
|
||||
"mocking_required": true,
|
||||
@@ -133,6 +126,13 @@
|
||||
"port": 5432,
|
||||
"password": "",
|
||||
"sync": "off",
|
||||
"binary":false,
|
||||
"two_phase":false,
|
||||
"disable_on_error":false,
|
||||
"streaming":false,
|
||||
"password_required":true,
|
||||
"run_as_owner":false,
|
||||
"origin":"any",
|
||||
"pub": ["sample__1"]
|
||||
},
|
||||
"mocking_required": true,
|
||||
@@ -248,18 +248,6 @@
|
||||
"status_code": 200
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Get all the subscription under the database nodes using wrong database id",
|
||||
"url": "/browser/subscription/nodes/",
|
||||
"is_positive_test": true,
|
||||
"incorrect_database_id": true,
|
||||
"database_nodes": true,
|
||||
"mocking_required": false,
|
||||
"mock_data": {},
|
||||
"expected_data": {
|
||||
"status_code": 200
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Error while fetching all the subscription under the database nodes using wrong database id",
|
||||
"url": "/browser/subscription/nodes/",
|
||||
@@ -320,7 +308,6 @@
|
||||
"name": "update a port in connection details of subscription",
|
||||
"url": "/browser/subscription/obj/",
|
||||
"is_positive_test": true,
|
||||
"owner_subscription": true,
|
||||
"test_data": {
|
||||
"id": "PLACE_HOLDER",
|
||||
"port": "5444"
|
||||
@@ -335,7 +322,6 @@
|
||||
"name": "update a username in connection details of subscription",
|
||||
"url": "/browser/subscription/obj/",
|
||||
"is_positive_test": true,
|
||||
"owner_subscription": true,
|
||||
"test_data": {
|
||||
"id": "PLACE_HOLDER",
|
||||
"username": "sample_username"
|
||||
|
||||
@@ -47,15 +47,6 @@ class SubscriptionAddTestCase(BaseTestGenerator):
|
||||
raise Exception(
|
||||
"Could not connect to database to add a subscription.")
|
||||
|
||||
if self.is_positive_test and hasattr(self, 'few_tables_11'):
|
||||
self.table_name = "table_column_%s" % (str(uuid.uuid4())[1:8])
|
||||
self.table_id = tables_utils.create_table(self.server,
|
||||
self.db_name,
|
||||
self.schema_name,
|
||||
self.table_name)
|
||||
|
||||
self.test_data['pubtable'] = subscription_utils.get_tables(self)
|
||||
|
||||
def runTest(self):
|
||||
"""This function will subscription."""
|
||||
self.test_data['name'] = \
|
||||
|
||||
@@ -43,14 +43,7 @@ class SubscriptionDeleteTestCase(BaseTestGenerator):
|
||||
if not db_con['data']["connected"]:
|
||||
raise Exception(
|
||||
"Could not connect to database to delete subscription.")
|
||||
self.schema_id = schema_info["schema_id"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
schema_response = schema_utils.verify_schemas(self.server,
|
||||
self.db_name,
|
||||
self.schema_name)
|
||||
if not schema_response:
|
||||
raise Exception("Could not find the schema to delete "
|
||||
"subscription.")
|
||||
|
||||
self.subscription_name = "test_subscription_delete_%s" % (
|
||||
str(uuid.uuid4())[1:8])
|
||||
|
||||
|
||||
@@ -45,18 +45,7 @@ class SubscriptionDeleteTestCases(BaseTestGenerator):
|
||||
if not db_con['data']["connected"]:
|
||||
raise Exception(
|
||||
"Could not connect to database to delete subscription.")
|
||||
self.schema_id = schema_info["schema_id"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
schema_response = schema_utils.verify_schemas(self.server,
|
||||
self.db_name,
|
||||
self.schema_name)
|
||||
if not schema_response:
|
||||
raise Exception("Could not find the schema to "
|
||||
"delete subscription.")
|
||||
self.table_name = "table_column_%s" % (str(uuid.uuid4())[1:8])
|
||||
self.table_id = tables_utils.create_table(self.server, self.db_name,
|
||||
self.schema_name,
|
||||
self.table_name)
|
||||
|
||||
self.subscription_name = "test_subscription_delete_%s" % (
|
||||
str(uuid.uuid4())[1:8])
|
||||
self.subscription_name_1 = "test_subscription_delete_%s" % (
|
||||
|
||||
@@ -45,18 +45,7 @@ class SubscriptionGetTestCase(BaseTestGenerator):
|
||||
if not db_con['data']["connected"]:
|
||||
raise Exception("Could not connect to database to "
|
||||
"delete subscription.")
|
||||
self.schema_id = schema_info["schema_id"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
schema_response = schema_utils.verify_schemas(self.server,
|
||||
self.db_name,
|
||||
self.schema_name)
|
||||
if not schema_response:
|
||||
raise Exception("Could not find the schema to delete "
|
||||
"subscription.")
|
||||
self.table_name = "table_column_%s" % (str(uuid.uuid4())[1:8])
|
||||
self.table_id = tables_utils.create_table(self.server, self.db_name,
|
||||
self.schema_name,
|
||||
self.table_name)
|
||||
|
||||
self.subscription_name = "test_subscription_delete_%s" % (
|
||||
str(uuid.uuid4())[1:8])
|
||||
self.subscription_id = subscription_utils.create_subscription(
|
||||
|
||||
@@ -46,18 +46,7 @@ class SubscriptionUpdateTestCase(BaseTestGenerator):
|
||||
if not db_con['data']["connected"]:
|
||||
raise Exception(
|
||||
"Could not connect to database to delete subscription.")
|
||||
self.schema_id = schema_info["schema_id"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
schema_response = schema_utils.verify_schemas(self.server,
|
||||
self.db_name,
|
||||
self.schema_name)
|
||||
if not schema_response:
|
||||
raise Exception("Could not find the schema to delete "
|
||||
"subscription.")
|
||||
self.table_name = "table_column_%s" % (str(uuid.uuid4())[1:8])
|
||||
self.table_id = tables_utils.create_table(self.server, self.db_name,
|
||||
self.schema_name,
|
||||
self.table_name)
|
||||
|
||||
self.subscription_name = "test_subscription_update_%s" % (
|
||||
str(uuid.uuid4())[1:8])
|
||||
self.subscription_id = \
|
||||
@@ -92,8 +81,6 @@ class SubscriptionUpdateTestCase(BaseTestGenerator):
|
||||
if self.is_positive_test:
|
||||
if hasattr(self, "wrong_subscription_id"):
|
||||
self.subscription_id = 9999
|
||||
if hasattr(self, "plid_none"):
|
||||
self.subscription_id = ''
|
||||
response = self.update_subscription(self.test_data)
|
||||
else:
|
||||
with patch(self.mock_data["function_name"],
|
||||
|
||||
@@ -44,18 +44,7 @@ class SubscriptionGetTestCase(BaseTestGenerator):
|
||||
if not db_con['data']["connected"]:
|
||||
raise Exception(
|
||||
"Could not connect to database to delete subscription.")
|
||||
self.schema_id = schema_info["schema_id"]
|
||||
self.schema_name = schema_info["schema_name"]
|
||||
schema_response = schema_utils.verify_schemas(self.server,
|
||||
self.db_name,
|
||||
self.schema_name)
|
||||
if not schema_response:
|
||||
raise Exception("Could not find the schema to delete "
|
||||
"subscription.")
|
||||
self.table_name = "table_column_%s" % (str(uuid.uuid4())[1:8])
|
||||
self.table_id = tables_utils.create_table(self.server, self.db_name,
|
||||
self.schema_name,
|
||||
self.table_name)
|
||||
|
||||
self.subscription_name = "test_subscription_delete_%s" % (
|
||||
str(uuid.uuid4())[1:8])
|
||||
self.subscription_id = \
|
||||
|
||||
@@ -20,16 +20,6 @@ with open(CURRENT_PATH + "/subscription_test_data.json") as data_file:
|
||||
test_cases = json.load(data_file)
|
||||
|
||||
|
||||
def get_tables(self):
|
||||
tables = self.tester.get(
|
||||
'/browser/subscription/get_tables/' + str(
|
||||
utils.SERVER_GROUP) + '/' + str(
|
||||
self.server_id) + '/' +
|
||||
str(self.db_id) + '/',
|
||||
content_type='html/json')
|
||||
return [tables.json['data'][1]['value']]
|
||||
|
||||
|
||||
def create_subscription_api(self):
|
||||
return self.tester.post(
|
||||
self.url + str(utils.SERVER_GROUP) + '/' +
|
||||
|
||||
Reference in New Issue
Block a user