From 691674d57c73a4408c8104a9a391f9345af143ca Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Thu, 7 May 2026 18:46:34 +0500 Subject: [PATCH 01/10] docs: correct Spock function reference signatures and return values --- .../functions/spock_max_proto_version.md | 8 ++- .../functions/spock_min_proto_version.md | 8 ++- .../functions/spock_node_drop_interface.md | 7 +-- .../functions/spock_repset_add_seq.md | 4 +- .../functions/spock_repset_add_table.md | 10 +-- .../functions/spock_repset_remove_seq.md | 4 +- .../functions/spock_repset_remove_table.md | 3 +- .../functions/spock_sub_add_repset.md | 4 +- .../functions/spock_sub_alter_interface.md | 3 +- .../functions/spock_sync_event.md | 8 ++- docs/spock_functions/gen_mgmt.md | 41 ++++++------ docs/spock_functions/index.md | 14 ++--- docs/spock_functions/repset_mgmt.md | 46 ++++++++------ docs/spock_functions/sub_mgmt.md | 63 ++++++++++++------- 14 files changed, 133 insertions(+), 90 deletions(-) diff --git a/docs/spock_functions/functions/spock_max_proto_version.md b/docs/spock_functions/functions/spock_max_proto_version.md index 8b3122db..696b1bb3 100644 --- a/docs/spock_functions/functions/spock_max_proto_version.md +++ b/docs/spock_functions/functions/spock_max_proto_version.md @@ -1,10 +1,12 @@ ## NAME -spock.spock_max_proto_version() +spock_max_proto_version() ### SYNOPSIS -spock.spock_max_proto_version() +spock_max_proto_version() + +This function is defined in the public schema, not the `spock.` schema. ### RETURNS @@ -40,7 +42,7 @@ This function takes no arguments. The following command shows that the current version of Spock uses protocol version 4: - postgres=# SELECT spock.spock_max_proto_version(); + postgres=# SELECT spock_max_proto_version(); spock_max_proto_version ------------------------- 4 diff --git a/docs/spock_functions/functions/spock_min_proto_version.md b/docs/spock_functions/functions/spock_min_proto_version.md index 211f06e6..687a7e7a 100644 --- a/docs/spock_functions/functions/spock_min_proto_version.md +++ b/docs/spock_functions/functions/spock_min_proto_version.md @@ -1,10 +1,12 @@ ## NAME -spock.spock_min_proto_version() +spock_min_proto_version() ### SYNOPSIS -spock.spock_min_proto_version() +spock_min_proto_version() + +This function is defined in the public schema, not the `spock.` schema. ### RETURNS @@ -42,7 +44,7 @@ This function takes no arguments. The following command shows that the version of Spock in use is using protocol version 3: - postgres=# SELECT spock.spock_min_proto_version(); + postgres=# SELECT spock_min_proto_version(); spock_min_proto_version ------------------------- 3 diff --git a/docs/spock_functions/functions/spock_node_drop_interface.md b/docs/spock_functions/functions/spock_node_drop_interface.md index 0cfadc0b..9abce170 100644 --- a/docs/spock_functions/functions/spock_node_drop_interface.md +++ b/docs/spock_functions/functions/spock_node_drop_interface.md @@ -10,10 +10,9 @@ spock.node_drop_interface (node_name name, interface_name name) - true if the interface was dropped successfully. - - false if the interface does not exist. - - - ERROR if the call has invalid parameters, insufficient privileges, or - the interface cannot be removed. + - Raises an ERROR if the interface does not exist, the call has + invalid parameters or insufficient privileges, or the interface + cannot be removed. ### DESCRIPTION diff --git a/docs/spock_functions/functions/spock_repset_add_seq.md b/docs/spock_functions/functions/spock_repset_add_seq.md index e36ff5e5..cfc89adb 100644 --- a/docs/spock_functions/functions/spock_repset_add_seq.md +++ b/docs/spock_functions/functions/spock_repset_add_seq.md @@ -12,7 +12,9 @@ spock.repset_add_seq ( ### RETURNS - true if the sequence was successfully added to the replication set. - - false if the sequence was already a member of the replication set. + - Raises an ERROR if the sequence is already a member of the + replication set, or if the call has invalid parameters or + insufficient privileges. ### DESCRIPTION diff --git a/docs/spock_functions/functions/spock_repset_add_table.md b/docs/spock_functions/functions/spock_repset_add_table.md index 08beee78..d42cef20 100644 --- a/docs/spock_functions/functions/spock_repset_add_table.md +++ b/docs/spock_functions/functions/spock_repset_add_table.md @@ -16,7 +16,9 @@ spock.repset_add_table ( ### RETURNS - true if the table was successfully added to the replication set. - - false if the table was already a member of the replication set. + - Raises an ERROR if the table is already a member of the replication + set, or if the call has invalid parameters or insufficient + privileges. ### DESCRIPTION @@ -96,7 +98,7 @@ rows: row_filter := 'balance > 0'); **WARNING: Use caution when synchronizing data with a valid row filter.** -Using `sync_data=true` with a valid `row_filter` is usually a one_time -operation for a table. Executing it again with a modified `row_filter` -won't synchronize data to subscriber. You may need to call +Using `synchronize_data=true` with a valid `row_filter` is usually a +one-time operation for a table. Executing it again with a modified +`row_filter` won't synchronize data to subscriber. You may need to call `spock.sub_resync_table()` to fix it. diff --git a/docs/spock_functions/functions/spock_repset_remove_seq.md b/docs/spock_functions/functions/spock_repset_remove_seq.md index a0f8555b..25826309 100644 --- a/docs/spock_functions/functions/spock_repset_remove_seq.md +++ b/docs/spock_functions/functions/spock_repset_remove_seq.md @@ -11,7 +11,9 @@ spock.repset_remove_seq ( ### RETURNS - true if the sequence was successfully removed from the replication set. - - false if the sequence was not a member of the replication set. + - Raises an ERROR if the sequence is not a member of the replication + set, or if the call has invalid parameters or insufficient + privileges. ### DESCRIPTION diff --git a/docs/spock_functions/functions/spock_repset_remove_table.md b/docs/spock_functions/functions/spock_repset_remove_table.md index 7c0a34f5..9e562bab 100644 --- a/docs/spock_functions/functions/spock_repset_remove_table.md +++ b/docs/spock_functions/functions/spock_repset_remove_table.md @@ -12,7 +12,8 @@ spock.repset_remove_table ( ### RETURNS - true if the table was successfully removed from the replication set. - - false if the table was not a member of the replication set. + - Raises an ERROR if the table is not a member of the replication set, + or if the call has invalid parameters or insufficient privileges. ### DESCRIPTION diff --git a/docs/spock_functions/functions/spock_sub_add_repset.md b/docs/spock_functions/functions/spock_sub_add_repset.md index 74bb1edb..db37e088 100644 --- a/docs/spock_functions/functions/spock_sub_add_repset.md +++ b/docs/spock_functions/functions/spock_sub_add_repset.md @@ -10,7 +10,9 @@ spock.sub_add_repset (subscription_name name, replication_set name) - true if the replication set was successfully added. - - false if the operation fails. + - Raises an ERROR if the subscription does not exist, the replication + set is already attached, or the call has invalid parameters or + insufficient privileges. ### DESCRIPTION diff --git a/docs/spock_functions/functions/spock_sub_alter_interface.md b/docs/spock_functions/functions/spock_sub_alter_interface.md index 68c24994..1b0bd350 100644 --- a/docs/spock_functions/functions/spock_sub_alter_interface.md +++ b/docs/spock_functions/functions/spock_sub_alter_interface.md @@ -10,7 +10,8 @@ spock.sub_alter_interface (subscription_name name, interface_name name) - true if the interface was successfully changed. - - false if the operation fails. + - Raises an ERROR if the subscription or interface does not exist, or + if the call has invalid parameters or insufficient privileges. ### DESCRIPTION diff --git a/docs/spock_functions/functions/spock_sync_event.md b/docs/spock_functions/functions/spock_sync_event.md index 6dca7b1d..9b3acd14 100644 --- a/docs/spock_functions/functions/spock_sync_event.md +++ b/docs/spock_functions/functions/spock_sync_event.md @@ -6,7 +6,7 @@ replication stream and returns its Log Sequence Number (LSN). ## Synopsis ```sql -spock.sync_event() +spock.sync_event(transactional boolean DEFAULT false) ``` ## Returns @@ -38,7 +38,11 @@ This function modifies the replication stream by inserting a sync marker. ## Arguments -The function takes no arguments. +- `transactional` (optional, default `false`) - When `false`, the sync + event marker is emitted immediately into the WAL stream, independent of + the calling transaction. When `true`, the marker is bound to the calling + transaction and is only visible to subscribers if the transaction + commits. ## Example diff --git a/docs/spock_functions/gen_mgmt.md b/docs/spock_functions/gen_mgmt.md index 7f00bc07..1371f703 100644 --- a/docs/spock_functions/gen_mgmt.md +++ b/docs/spock_functions/gen_mgmt.md @@ -5,11 +5,11 @@ You can use the following settings to manage your replication clusters. | Command | Description |----------|------------- | [spock.get_country](functions/spock_get_country.md) | Returns the country code configured for the node. | -| [spock.max_proto_version](functions/spock_max_proto_version.md) | Returns the maximum protocol version supported by Spock. | -| [spock.min_proto_version](functions/spock_min_proto_version.md) | Returns the minimum protocol version supported by Spock. | +| [spock_max_proto_version](functions/spock_max_proto_version.md) | Returns the maximum protocol version supported by Spock. Defined in the public schema (no `spock.` prefix). | +| [spock_min_proto_version](functions/spock_min_proto_version.md) | Returns the minimum protocol version supported by Spock. Defined in the public schema (no `spock.` prefix). | | [spock.node_info](functions/spock_node_info.md) | Returns information about the local Spock node. | -| [spock.version](functions/spock_version.md) | Returns the version string of the Spock extension. | -| [spock.version_num](functions/spock_version_num.md) | Returns the version number of Spock as an integer. | +| [spock_version](functions/spock_version.md) | Returns the version string of the Spock extension. Defined in the public schema (no `spock.` prefix). | +| [spock_version_num](functions/spock_version_num.md) | Returns the version number of Spock as an integer. Defined in the public schema (no `spock.` prefix). | ## spock.get_country @@ -29,12 +29,13 @@ rules. This function takes no arguments. -## spock.max_proto_version +## spock_max_proto_version -Use `spock.max_proto_version` to retrieve the maximum protocol version -supported by Spock. +Use `spock_max_proto_version` to retrieve the maximum protocol version +supported by Spock. This function is defined in the public schema (no +`spock.` prefix). -`spock.max_proto_version()` +`spock_max_proto_version()` Returns the maximum protocol version supported by the Spock extension. @@ -50,12 +51,13 @@ different Spock releases. This function takes no arguments. -## spock.min_proto_version +## spock_min_proto_version -Use `spock.min_proto_version` to retrieve the minimum protocol version -supported by Spock. +Use `spock_min_proto_version` to retrieve the minimum protocol version +supported by Spock. This function is defined in the public schema (no +`spock.` prefix). -`spock.min_proto_version()` +`spock_min_proto_version()` Returns the minimum protocol version supported by the Spock extension. @@ -83,11 +85,12 @@ optional descriptive fields that were set during node creation. This function takes no arguments. -## spock.version +## spock_version -Use `spock.version` to retrieve the version string of the Spock extension. +Use `spock_version` to retrieve the version string of the Spock extension. +This function is defined in the public schema (no `spock.` prefix). -`spock.version()` +`spock_version()` Returns the version number of the Spock extension. @@ -97,12 +100,12 @@ string. The version string typically follows semantic versioning format This function takes no arguments. -## spock.version_num +## spock_version_num -Use `spock.version_num` to retrieve the version number of Spock as an -integer. +Use `spock_version_num` to retrieve the version number of Spock as an +integer. This function is defined in the public schema (no `spock.` prefix). -`spock.version_num()` +`spock_version_num()` Returns the version number of the Spock extension as an integer. diff --git a/docs/spock_functions/index.md b/docs/spock_functions/index.md index 5e2fcb37..9e31a544 100644 --- a/docs/spock_functions/index.md +++ b/docs/spock_functions/index.md @@ -20,9 +20,9 @@ The following user functions are available via the Spock extension: | [spock.repset_add_all_tables](functions/spock_repset_add_all_tables.md) | Add all existing table(s) to the replication set. | [spock.repset_remove_table](functions/spock_repset_remove_table.md) | Remove table from replication set. | spock.repset_show_table | -| [repset_add_seq](functions/spock_repset_add_seq.md) | Deprecated; Adds a sequence to a replication set. -| [repset_add_all_seqs](functions/spock_repset_add_all_seqs.md) | Deprecated; Adds all sequences from the specified schemas to a replication set. -| [repset_remove_seq](functions/spock_repset_remove_seq.md) | Deprecated; Remove a sequence from a replication set. +| [spock.repset_add_seq](functions/spock_repset_add_seq.md) | Adds a sequence to a replication set. +| [spock.repset_add_all_seqs](functions/spock_repset_add_all_seqs.md) | Adds all sequences from the specified schemas to a replication set. +| [spock.repset_remove_seq](functions/spock_repset_remove_seq.md) | Remove a sequence from a replication set. | spock.sync_seq | Synchronize the specified sequence. | **Subscription Management Functions** | | | [spock.sub_create](functions/spock_sub_create.md) | Create a subscription. @@ -41,16 +41,16 @@ The following user functions are available via the Spock extension: | **Miscellaneous Management Functions** | | | [spock.table_wait_for_sync](functions/spock_table_wait_for_sync.md) | Pause until a table finishes synchronizing. | [spock.replicate_ddl](functions/spock_replicate_ddl.md) | Enable DDL replication. -| spock.spock_version | Returns the Spock version in a major/minor version form: `4.0.10`. -| spock.spock_version_num | Returns the Spock version in a single numeric form: `40010`. +| spock_version | Returns the Spock version in a major/minor version form: `4.0.10`. Defined in the public schema (no `spock.` prefix). +| spock_version_num | Returns the Spock version in a single numeric form: `40010`. Defined in the public schema (no `spock.` prefix). | spock.get_channel_stats | Returns tuple traffic statistics. | spock.get_country | Returns the country code if explicitly set; returns `??` if not set. | spock.lag_tracker | Returns a list of slots, with commit_lsn and commit_timestamp for each. | spock.repair_mode | Used to manage the state of replication - If set to `true`, stops replicating statements; when `false`, resumes replication. | spock.replicate_ddl | Replicate a specific statement. | spock.reset_channel_stats | Reset the channel statistics. -| spock.spock_max_proto_version | The highest Spock native protocol supported by the current binary/build. -| spock.spock_min_proto_version | The lowest build for which this Spock binary is backward compatible. +| spock_max_proto_version | The highest Spock native protocol supported by the current binary/build. Defined in the public schema (no `spock.` prefix). +| spock_min_proto_version | The lowest build for which this Spock binary is backward compatible. Defined in the public schema (no `spock.` prefix). | spock.table_data_filtered | Scans the specified table and returns rows that match the row filter from the specified replication set(s). Row filters are added to a replication set when adding a table with `repset_add_table`. | spock.terminate_active_transactions | Terminates all active transactions. | spock.wait_slot_confirm_lsn | Wait for the `confirmed_flush_lsn` of the specified slot, or all logical slots if none given. diff --git a/docs/spock_functions/repset_mgmt.md b/docs/spock_functions/repset_mgmt.md index ef98ac8b..e1153f20 100644 --- a/docs/spock_functions/repset_mgmt.md +++ b/docs/spock_functions/repset_mgmt.md @@ -132,26 +132,30 @@ Parameters: Use `spock.repset_alter` to change the parameters of an existing replication set. -`spock.repset_alter(set_name name, replicate_inserts bool, -replicate_updates bool, replicate_deletes bool, replicate_truncate bool)` +`spock.repset_alter(set_name name, replicate_insert bool DEFAULT NULL, +replicate_update bool DEFAULT NULL, replicate_delete bool DEFAULT NULL, +replicate_truncate bool DEFAULT NULL)` Parameters: - `set_name` is the name of an existing replication set that will be modified by this function. -- `replicate_insert` is `true` if `INSERT` statements are replicated; the default is `true`. -- `replicate_update` is `true` if `UPDATE` statements are replicated; the default is `true`. -- `replicate_delete` is `true` if `DELETE` statements are replicated; the default is `true`. -- `replicate_truncate` is `true` if `TRUNCATE` statements are replicated; the default is `true`. +- `replicate_insert` is `true` if `INSERT` statements are replicated. Pass `NULL` (the default) to leave the current value unchanged. +- `replicate_update` is `true` if `UPDATE` statements are replicated. Pass `NULL` (the default) to leave the current value unchanged. +- `replicate_delete` is `true` if `DELETE` statements are replicated. Pass `NULL` (the default) to leave the current value unchanged. +- `replicate_truncate` is `true` if `TRUNCATE` statements are replicated. Pass `NULL` (the default) to leave the current value unchanged. ### spock.repset_drop Use `spock.repset_drop` to remove the specified replication set. -`spock.repset_drop(set_name text)` +`spock.repset_drop(set_name name, ifexists boolean DEFAULT false)` Parameters: - `set_name` is the name of an existing replication set. +- `ifexists` controls whether dropping a non-existent replication set + raises an error. When `true`, no error is raised if the set is missing; + the default is `false`. ### spock.repset_add_table @@ -188,7 +192,7 @@ Use `spock.repset_add_all_tables` to add all tables in the specified schemas to the replication set. `spock.repset_add_all_tables(set_name name, schema_names text[], -sync_data boolean)` +synchronize_data boolean DEFAULT false)` Only existing tables are added; tables that will be created in the future will not be added automatically. @@ -198,41 +202,45 @@ Parameters: - `set_name` is the name of an existing replication set. - `schema_names` is an array of names of existing schemas from which tables should be added. -- `sync_data` instructs Spock to synchronize the table data on all nodes - which are subscribed to the given replication set when set to `true`; the - default is `false`. +- `synchronize_data` instructs Spock to synchronize the table data on all + nodes which are subscribed to the given replication set when set to + `true`; the default is `false`. ### spock.repset_remove_table Use `spock.repset_remove_table` to remove a table from a replication set. -`spock.repset_remove_table(set_name name, relation regclass)` +`spock.repset_remove_table(set_name name, relation regclass, +include_partitions boolean DEFAULT true)` Parameters: - `set_name` is the name of an existing replication set. - `relation` is the name or OID of the table to be removed from the set. +- `include_partitions` is `true` to also remove partitions of the + partitioned table; the default is `true`. ### spock.repset_add_seq Use `spock.repset_add_seq` to add a sequence to a replication set. -`spock.repset_add_seq(set_name name, relation regclass, sync_data boolean)` +`spock.repset_add_seq(set_name name, relation regclass, +synchronize_data boolean DEFAULT false)` Parameters: - `set_name` is the name of an existing replication set. - `relation` is the name or OID of the sequence to be added to the set. -- `sync_data` instructs Spock to synchronize the table data on all nodes - which are subscribed to the given replication set when set to `true`; the - default is `false`. +- `synchronize_data` instructs Spock to synchronize the sequence on all + nodes which are subscribed to the given replication set when set to + `true`; the default is `false`. ### spock.repset_add_all_seqs Use `spock.repset_add_all_seqs` to add all sequences from the given schemas. `spock.repset_add_all_seqs(set_name name, schema_names text[], -sync_data boolean)` +synchronize_data boolean DEFAULT false)` Only existing sequences are added; any sequences that will be created in the future will not be added automatically. @@ -242,8 +250,8 @@ Parameters: - `set_name` is the name of an existing replication set. - `schema_names` is an array of names of existing schemas from which sequences should be added. -- `sync_data` specify `true` to synchronize the sequence value immediately; - the default is `false`. +- `synchronize_data` specify `true` to synchronize the sequence value + immediately; the default is `false`. ### spock.repset_remove_seq diff --git a/docs/spock_functions/sub_mgmt.md b/docs/spock_functions/sub_mgmt.md index e2ced9a6..e6cfc7d7 100644 --- a/docs/spock_functions/sub_mgmt.md +++ b/docs/spock_functions/sub_mgmt.md @@ -15,7 +15,7 @@ the publisher. | [spock.sub_alter_sync](functions/spock_sub_alter_sync.md) | Synchronize all unsynchronized tables in a single operation. | [spock.sub_resync_table](functions/spock_sub_resync_table.md) | Resynchronize a single table. | [spock.sub_wait_for_sync](functions/spock_sub_wait_for_sync.md) | Wait for a subscription to finish synchronization after a `spock.sub_create` or `spock.sub_alter_sync`. -| [spock.sub_wait_table_sync](functions/spock_table_wait_for_sync.md) | Same as `spock.sub_wait_for_sync`, but waits only for the subscription's initial sync. +| [spock.table_wait_for_sync](functions/spock_table_wait_for_sync.md) | Wait only for the subscription's initial sync and a named table. | [spock.sub_show_status](functions/spock_sub_show_status.md) | Shows status and basic information about subscription. | [spock.sub_show_table](functions/spock_sub_show_table.md) | Shows synchronization status of a table. | [spock.sub_add_repset](functions/spock_sub_add_repset.md) | Adds a replication set to a subscriber. @@ -29,7 +29,7 @@ connect to the server with psql and invoke the `spock.sub_create` command: ```sql SELECT spock.sub_create(subscription_name, provider_dsn, replication_sets, synchronize_structure, synchronize_data, forward_origins, apply_delay, - force_text_transfer) + force_text_transfer, enabled, skip_schema) ``` Parameters include: @@ -39,11 +39,11 @@ Parameters include: - `replication_sets` is an array of replication sets that you wish to subscribe to. The sets must already exist; the default is `{default,default_insert_only,ddl_sql}`. -- `sync_structure` is a boolean value that specifies if Spock should +- `synchronize_structure` is a boolean value that specifies if Spock should synchronize the structure from provider to the subscriber; the default is `false`. -- `sync_data` specifies if Spock should synchronize data from provider to the - subscriber; the default is `true`. +- `synchronize_data` specifies if Spock should synchronize data from + provider to the subscriber; the default is `false`. - `forward_origins` is an array of origin names to forward. Currently, the only supported values are an empty array meaning don't forward any changes that didn't originate on provider node (this is useful for two-way @@ -55,12 +55,18 @@ Parameters include: 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`. +- `enabled` controls whether the subscription is started immediately after + creation. The default is `true`. +- `skip_schema` is an array of schema names whose changes should be ignored + by the apply worker. The default is `{}` (an empty array, meaning no + schemas are skipped). For example, the following command: ```sql -SELECT spock.sub_create(accts, - 'host=178.12.15.12 user=carol dbname=accounting', payables) +SELECT spock.sub_create('accts', + 'host=178.12.15.12 user=carol dbname=accounting', + ARRAY['payables']); ``` Creates a subscription named `accts` that connects to the `accounting` @@ -86,7 +92,7 @@ Parameters include: For example, the following command: ```sql -SELECT spock.sub_drop(accts, true) +SELECT spock.sub_drop('accts', true); ``` Drops a subscription named `accts`; if the subscription does not exist, an @@ -103,9 +109,10 @@ You can use the following settings to control and manage your subscriptions. Use `spock.sub_create` to create a subscription from current node to the provider node. -`spock.sub_create(subscription_name name, provider_dsn text, repsets text[], -sync_structure boolean, sync_data boolean, forward_origins text[], -apply_delay interval)` +`spock.sub_create(subscription_name name, provider_dsn text, +replication_sets text[], synchronize_structure boolean, +synchronize_data boolean, forward_origins text[], apply_delay interval, +force_text_transfer boolean, enabled boolean, skip_schema text[])` The command does not wait for completion before returning to the caller. @@ -113,12 +120,12 @@ Parameters: - `subscription_name` is the unique name of the subscription. - `provider_dsn` is the connection string to a provider. -- `repsets` is an array of existing replication sets to which you are - subscribing. The default is `{default,default_insert_only,ddl_sql}`. -- `sync_structure` tells Spock if it should synchronize the structure from - the provider to the subscriber; the default is `false`. -- `sync_data` tells Spock to synchronize data from provider to the - subscriber; the default is `true`. +- `replication_sets` is an array of existing replication sets to which you + are subscribing. The default is `{default,default_insert_only,ddl_sql}`. +- `synchronize_structure` tells Spock if it should synchronize the + structure from the provider to the subscriber; the default is `false`. +- `synchronize_data` tells Spock to synchronize data from provider to the + subscriber; the default is `false`. - `forward_origins` is an array of origin names to forward. Currently, the only supported values are an empty array meaning don't forward any changes that didn't originate on the provider node (this is useful for two-way @@ -128,8 +135,12 @@ Parameters: is `0` seconds. - `force_text_transfer` forces 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) when set to `yes`. The default + of a replicated column on the subscriber) when set to `true`. The default is `false`. +- `enabled` controls whether the subscription is started immediately after + creation. The default is `true`. +- `skip_schema` is an array of schema names whose changes should be ignored + by the apply worker. The default is `{}`. The `subscription_name` is used as `application_name` by the replication connection. This means that it's visible in the `pg_stat_replication` @@ -222,7 +233,7 @@ The table may not be the target of any foreign key constraints. This function will truncate the table immediately, and only then begin synchronising it, so it will be empty while being synced. The command does not wait for completion before returning to the caller; use - `spock.wait_for_table_sync` to wait for completion. + `spock.table_wait_for_sync` to wait for completion. Parameters: @@ -248,12 +259,12 @@ For best results, run `SELECT spock.wait_slot_confirm_lsn(NULL, NULL)` on the provider after any replication set changes that requested resyncs, and only then call `spock.sub_wait_for_sync` on the subscriber. -### spock.sub_wait_table_sync +### spock.table_wait_for_sync -Use `spock.sub_wait_table_sync` to wait only for the subscription's initial +Use `spock.table_wait_for_sync` to wait only for the subscription's initial sync and the named table. -`spock.sub_wait_table_sync(subscription_name name, relation regclass)` +`spock.table_wait_for_sync(subscription_name name, relation regclass)` Same as `spock.sub_wait_for_sync`, but waits only for the subscription's initial sync and the named table. Other tables pending resynchronisation are @@ -285,14 +296,18 @@ up to a certain point on the provider. Use `spock.sub_show_status` to show status and basic information about a subscription. -`spock.sub_show_status(subscription_name name)` +`spock.sub_show_status(subscription_name name DEFAULT NULL)` Parameters: - `subscription_name` is the optional name of an existing subscription. If - no name is provided, the function will show the status of all + omitted (or `NULL`), the function will show the status of all subscriptions on the local node. +The function returns one row per subscription with these columns: +`subscription_name`, `status`, `provider_node`, `provider_dsn`, +`slot_name`, `replication_sets`, `forward_origins`. + ### spock.sub_show_table Use `spock.sub_show_table` to show the synchronization status of a table. From e50b92885afe2b33d72c669a080e42b4a1eba694 Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Thu, 7 May 2026 18:46:34 +0500 Subject: [PATCH 02/10] docs: fix GUC documentation and conflict resolution claims --- docs/configuring.md | 16 ++++++---------- docs/conflict_types.md | 10 +++------- docs/managing/read_only.md | 12 +++++++++--- docs/managing/spock_autoddl.md | 9 +++++++++ docs/spock_release_notes.md | 2 +- docs/troubleshooting.md | 17 ++++++++--------- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/docs/configuring.md b/docs/configuring.md index def196a1..a2926dab 100644 --- a/docs/configuring.md +++ b/docs/configuring.md @@ -97,16 +97,12 @@ inadvertently create orphaned foreign key records. ### `spock.conflict_resolution` `spock.conflict_resolution` sets the resolution method for any detected -conflicts between local data and incoming changes. Possible values include: +conflicts between local data and incoming changes. The only supported value +in current Spock releases is: -- `error` - the replication will stop on error if a conflict is detected and - manual action is required to resolve the conflict. -- `apply_remote` - always apply the change that's conflicting with local - data. -- `keep_local` - keep the local version of the data and ignore the - conflicting change that is coming from the remote node. -- `last_update_wins` - the version of data with newest commit timestamp - will be kept (this can be either local or remote version). +- `last_update_wins` (the default) - the version of data with the newest + commit timestamp will be kept (this can be either the local or the remote + version). To enable conflict resolution, the `track_commit_timestamp` setting must be enabled. @@ -142,7 +138,7 @@ an ERROR within a transaction: that is written to the WAL log file; when the subscription is enabled, replication will resume with the transaction that caused the exception, followed by the other queued transactions; you can use the - `spock.alter_sub_skip_lsn` function to skip the transaction that caused + `spock.sub_alter_skiplsn` function to skip the transaction that caused the exception and resume processing with the next transaction in the queue. diff --git a/docs/conflict_types.md b/docs/conflict_types.md index 190d1835..e5262abf 100644 --- a/docs/conflict_types.md +++ b/docs/conflict_types.md @@ -160,18 +160,14 @@ kept (`skip` / `keep_local`). The event is recorded in the ### Conflict Resolution Strategies The `spock.conflict_resolution` GUC controls how resolvable conflicts -(all types except `update_missing` and `update_exists`) are decided: +(all types except `update_missing` and `update_exists`) are decided. In +current Spock releases the only supported value is: | Strategy | Behavior | |-----------------------|-----------------------------------------------------------| | `last_update_wins` | The row with the most recent commit timestamp wins (default). | -| `first_update_wins` | The row with the earliest commit timestamp wins. | -| `apply_remote` | Always apply the incoming remote change. | -| `keep_local` | Always keep the local row. | -| `error` | Raise an ERROR on any conflict. | -The timestamp-based strategies (`last_update_wins` and -`first_update_wins`) require `track_commit_timestamp = on` in +`last_update_wins` requires `track_commit_timestamp = on` in `postgresql.conf`. **Tiebreaker:** When two rows have identical commit timestamps, Spock diff --git a/docs/managing/read_only.md b/docs/managing/read_only.md index a12c28e4..87ad56bd 100644 --- a/docs/managing/read_only.md +++ b/docs/managing/read_only.md @@ -72,9 +72,15 @@ COMMIT; ## Behavior of `all` mode -In `all` mode, apply workers detect the setting and stop consuming inbound WAL. -When the mode is switched back to `off` or `local`, replication resumes from -where it left off — no data is lost. +In `all` mode, apply workers detect the setting and stop consuming inbound +WAL — internally each worker raises a FATAL and exits, and the manager +restarts it once read-only is cleared. When the mode is switched back to +`off` or `local`, replication resumes from where it left off, **provided +the upstream replication slot still retains the necessary WAL**. Plan for +slot retention (`max_slot_wal_keep_size`, disk capacity) before placing a +node in `all` mode for an extended period; if the upstream slot is +recycled while the node is read-only, replication cannot resume from the +prior position and the node will need to be re-synchronized. Notes: - Only superusers can set and unset the `spock.readonly` parameter. diff --git a/docs/managing/spock_autoddl.md b/docs/managing/spock_autoddl.md index f4001a0c..d4666afd 100644 --- a/docs/managing/spock_autoddl.md +++ b/docs/managing/spock_autoddl.md @@ -29,6 +29,15 @@ automatic DDL replication, set the following parameters to `on`: will be added into the `default` replication set; alternatively, they will be added to the `default_insert_only` replication set. +To completely block all DDL across the cluster (including DDL that would +otherwise be replicated automatically), use: + +* `spock.deny_all_ddl` is a boolean (default `false`). When set to `true`, + Spock rejects any DDL statement executed on the node. This is useful as a + guard during sensitive maintenance windows or while a node is being added + or repaired. The setting can be changed by a superuser at runtime + (`PGC_SUSET`); a server reload is not required. + It's best to set these parameters to `on` only when the database schema matches exactly on all nodes - either when all databases have no objects, or when all databases have exactly the same objects and all tables are added to diff --git a/docs/spock_release_notes.md b/docs/spock_release_notes.md index 03b2ce95..4256236e 100644 --- a/docs/spock_release_notes.md +++ b/docs/spock_release_notes.md @@ -25,7 +25,7 @@ origin. Now no restriction exists. Spock will use memory until memory is exhausted (improving performance for huge transactions). If an allocation fails, Spock -performs as specified by the spock.exception_behavior GUC: +performs as specified by the spock.exception_behaviour GUC: Exception handling behavior is now controlled by the `spock.exception_behaviour` GUC, which accepts the following values: diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index f65f1abc..1d3c3050 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -203,11 +203,8 @@ resolution setting with this query: SHOW spock.conflict_resolution; ``` -The following values are available: +The only supported value is: -- `error` - Stop replication on conflict (requires manual resolution). -- `apply_remote` - Always apply the remote change. -- `keep_local` - Keep the local version. - `last_update_wins` - Keep the version with the newest commit timestamp. To change the setting, use the following command: @@ -374,7 +371,7 @@ If DDL replication was disabled for the upgrade, re-enable it on all nodes with the following commands: ```sql -SELECT spock.replicate_ddl('SET spock.enable_ddl_replication = on'); +ALTER SYSTEM SET spock.enable_ddl_replication = on; SELECT pg_reload_conf(); ``` @@ -419,14 +416,16 @@ following command: ```sql SELECT spock.repset_add_partition( - set_name := 'default', - relation := 'public.parent_table', - partition_name := 'public.new_partition' + parent := 'public.parent_table', + partition := 'public.new_partition' ); ``` The parent table is synced during initial sync, but new partitions -created after sync must be added explicitly. +created after sync must be added explicitly. Pass `partition := NULL` +(or omit it) to add every existing partition of the parent at once. +You can also pass an optional `row_filter` argument to restrict which +rows from the partition are replicated. ## Checking Logs From 2fafb3a108dd6f20aa0fbd709a2717891456a600 Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Thu, 7 May 2026 18:46:34 +0500 Subject: [PATCH 03/10] docs: fix tutorial commands, monitoring views, and broken links --- README.md | 2 +- docs/limitations.md | 2 +- docs/modify/zodan/zodan_tutorial.md | 46 +++++++++++----------- docs/monitoring/spock_info.md | 6 +-- docs/monitoring/spock_sync_event.md | 17 ++++++-- docs/recovery/catastrophic_node_failure.md | 25 +++++++----- docs/two_node_cluster.md | 4 +- 7 files changed, 59 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 090c5c42..f09d1b4b 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ primary key, btree, for table "public.table_a" * `CHECK` constraints and `NOT NULL` constraints must be the same or more permissive on any standby node that acts only as a subscriber. -For more information about the Spock extension's advanced functionality, visit [here](docs/features.md). +For more information about the Spock extension's advanced functionality, visit the [Spock documentation](docs/index.md). ## Building the Spock Extension diff --git a/docs/limitations.md b/docs/limitations.md index c93df1ad..6848c193 100644 --- a/docs/limitations.md +++ b/docs/limitations.md @@ -50,7 +50,7 @@ Partial secondary unique indexes are permitted, but will be ignored for conflict resolution purposes. `spock.check_all_uc_indexes` is an experimental -[GUC](https://github.com/pgEdge/spock/blob/main/docs/guc_settings.md) that +[GUC](configuring.md) that adds `INSERT` conflict resolution by allowing Spock to consider all unique constraints, not just the primary key or replica identity. diff --git a/docs/modify/zodan/zodan_tutorial.md b/docs/modify/zodan/zodan_tutorial.md index 7086e8af..02a26281 100644 --- a/docs/modify/zodan/zodan_tutorial.md +++ b/docs/modify/zodan/zodan_tutorial.md @@ -154,7 +154,7 @@ FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=pgedge password=1safepassword', 'SELECT extversion FROM pg_extension WHERE extname = ''spock''' ) AS t(version text); --- Expected: 5.0.4 +-- Expected: matches the version installed on every node in the cluster -- Check new node version SELECT version @@ -162,7 +162,7 @@ FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=pgedge password=1safepassword', 'SELECT extversion FROM pg_extension WHERE extname = ''spock''' ) AS t(version text); --- Expected: 5.0.4 +-- Expected: matches the version installed on every node in the cluster -- Check all existing cluster nodes (n2, n3) SELECT node_name, version @@ -173,12 +173,12 @@ FROM dblink( FROM spock.node n' ) AS t(node_name text, version text); --- Expected output: --- node_name | version --- -----------+-------------- --- n1 | 5.0.4 --- n2 | 5.0.4 --- n3 | 5.0.4 +-- Expected output: every node reports the same Spock version, e.g. +-- node_name | version +-- -----------+---------- +-- n1 | 5.0.6 +-- n2 | 5.0.6 +-- n3 | 5.0.6 ``` ### Validate Prerequisites @@ -597,8 +597,8 @@ FROM dblink( SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', - 'CALL spock.wait_for_sync_event(true, ''n2'', ''0/1C9F400''::pg_lsn, 1200000)' -) AS t(result text); + 'CALL spock.wait_for_sync_event(true, ''n2'', ''0/1C9F400''::pg_lsn, 1200)' +) AS t(result bool); ``` #### Sync n3 to n1 @@ -623,8 +623,8 @@ FROM dblink( SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', - 'CALL spock.wait_for_sync_event(true, ''n3'', ''0/1D0E510''::pg_lsn, 1200000)' -) AS t(result text); + 'CALL spock.wait_for_sync_event(true, ''n3'', ''0/1D0E510''::pg_lsn, 1200)' +) AS t(result bool); ``` ### Copy the Source to New Subscription @@ -752,7 +752,7 @@ FROM dblink( On n4, wait for the sync marker that matches the returned LSN (0/1E1F620) to arrive and be processed. This is a blocking call; the call will not return until the n4 subscription from n1 has replicated up to this LSN. -The timeout (1200000 milliseconds = 20 minutes) prevents waiting forever +The timeout (1200 seconds = 20 minutes) prevents waiting forever if something goes wrong. In the following example, the command waits for the sync event on n4: @@ -761,8 +761,8 @@ In the following example, the command waits for the sync event on n4: SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', - 'CALL spock.wait_for_sync_event(true, ''n1'', ''0/1E1F620''::pg_lsn, 1200000)' -) AS t(result text); + 'CALL spock.wait_for_sync_event(true, ''n1'', ''0/1E1F620''::pg_lsn, 1200)' +) AS t(result bool); ``` @@ -844,7 +844,7 @@ FROM dblink( ) SELECT pg_replication_slot_advance(''spk_inventory_n2_sub_n2_n4'', lsn) FROM lsn_cte' -) AS t(result text); +) AS t(result bool); ``` #### Repeat for n3 to n4 @@ -875,7 +875,7 @@ FROM dblink( ) SELECT pg_replication_slot_advance(''spk_inventory_n3_sub_n3_n4'', lsn) FROM lsn_cte' -) AS t(result text); +) AS t(result bool); ``` @@ -925,7 +925,7 @@ FROM dblink( subscription_name := ''sub_n2_n4'', immediate := true )' -) AS t(result text); +) AS t(result bool); ``` #### Wait for Stored Sync Event from n2 @@ -948,8 +948,8 @@ SELECT sync_lsn FROM temp_sync_lsns WHERE origin_node = 'n2'; SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', - 'CALL spock.wait_for_sync_event(true, ''n2'', ''0/1A7D1E0''::pg_lsn, 1200000)' -) AS t(result text); + 'CALL spock.wait_for_sync_event(true, ''n2'', ''0/1A7D1E0''::pg_lsn, 1200)' +) AS t(result bool); ``` #### Verify the Subscription is Replicating @@ -991,7 +991,7 @@ FROM dblink( subscription_name := ''sub_n3_n4'', immediate := true )' -) AS t(result text); +) AS t(result bool); -- Retrieve stored LSN SELECT sync_lsn FROM temp_sync_lsns WHERE origin_node = 'n3'; @@ -1001,8 +1001,8 @@ SELECT sync_lsn FROM temp_sync_lsns WHERE origin_node = 'n3'; SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', - 'CALL spock.wait_for_sync_event(true, ''n3'', ''0/1B8E2F0''::pg_lsn, 1200000)' -) AS t(result text); + 'CALL spock.wait_for_sync_event(true, ''n3'', ''0/1B8E2F0''::pg_lsn, 1200)' +) AS t(result bool); -- Verify status SELECT subscription_name, status, provider_node diff --git a/docs/monitoring/spock_info.md b/docs/monitoring/spock_info.md index 316ad80f..8ce097ab 100644 --- a/docs/monitoring/spock_info.md +++ b/docs/monitoring/spock_info.md @@ -4,8 +4,8 @@ The following table describes informational tables in the `spock` schema: | Table Name | Description | |---------------------|----------------------------| -| `channel_summary_stats` | This table tracks per-table statistics for a given subscription, including total inserts, updates, deletes, conflicts, and delta apply column changes. The table includes the following columns: `subid`, `sub_name`, `n_tup_ins`, `n_tup_upd`, `n_tup_del`, `n_conflict`, `n_dca` | -| `channel_table_stats` | This table is similar to `channel_summary_stats`, but aggregates statistics across subscriptions, showing overall metrics grouped by subscription. The table includes the following columns: `subid`, `relid`, `sub_name`, `table_name`, `n_tup_ins`, `n_tup_upd`, `n_tup_del`, `n_conflict`, `n_dca` | +| `channel_table_stats` | This view tracks per-table statistics for a given subscription, including total inserts, updates, deletes, conflicts, and delta apply column changes. The view includes the following columns: `subid`, `relid`, `sub_name`, `table_name`, `n_tup_ins`, `n_tup_upd`, `n_tup_del`, `n_conflict`, `n_dca` | +| `channel_summary_stats` | This view aggregates statistics from `channel_table_stats` across tables, showing overall metrics grouped by subscription. The view includes the following columns: `subid`, `sub_name`, `n_tup_ins`, `n_tup_upd`, `n_tup_del`, `n_conflict`, `n_dca` | | `depend` | This is an internal-use table that tracks dependent objects (e.g., tables added for replication or row filters). If such objects are dropped, they are also removed from Spock’s tracking. The table includes the following columns: `classid`, `objid`, `objsubid`, `refclassid`, `refobjid`, `refobjsubid`, `deptype` | | `exception_log` | This table logs unrecoverable errors or conflicts encountered by Spock during the replication process. The table includes the following columns: `remote_origin`, `remote_commit_ts`, `command_counter`, `retry_errored_at`, `remote_xid`, `local_origin`, `local_commit_ts`, `table_schema`, `table_name`, `operation` (contains one of the following: `BEGIN`, `COMMIT`, `INSERT`, `UPDATE`, `DELETE`, or `DDL`), `local_tup`, `remote_old_tup`, `remote_new_tup`, `ddl_statement`, `ddl_user`, `error_message` | | `exception_status` | This table is not used internally by Spock. This table exists to support ACE by tracking specific status details. The table includes the following information columns: `remote_origin`, `remote_commit_ts`, `retry_errored_at`, `remote_xid`, `status`, `resolved_at`, `resolution_details` | @@ -22,7 +22,7 @@ The following table describes informational tables in the `spock` schema: | `replication_set_table` | This table contains one row per table that is in any replication set. It contains the `set_id`, `set_reloid` (the table name), `set_att_list`, and `set_row_filter`. The last two columns contain the row and column filters on that table for replication. | | `resolutions` | This table contains one row per resolution made on this node. It contains the `id`, `node_name`, `log_time`, `relname`, `idxname`, `conflict_type` (`update_update`), `conflict_resolution` (`keep_local`), `local_origin`, `local_tuple`, `local_xid, local_timestamp`, `remote_origin`, `remote_tuple`, `remote_xid`, `remote_timestamp`, `remote_lsn`. | | `sequence_state` | This is an internal-use table that stores state information for native sequence synchronization. The table includes the following columns: `seqoid`, `cache_size`, `last_value` | -| `subscription` | This table contains one row per subscription. It contains the following columns: `sub_id`, `sub_name`, `sub_origin`, `sub_target`, `sub_origin_if`, `sub_target_if`, `sub_enabled`, `sub_slot_name`, `sub_replication_sets` (an array of replication sets that have been added to the subscription), `sub_forward_origins`, `sub_apply_delay`, and `sub_force_text_transfer`. | +| `subscription` | This table contains one row per subscription. It contains the following columns: `sub_id`, `sub_name`, `sub_origin`, `sub_target`, `sub_origin_if`, `sub_target_if`, `sub_enabled`, `sub_slot_name`, `sub_replication_sets` (an array of replication sets that have been added to the subscription), `sub_forward_origins`, `sub_apply_delay`, `sub_force_text_transfer`, `sub_skip_lsn` (a `pg_lsn` set by `spock.sub_alter_skiplsn`), `sub_skip_schema` (an array of schemas to skip during apply), and `sub_created_at` (timestamp of subscription creation). | | `tables` | This table contains one row per table in the database. It contains the following columns: `relid`, `nspname` (the schema), `relname` (the tablename), and `set_name` (`null` if that table is not added to any replication set). | ## Examples diff --git a/docs/monitoring/spock_sync_event.md b/docs/monitoring/spock_sync_event.md index 6e968ed6..7d7433f2 100644 --- a/docs/monitoring/spock_sync_event.md +++ b/docs/monitoring/spock_sync_event.md @@ -24,7 +24,13 @@ Invoked on the provider node, this function returns the current `pg_lsn` value, representing a point-in-time value for your replication scenario. The syntax of `spock.sync_event` is: -`spock.sync_event() RETURNS pg_lsn` +`spock.sync_event(transactional boolean DEFAULT false) RETURNS pg_lsn` + +When `transactional` is `false` (the default), the sync event marker is +emitted into the WAL stream immediately, independent of the calling +transaction. When `transactional` is `true`, the marker is bound to the +calling transaction and is only visible to subscribers if the transaction +commits. Invoked on a subscriber node, `spock.wait_for_sync_event` is available in two flavors - the first uses the origin_id (an `oid`) as an identifier for the @@ -62,6 +68,11 @@ On a provider node: On a subscriber node: -`CALL spock.wait_for_sync_event(OUT result, 'provider_node', '0/16342B0', 10);` -`-- result: true (if applied within 10s), false otherwise` +```sql +CALL spock.wait_for_sync_event(NULL, 'provider_node', '0/16342B0', 10); +-- result: true (if applied within 10s), false otherwise +``` + +The first parameter is the OUT `result` placeholder; pass `NULL` for it in +the `CALL` statement and read the OUT value from the procedure result. diff --git a/docs/recovery/catastrophic_node_failure.md b/docs/recovery/catastrophic_node_failure.md index 747010a8..f611b934 100644 --- a/docs/recovery/catastrophic_node_failure.md +++ b/docs/recovery/catastrophic_node_failure.md @@ -307,15 +307,17 @@ when it should be `replicating` indicates that the node is behind. For example: ``` - sub_name | status | provider_node | replication_sets | lag ------------+-------------+---------------+---------------------------------------+----------- - sub_n2_n1 | down | n1 | {default,default_insert_only,ddl_sql} | 00:05:12 - sub_n2_n3 | replicating | n3 | {default,default_insert_only,ddl_sql} | 00:00:00 + subscription_name | status | provider_node | replication_sets +-------------------+-------------+---------------+--------------------------------------- + sub_n2_n1 | down | n1 | {default,default_insert_only,ddl_sql} + sub_n2_n3 | replicating | n3 | {default,default_insert_only,ddl_sql} ``` -In this output, `sub_n2_n1` is down and lagging — that confirms n2 did not -receive all of n1's transactions before n1 failed. The subscriptions to n3, -n4, and n5 are still healthy. +In this output, `sub_n2_n1` is `down` — that confirms n2 lost its +connection to n1 (which has failed). The subscriptions to n3, n4, and n5 +are still healthy. To gauge how far behind n2 is, query +[`spock.lag_tracker`](../monitoring/lag_tracking.md) for replication lag +in bytes and time. Determine the approximate time when the failed node (or nodes) failed. You'll need this timestamp for the ACE commands in Phase 3 and 4. If you @@ -377,14 +379,17 @@ leave others out of sync. ### Step 1: Get a List of All Tables to Check First, get the list of tables that participate in replication. You can get -this from Spock replication sets. Connect to any surviving node (for +this from the `spock.tables` view, which lists every table along with the +replication set (if any) it belongs to. Connect to any surviving node (for example, n3) and run: ```sql -SELECT * FROM spock.repset_list_tables('default'); +SELECT nspname, relname, set_name + FROM spock.tables + WHERE set_name IS NOT NULL + ORDER BY set_name, nspname, relname; ``` -If you use multiple replication sets, run this for each set. Alternatively, you can list all tables in the schema you replicate: ```sql diff --git a/docs/two_node_cluster.md b/docs/two_node_cluster.md index 5abab8e2..f129a10f 100644 --- a/docs/two_node_cluster.md +++ b/docs/two_node_cluster.md @@ -36,7 +36,7 @@ After installing and initializing Postgres and creating the Spock Extension, you On `n2`: - `SELECT spock.node_create (node_name := 'n2', dsn := 'host= port= =');` + `SELECT spock.node_create (node_name := 'n2', dsn := 'host= port= dbname=');` 5. On `n1`, use the [`spock.repset_add_all_tables`](spock_functions/functions/spock_repset_add_all_tables.md) command to add the tables in the `public` schema to the `default` replication set. If you are working in another schema, customize this command as needed: @@ -50,7 +50,7 @@ After installing and initializing Postgres and creating the Spock Extension, you 7. On `n1`, create a corresponding subscription to `n2` named `sub_n1_n2`: - `SELECT spock.sub_create (subscription_name := 'sub_n1_n2', subscriber_dsn := 'host= port= dbname=');` + `SELECT spock.sub_create (subscription_name := 'sub_n1_n2', provider_dsn := 'host= port= dbname=');` 8. To ensure that modifications to your [DDL statements are automatically replicated](managing/spock_autoddl.md), connect to each node with a Postgres client and invoke the following SQL commands: From bfa3e5a3ac64c43f0de7b0979a350ef8d0260e90 Mon Sep 17 00:00:00 2001 From: susan-pgedge <130390403+susan-pgedge@users.noreply.github.com> Date: Thu, 7 May 2026 12:49:58 -0400 Subject: [PATCH 04/10] Update documentation for spock_max_proto_version Clarify function definition location and add details. --- docs/spock_functions/functions/spock_max_proto_version.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/spock_functions/functions/spock_max_proto_version.md b/docs/spock_functions/functions/spock_max_proto_version.md index 696b1bb3..3a3d3d4d 100644 --- a/docs/spock_functions/functions/spock_max_proto_version.md +++ b/docs/spock_functions/functions/spock_max_proto_version.md @@ -6,8 +6,6 @@ spock_max_proto_version() spock_max_proto_version() -This function is defined in the public schema, not the `spock.` schema. - ### RETURNS The maximum spock protocol version supported by the installed Spock extension @@ -31,7 +29,8 @@ different Spock releases. The protocol version is returned as an integer value. Higher numbers indicate newer protocol versions with additional features. -This is a read-only query function that does not modify data. +This is a read-only query function that does not modify data. This function is +defined in the public schema. ### ARGUMENTS From d9185dd6f84c7888613a9ec3057b0a98f70735ab Mon Sep 17 00:00:00 2001 From: susan-pgedge <130390403+susan-pgedge@users.noreply.github.com> Date: Thu, 7 May 2026 12:50:59 -0400 Subject: [PATCH 05/10] Update documentation for spock_min_proto_version Clarify the schema definition of the spock_min_proto_version function and its read-only nature. --- docs/spock_functions/functions/spock_min_proto_version.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/spock_functions/functions/spock_min_proto_version.md b/docs/spock_functions/functions/spock_min_proto_version.md index 687a7e7a..b754e34b 100644 --- a/docs/spock_functions/functions/spock_min_proto_version.md +++ b/docs/spock_functions/functions/spock_min_proto_version.md @@ -6,8 +6,6 @@ spock_min_proto_version() spock_min_proto_version() -This function is defined in the public schema, not the `spock.` schema. - ### RETURNS The minimum Spock protocol version supported by the installed Spock extension @@ -33,7 +31,8 @@ The protocol version is returned as an integer value. This minimum version ensures backward compatibility with older Spock releases while still allowing the use of newer protocol features when both nodes support them. -This is a read-only query function that does not modify data. +This is a read-only query function that does not modify data. This function is +defined in the public schema. ### ARGUMENTS From 8d101ae6c6e781dc976e0bb5fecdffd2f470a368 Mon Sep 17 00:00:00 2001 From: susan-pgedge <130390403+susan-pgedge@users.noreply.github.com> Date: Thu, 7 May 2026 12:53:24 -0400 Subject: [PATCH 06/10] Fix warning message about data synchronization --- docs/spock_functions/functions/spock_repset_add_table.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/spock_functions/functions/spock_repset_add_table.md b/docs/spock_functions/functions/spock_repset_add_table.md index d42cef20..487c2293 100644 --- a/docs/spock_functions/functions/spock_repset_add_table.md +++ b/docs/spock_functions/functions/spock_repset_add_table.md @@ -100,5 +100,5 @@ rows: **WARNING: Use caution when synchronizing data with a valid row filter.** Using `synchronize_data=true` with a valid `row_filter` is usually a one-time operation for a table. Executing it again with a modified -`row_filter` won't synchronize data to subscriber. You may need to call +`row_filter` won't synchronize data to the subscriber. You may need to call `spock.sub_resync_table()` to fix it. From 4b3ff35cb716ed8becb5eb57a898eff961f55efe Mon Sep 17 00:00:00 2001 From: susan-pgedge <130390403+susan-pgedge@users.noreply.github.com> Date: Tue, 12 May 2026 07:27:44 -0400 Subject: [PATCH 07/10] Clarify protocol version commands in documentation --- docs/spock_functions/gen_mgmt.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/spock_functions/gen_mgmt.md b/docs/spock_functions/gen_mgmt.md index 1371f703..a76f6bd0 100644 --- a/docs/spock_functions/gen_mgmt.md +++ b/docs/spock_functions/gen_mgmt.md @@ -5,11 +5,11 @@ You can use the following settings to manage your replication clusters. | Command | Description |----------|------------- | [spock.get_country](functions/spock_get_country.md) | Returns the country code configured for the node. | -| [spock_max_proto_version](functions/spock_max_proto_version.md) | Returns the maximum protocol version supported by Spock. Defined in the public schema (no `spock.` prefix). | -| [spock_min_proto_version](functions/spock_min_proto_version.md) | Returns the minimum protocol version supported by Spock. Defined in the public schema (no `spock.` prefix). | +| [spock_max_proto_version](functions/spock_max_proto_version.md) | Returns the maximum protocol version supported by Spock. Defined in the public schema so invoked without the `spock.` prefix. | +| [spock_min_proto_version](functions/spock_min_proto_version.md) | Returns the minimum protocol version supported by Spock. Defined in the public schema, so invoked without the `spock.` prefix. | | [spock.node_info](functions/spock_node_info.md) | Returns information about the local Spock node. | -| [spock_version](functions/spock_version.md) | Returns the version string of the Spock extension. Defined in the public schema (no `spock.` prefix). | -| [spock_version_num](functions/spock_version_num.md) | Returns the version number of Spock as an integer. Defined in the public schema (no `spock.` prefix). | +| [spock_version](functions/spock_version.md) | Returns the version string of the Spock extension. Defined in the public schema so invoked without the `spock.` prefix. | +| [spock_version_num](functions/spock_version_num.md) | Returns the version number of Spock as an integer. Defined in the public schema so invoked without the `spock.` prefix. | ## spock.get_country From d7ae8e706dff93da65fde503d9548ff54c089a3c Mon Sep 17 00:00:00 2001 From: susan-pgedge <130390403+susan-pgedge@users.noreply.github.com> Date: Tue, 12 May 2026 07:33:19 -0400 Subject: [PATCH 08/10] Clarify argument requirements for Spock functions Added notes about argument requirements for Spock functions. --- docs/spock_functions/gen_mgmt.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/spock_functions/gen_mgmt.md b/docs/spock_functions/gen_mgmt.md index a76f6bd0..5c945a5a 100644 --- a/docs/spock_functions/gen_mgmt.md +++ b/docs/spock_functions/gen_mgmt.md @@ -32,13 +32,15 @@ This function takes no arguments. ## spock_max_proto_version Use `spock_max_proto_version` to retrieve the maximum protocol version -supported by Spock. This function is defined in the public schema (no -`spock.` prefix). +supported by Spock. `spock_max_proto_version()` Returns the maximum protocol version supported by the Spock extension. +This function takes no arguments, and is defined in the public +schema so must be invoked without the `spock.` prefix. + This function queries the Spock extension and returns the highest protocol version number it can use for replication communication. The protocol version determines the features and capabilities available for replication @@ -49,18 +51,19 @@ Spock versions, the nodes negotiate to use the lower of the two maximum protocol versions. This ensures compatibility between nodes running different Spock releases. -This function takes no arguments. ## spock_min_proto_version Use `spock_min_proto_version` to retrieve the minimum protocol version -supported by Spock. This function is defined in the public schema (no -`spock.` prefix). +supported by Spock. `spock_min_proto_version()` Returns the minimum protocol version supported by the Spock extension. +This function takes no arguments, and is defined in the public +schema so must be invoked without the `spock.` prefix. + This function queries the Spock extension and returns the lowest protocol version number it can use for replication communication. The protocol version determines the features and capabilities available for replication @@ -71,8 +74,6 @@ Spock versions, the nodes negotiate to use a protocol version that falls within the supported range of both nodes. The minimum protocol version defines the lower bound of compatibility. -This function takes no arguments. - ## spock.node_info Use `spock.node_info` to retrieve information about the local Spock node. @@ -88,27 +89,30 @@ This function takes no arguments. ## spock_version Use `spock_version` to retrieve the version string of the Spock extension. -This function is defined in the public schema (no `spock.` prefix). `spock_version()` Returns the version number of the Spock extension. +This function takes no arguments, and is defined in the public +schema so must be invoked without the `spock.` prefix. + This function queries the Spock extension and returns its version as a text string. The version string typically follows semantic versioning format (for example, "4.0.1" or "5.0.4"). -This function takes no arguments. - ## spock_version_num Use `spock_version_num` to retrieve the version number of Spock as an -integer. This function is defined in the public schema (no `spock.` prefix). +integer. `spock_version_num()` Returns the version number of the Spock extension as an integer. +This function takes no arguments, and is defined in the public +schema so must be invoked without the `spock.` prefix. + This function queries the Spock extension and returns its version encoded as an integer value. The integer format allows for easy version comparison in SQL queries without string parsing. @@ -117,4 +121,3 @@ The integer typically represents the version in a format like XXYYZZ where XX is the major version, YY is the minor version, and ZZ is the patch version. For example, version 3.1.0 might be represented as 30100. -This function takes no arguments. From 856809027e9f2a93e208673a42d00af08a7784c1 Mon Sep 17 00:00:00 2001 From: susan-pgedge <130390403+susan-pgedge@users.noreply.github.com> Date: Tue, 12 May 2026 07:39:21 -0400 Subject: [PATCH 09/10] Clarify documentation for spock.deny_all_ddl --- docs/managing/spock_autoddl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/managing/spock_autoddl.md b/docs/managing/spock_autoddl.md index d4666afd..e5fbccb7 100644 --- a/docs/managing/spock_autoddl.md +++ b/docs/managing/spock_autoddl.md @@ -32,7 +32,7 @@ automatic DDL replication, set the following parameters to `on`: To completely block all DDL across the cluster (including DDL that would otherwise be replicated automatically), use: -* `spock.deny_all_ddl` is a boolean (default `false`). When set to `true`, +* `spock.deny_all_ddl` - a boolean value, default `false`. When set to `true`, Spock rejects any DDL statement executed on the node. This is useful as a guard during sensitive maintenance windows or while a node is being added or repaired. The setting can be changed by a superuser at runtime From 7d567dd7696690001dfeb9306ecce10c7d5599fe Mon Sep 17 00:00:00 2001 From: susan-pgedge <130390403+susan-pgedge@users.noreply.github.com> Date: Tue, 12 May 2026 07:48:38 -0400 Subject: [PATCH 10/10] Update Spock version descriptions in documentation --- docs/spock_functions/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/spock_functions/index.md b/docs/spock_functions/index.md index 9e31a544..22a332dd 100644 --- a/docs/spock_functions/index.md +++ b/docs/spock_functions/index.md @@ -41,16 +41,16 @@ The following user functions are available via the Spock extension: | **Miscellaneous Management Functions** | | | [spock.table_wait_for_sync](functions/spock_table_wait_for_sync.md) | Pause until a table finishes synchronizing. | [spock.replicate_ddl](functions/spock_replicate_ddl.md) | Enable DDL replication. -| spock_version | Returns the Spock version in a major/minor version form: `4.0.10`. Defined in the public schema (no `spock.` prefix). -| spock_version_num | Returns the Spock version in a single numeric form: `40010`. Defined in the public schema (no `spock.` prefix). +| spock_version | Returns the Spock version in a major/minor version form: `4.0.10`. Defined in the public schema so invoked without the `spock.` prefix. +| spock_version_num | Returns the Spock version in a single numeric form: `40010`. Defined in the public schema so invoked without the `spock.` prefix. | spock.get_channel_stats | Returns tuple traffic statistics. | spock.get_country | Returns the country code if explicitly set; returns `??` if not set. | spock.lag_tracker | Returns a list of slots, with commit_lsn and commit_timestamp for each. | spock.repair_mode | Used to manage the state of replication - If set to `true`, stops replicating statements; when `false`, resumes replication. | spock.replicate_ddl | Replicate a specific statement. | spock.reset_channel_stats | Reset the channel statistics. -| spock_max_proto_version | The highest Spock native protocol supported by the current binary/build. Defined in the public schema (no `spock.` prefix). -| spock_min_proto_version | The lowest build for which this Spock binary is backward compatible. Defined in the public schema (no `spock.` prefix). +| spock_max_proto_version | The highest Spock native protocol supported by the current binary/build. Defined in the public schema so invoked without the `spock.` prefix. +| spock_min_proto_version | The lowest build for which this Spock binary is backward compatible. Defined in the public schema so invoked without the `spock.` prefix. | spock.table_data_filtered | Scans the specified table and returns rows that match the row filter from the specified replication set(s). Row filters are added to a replication set when adding a table with `repset_add_table`. | spock.terminate_active_transactions | Terminates all active transactions. | spock.wait_slot_confirm_lsn | Wait for the `confirmed_flush_lsn` of the specified slot, or all logical slots if none given.