Skip to content

Commit 26fdf60

Browse files
committed
Here we revise docs on sub_disable, sub_enable, and sub_show_status functions.
Some minor typos and trailed whitespaces fixed here and there in the code. Also, this commit commences restructurisation of the UI .sql script to make it a little more readable and synced with the docs/spock_functions.md.
1 parent bf823e0 commit 26fdf60

File tree

7 files changed

+120
-41
lines changed

7 files changed

+120
-41
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ set -e -u -x
195195
# If you don't want leak checking, use --leak-check=no
196196
#
197197
# When just doing leak checking and not looking for detailed memory error reports you don't need:
198-
# --track-origins=yes --read-var-info=yes --malloc-fill=8f --free-fill=9f
198+
# --track-origins=yes --read-var-info=yes --malloc-fill=8f --free-fill=9f
199199
#
200200
SUPP=$(POSTGRES_SRC)/src/tools/valgrind.supp
201201

docs/spock_functions/functions/spock_sub_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ Use `spock.sub_wait_for_sync(subscription_name)` to wait for the subscription to
3636
force_text_transfer
3737
Force the provider to replicate all columns using a text representation (which is slower, but may be used to change the type of a replicated column on the subscriber). The default is false.
3838
enabled
39-
If true, it signals replication machinery to activate synchronisation of schema/data from the publisher. If false, the node synchronisation status is set to ready, no active sync The default is true.
39+
If true, it signals replication machinery to activate synchronisation of schema/data from the publisher. If false, the node synchronisation status is set to ready, no synchronization will be made (TODO: refer to a correct use case). The default is true.
4040
skip_schema
4141
Array of schema names that will be skipped during the structure synchronisation. Data from any table, included in these schemas will be filtered at initial data synchronisation. The default is NULL.
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
## NAME
1+
## NAME
22

33
`spock.sub_disable ()`
44

55
### SYNOPSIS
66

77
`spock.sub_disable (subscription_name name, immediate boolean)`
8-
8+
99
### DESCRIPTION
10-
Disable a subscription by putting it on hold and disconnect from provider.
10+
Disable a subscription by putting it on hold and disconnect from provider.
1111

1212
### EXAMPLE
1313

14-
`spock sub_disable 'sub_n2n1'`
15-
14+
`spock sub_disable('sub_n2n1')`
15+
1616
### ARGUMENTS
1717
subscription_name
1818
The name of the existing subscription.
1919
immediate
2020
If true, the subscription is stopped immediately, otherwise it will be only stopped at the end of current transaction; the default is false.
21-

docs/spock_functions/functions/spock_sub_show_status.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,29 @@
55
### SYNOPSIS
66

77
`spock.sub_show_status (subscription_name name)`
8-
8+
99
### DESCRIPTION
1010

11-
Show the status and basic information of a subscription.
11+
Show the status and basic information of a subscription.
1212

1313
### EXAMPLE
1414

1515
`spock.sub_show_status ('sub_n2n1')`
16-
16+
1717
### ARGUMENTS
1818
subscription_name
1919
The optional name of the existing subscription. If no name is provided, the function will show status for all subscriptions on the local node.
20+
21+
### RETURN
22+
23+
Returns one record per subscription with the following columns:
24+
25+
* `subscription_name text`,
26+
* `status text`,
27+
* `provider_node text`,
28+
* `provider_dsn text`,
29+
* `slot_name text`,
30+
* `replication_sets text[]`,
31+
* `forward_origins text[]`
32+
33+
Column `status` may have one of the following values: `unknown`, `replicating`, `initializing`, `disabled`, or `down`.

sql/spock--6.0.0-devel.sql

Lines changed: 86 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ CREATE TABLE spock.progress (
106106
PRIMARY KEY(node_id, remote_node_id)
107107
) WITH (fillfactor=50);
108108

109+
--
110+
-- Node Management Functions
111+
--
112+
109113
CREATE FUNCTION spock.node_create(
110114
node_name name,
111115
dsn text,
@@ -117,6 +121,31 @@ RETURNS oid CALLED ON NULL INPUT VOLATILE
117121
AS 'MODULE_PATHNAME', 'spock_create_node'
118122
LANGUAGE C;
119123

124+
CREATE FUNCTION spock.node_drop(
125+
node_name name,
126+
ifexists boolean DEFAULT false
127+
)
128+
RETURNS boolean
129+
AS 'MODULE_PATHNAME', 'spock_drop_node'
130+
LANGUAGE C STRICT VOLATILE;
131+
132+
CREATE FUNCTION spock.node_info(
133+
OUT node_id oid,
134+
OUT node_name text,
135+
OUT sysid text,
136+
OUT dbname text,
137+
OUT replication_sets text,
138+
OUT location text,
139+
OUT country text,
140+
OUT info jsonb)
141+
RETURNS record
142+
AS 'MODULE_PATHNAME', 'spock_node_info'
143+
LANGUAGE C STABLE STRICT;
144+
145+
--
146+
-- SSubscription Management Functions
147+
--
148+
120149
CREATE FUNCTION spock.sub_create(
121150
subscription_name name,
122151
provider_dsn text,
@@ -141,23 +170,64 @@ RETURNS oid
141170
AS 'MODULE_PATHNAME', 'spock_drop_subscription'
142171
LANGUAGE C STRICT VOLATILE;
143172

144-
CREATE FUNCTION spock.node_drop(node_name name, ifexists boolean DEFAULT false)
173+
CREATE FUNCTION spock.sub_disable(
174+
subscription_name name,
175+
immediate boolean DEFAULT false
176+
)
145177
RETURNS boolean
146-
AS 'MODULE_PATHNAME', 'spock_drop_node'
178+
AS 'MODULE_PATHNAME', 'spock_alter_subscription_disable'
147179
LANGUAGE C STRICT VOLATILE;
148180

149-
CREATE FUNCTION spock.node_add_interface(node_name name, interface_name name, dsn text)
150-
RETURNS oid STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_node_add_interface';
151-
CREATE FUNCTION spock.node_drop_interface(node_name name, interface_name name)
152-
RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_node_drop_interface';
181+
CREATE FUNCTION spock.sub_enable(
182+
subscription_name name,
183+
immediate boolean DEFAULT false
184+
)
185+
RETURNS boolean
186+
AS 'MODULE_PATHNAME', 'spock_alter_subscription_enable'
187+
LANGUAGE C STRICT VOLATILE;
188+
189+
CREATE FUNCTION spock.sub_show_status(
190+
subscription_name name DEFAULT NULL,
191+
OUT subscription_name text,
192+
OUT status text,
193+
OUT provider_node text,
194+
OUT provider_dsn text,
195+
OUT slot_name text,
196+
OUT replication_sets text[],
197+
OUT forward_origins text[]
198+
)
199+
RETURNS SETOF record
200+
AS 'MODULE_PATHNAME', 'spock_show_subscription_status'
201+
LANGUAGE C STABLE;
153202

154-
CREATE FUNCTION spock.sub_alter_interface(subscription_name name, interface_name name)
155-
RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_subscription_interface';
203+
--
204+
-- Additional interface management routines for complex network configurations
205+
--
206+
207+
CREATE FUNCTION spock.node_add_interface(
208+
node_name name,
209+
interface_name name,
210+
dsn text
211+
)
212+
RETURNS oid
213+
AS 'MODULE_PATHNAME', 'spock_alter_node_add_interface'
214+
LANGUAGE C STRICT VOLATILE;
215+
216+
CREATE FUNCTION spock.sub_alter_interface(
217+
subscription_name name,
218+
interface_name name
219+
)
220+
RETURNS boolean
221+
AS 'MODULE_PATHNAME', 'spock_alter_subscription_interface'
222+
LANGUAGE C STRICT VOLATILE;
156223

157-
CREATE FUNCTION spock.sub_disable(subscription_name name, immediate boolean DEFAULT false)
158-
RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_subscription_disable';
159-
CREATE FUNCTION spock.sub_enable(subscription_name name, immediate boolean DEFAULT false)
160-
RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_subscription_enable';
224+
CREATE FUNCTION spock.node_drop_interface(
225+
node_name name,
226+
interface_name name
227+
)
228+
RETURNS boolean
229+
AS 'MODULE_PATHNAME', 'spock_alter_node_drop_interface'
230+
LANGUAGE C STRICT VOLATILE;
161231

162232
CREATE FUNCTION spock.sub_add_repset(subscription_name name, replication_set name)
163233
RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_subscription_add_replication_set';
@@ -166,12 +236,6 @@ RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_su
166236
CREATE FUNCTION spock.sub_alter_skiplsn(subscription_name name, lsn pg_lsn)
167237
RETURNS boolean STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_alter_subscription_skip_lsn';
168238

169-
CREATE FUNCTION spock.sub_show_status(subscription_name name DEFAULT NULL,
170-
OUT subscription_name text, OUT status text, OUT provider_node text,
171-
OUT provider_dsn text, OUT slot_name text, OUT replication_sets text[],
172-
OUT forward_origins text[])
173-
RETURNS SETOF record STABLE LANGUAGE c AS 'MODULE_PATHNAME', 'spock_show_subscription_status';
174-
175239
CREATE TABLE spock.replication_set (
176240
set_id oid NOT NULL PRIMARY KEY,
177241
set_nodeid oid NOT NULL REFERENCES node(node_id) ON UPDATE CASCADE,
@@ -280,6 +344,10 @@ CREATE VIEW spock.TABLES AS
280344
FROM user_tables t
281345
WHERE t.oid NOT IN (SELECT set_reloid FROM set_relations);
282346

347+
--
348+
-- Replication Set Management Functions
349+
--
350+
283351
CREATE FUNCTION spock.repset_create(set_name name,
284352
replicate_insert boolean = true, replicate_update boolean = true,
285353
replicate_delete boolean = true, replicate_truncate boolean = true)
@@ -354,12 +422,6 @@ CREATE FUNCTION spock.replicate_ddl(command text[],
354422
RETURNS SETOF boolean STRICT VOLATILE LANGUAGE sql AS
355423
'SELECT spock.replicate_ddl(cmd, $2, $3, $4) FROM (SELECT unnest(command) cmd)';
356424

357-
CREATE FUNCTION spock.node_info(OUT node_id oid, OUT node_name text,
358-
OUT sysid text, OUT dbname text, OUT replication_sets text,
359-
OUT location text, OUT country text, OUT info jsonb)
360-
RETURNS record
361-
STABLE STRICT LANGUAGE c AS 'MODULE_PATHNAME', 'spock_node_info';
362-
363425
CREATE FUNCTION spock.spock_gen_slot_name(name, name, name)
364426
RETURNS name
365427
IMMUTABLE STRICT LANGUAGE c AS 'MODULE_PATHNAME';

src/spock_functions.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,8 @@ spock_create_subscription(PG_FUNCTION_ARGS)
636636
/*
637637
* Remove subscribption.
638638
*/
639-
Datum spock_drop_subscription(PG_FUNCTION_ARGS)
639+
Datum
640+
spock_drop_subscription(PG_FUNCTION_ARGS)
640641
{
641642
char *sub_name = NameStr(*PG_GETARG_NAME(0));
642643
bool ifexists = PG_GETARG_BOOL(1);
@@ -741,14 +742,15 @@ Datum spock_drop_subscription(PG_FUNCTION_ARGS)
741742
/*
742743
* Disable subscription.
743744
*/
744-
Datum spock_alter_subscription_disable(PG_FUNCTION_ARGS)
745+
Datum
746+
spock_alter_subscription_disable(PG_FUNCTION_ARGS)
745747
{
746748
char *sub_name = NameStr(*PG_GETARG_NAME(0));
747749
bool immediate = PG_GETARG_BOOL(1);
748750
SpockSubscription *sub = get_subscription_by_name(sub_name, false);
749751

750752
/* XXX: Only used for locking purposes. */
751-
(void)get_local_node(true, false);
753+
(void) get_local_node(true, false);
752754

753755
sub->enabled = false;
754756

@@ -1117,7 +1119,8 @@ Datum spock_show_subscription_table(PG_FUNCTION_ARGS)
11171119
/*
11181120
* Show info about subscribtion.
11191121
*/
1120-
Datum spock_show_subscription_status(PG_FUNCTION_ARGS)
1122+
Datum
1123+
spock_show_subscription_status(PG_FUNCTION_ARGS)
11211124
{
11221125
List *subscriptions;
11231126
ListCell *lc;
@@ -2274,7 +2277,8 @@ Datum spock_dependency_check_trigger(PG_FUNCTION_ARGS)
22742277
PG_RETURN_VOID();
22752278
}
22762279

2277-
Datum spock_node_info(PG_FUNCTION_ARGS)
2280+
Datum
2281+
spock_node_info(PG_FUNCTION_ARGS)
22782282
{
22792283
TupleDesc tupdesc;
22802284
Datum values[8];

src/spock_manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ manage_apply_workers(void)
9393
if (!wlc)
9494
apply = NULL;
9595

96-
/* Skip if the worker was alrady registered. */
96+
/* Skip if the worker was already registered. */
9797
if (spock_worker_running(apply))
9898
continue;
9999

0 commit comments

Comments
 (0)