This is the multi-page printable view of this section.
Spock Functions
- 1: spock.cleanup_resolutions
- 2: spock.gen_slot_name()
- 3: spock.get_country()
- 4: spock.max_proto_version()
- 5: spock.min_proto_version()
- 6: spock.node_add_interface()
- 7: spock.node_alter()
- 8: spock.node_create()
- 9: spock.node_drop_interface()
- 10: spock.node_drop()
- 11: spock.node_info()
- 12: spock.node_refresh_info()
- 13: spock.replicate_ddl()
- 14: spock.repset_add_all_seqs()
- 15: spock.repset_add_all_tables()
- 16: spock.repset_add_partition()
- 17: spock.repset_add_seq()
- 18: spock.repset_add_table()
- 19: spock.repset_alter()
- 20: spock.repset_create()
- 21: spock.repset_drop()
- 22: spock.repset_remove_partition()
- 23: spock.repset_remove_seq()
- 24: spock.repset_remove_table()
- 25: spock.repset_show_table()
- 26: spock.sub_add_repset()
- 27: spock.sub_alter_interface()
- 28: spock.sub_alter_options()
- 29: spock.sub_alter_skiplsn()
- 30: spock.sub_alter_sync
- 31: spock.sub_create()
- 32: spock.sub_disable
- 33: spock.sub_drop()
- 34: spock.sub_enable
- 35: spock.sub_remove_repset
- 36: spock.sub_resync_table
- 37: spock.sub_show_status
- 38: spock.sub_show_table
- 39: spock.sub_wait_for_sync
- 40: spock.sync_event
- 41: spock.sync_seq
- 42: spock.table_wait_for_sync()
- 43: spock.version_num()
- 44: spock.version()
- 45: spock.wait_slot_confirm_lsn()
- 46: spock.xact_commit_timestamp_origin()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
You can access the reference pages in this section via online help; at the terminal window, enter:
command_name --help
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
1 - spock.cleanup_resolutions
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.cleanup_resolutions() function manually deletes old rows from the
spock.resolutions table.
Synopsis
Description
Deletes rows from spock.resolutions whose log_time is older than the
retention window. Returns the number of rows deleted.
This function is a superuser-only manual trigger for the same cleanup that
the apply worker runs automatically once per day. It is useful for
immediate cleanup via pg_cron or when the apply worker has not been
running.
When days is provided it takes precedence over
spock.resolutions_retention_days, including when the GUC is set to 0
(automatic cleanup disabled). If days is omitted, the GUC value is used;
if the GUC is also 0, the function returns 0 without deleting anything.
Arguments
The function accepts the following argument:
days- Retention window in days. Overridesspock.resolutions_retention_daysfor this call. Pass an explicit value to perform a one-off cleanup when automatic cleanup is disabled (resolutions_retention_days = 0). Default isNULL(use the GUC value).
Example
Delete rows older than the configured retention window:
Delete rows older than 60 days, regardless of the GUC setting:
See Also
spock.resolutions_retention_days
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
2 - spock.gen_slot_name()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.spock_gen_slot_name()
SYNOPSIS
spock.spock_gen_slot_name(dbname name, provider_node name, subscription name)
RETURNS
The generated replication slot name as a name type.
DESCRIPTION
Generates a standardized replication slot name for a Spock subscription.
This function creates a consistent naming convention for replication slots based on the database name, provider node name, and subscription name. The generated name follows Spock’s internal naming scheme to ensure uniqueness and traceability.
This function that performs a calculation without accessing the database or modifying any data. It can be used to predict what slot name Spock will generate for a given subscription configuration.
ARGUMENTS
dbname
The name of the database.
provider_node
The name of the provider node.
subscription
The name of the subscription.
EXAMPLE
The following example executes the function; the database name is postgres, the node name is n1, and the subscription name is sub_n2n1:
postgres=# SELECT spock.spock_gen_slot_name('postgres', 'n1', 'sub_n2n1');
spock_gen_slot_name
--------------------------
spk_postgres_n1_sub_n2n1
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
3 - spock.get_country()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.get_country()
SYNOPSIS
spock.get_country ()
RETURNS
The country code configured for the node as text, or ?? if not set.
DESCRIPTION
Returns the spock.country property that was set during node creation. You can modify the property after configuration; modification requires a server restart to apply the change.
This function retrieves the value of the spock.country configuration parameter for the current session. The country code is typically used in multi-region or geo-distributed replication topologies to identify the geographic location of nodes and apply region-specific routing or filtering rules.
This function does not modify any data.
ARGUMENTS
This function takes no arguments.
EXAMPLE
If the spock.country parameter has not been set, the function returns:
postgres=# SELECT spock.get_country();
get_country
-------------
??
(1 row)
If spock.country is set to US, the function returns:
postgres=# SELECT spock.get_country();
get_country
-------------
US
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
4 - spock.max_proto_version()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock_max_proto_version()
SYNOPSIS
spock_max_proto_version()
RETURNS
The maximum spock protocol version supported by the installed Spock extension as an integer. The protocol version determines compatibility between Spock versions.
DESCRIPTION
Returns the maximum protocol version supported by the Spock extension.
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 between nodes.
When establishing replication connections between nodes running different Spock versions, the nodes negotiate to use the lower of the two maximum protocol versions. This ensures compatibility between nodes running 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 function is defined in the public schema.
ARGUMENTS
This function takes no arguments.
EXAMPLE
The following command shows that the current version of Spock uses protocol version 4:
postgres=# SELECT spock_max_proto_version();
spock_max_proto_version
-------------------------
4
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
5 - spock.min_proto_version()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock_min_proto_version()
SYNOPSIS
spock_min_proto_version()
RETURNS
The minimum Spock protocol version supported by the installed Spock extension as an integer. The protocol version determines compatibility between Spock versions.
DESCRIPTION
Returns the minimum protocol version supported by the Spock extension.
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 between nodes.
When establishing replication connections between nodes running different 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 - nodes supporting only protocol versions below this minimum cannot replicate with this Spock installation.
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 function is defined in the public schema.
ARGUMENTS
This function takes no arguments.
EXAMPLE
The following command shows that the version of Spock in use is using protocol version 3:
postgres=# SELECT spock_min_proto_version();
spock_min_proto_version
-------------------------
3
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
6 - spock.node_add_interface()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.node_add_interface()
SYNOPSIS
spock.node_add_interface (node_name name, interface_name name, dsn text)
RETURNS
The OID of the newly created interface. Returns NULL if any argument is NULL.
DESCRIPTION
Adds a new network interface definition to an existing Spock node; the network interface has an associated connection string that is used when the interface is referenced by other nodes.
Interfaces allow a single node to be reachable through multiple connection endpoints. This is commonly used in environments where nodes are accessible through different hostnames, IP addresses, private networks, public networks, or load balancers.
The interface definition consists of a name and a PostgreSQL DSN string that describes how other nodes should connect to this node.
This function writes metadata into the Spock catalogs but does not modify PostgreSQL server configuration or networking settings.
This command must be executed by a superuser.
ARGUMENTS
node_name
The name of an existing Spock node.
interface_name
A unique name for this interface on the node.
dsn
A PostgreSQL connection string that other nodes will use to connect to this node. The user in this string should equal the OS user. This connection string should be reachable from outside and match the one used later in the sub-create command. For example: host=10.1.2.5 port=5432 user=rocky
EXAMPLE
The following example adds an interface named private_net that uses the connection string defined in the last argument of the function call (‘host=10.0.0.10 port=5432 dbname=postgres’):
postgres=# SELECT spock.node_add_interface('n1', 'private_net',
'host=10.0.0.10 port=5432 dbname=postgres');
node_add_interface
--------------------
1239112588
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
7 - spock.node_alter()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.node_alter()
SYNOPSIS
spock.node_alter (p_location text DEFAULT NULL, p_country text DEFAULT NULL, p_info_patch jsonb DEFAULT NULL)
RETURNS
true on success. Raises an error if p_info_patch is not a JSON object,
or if it contains a tiebreaker key that is not a JSON number, is not a
whole number, or does not fit a 32-bit integer.
DESCRIPTION
Changes the local node’s own location, country, and/or info, merging
p_info_patch into the existing info rather than replacing it. Only
this node’s own row can be altered – there is no node_name argument,
since (unlike spock.node_refresh_info) there is only ever one valid
target: the local node.
Any omitted argument (left NULL) is left unchanged: p_location and
p_country each independently overwrite only if non-NULL, and
p_info_patch is merged key-by-key into the existing info (via ||)
only if non-NULL – an existing key not mentioned in the patch is left
as-is, not removed.
A tiebreaker key inside p_info_patch is validated: it must be a JSON
number (not a string, and not JSON null), a whole number, and fit a
32-bit integer, or the call raises an error and changes nothing. This is
the safe way to change a node’s tiebreaker; see the Tiebreaker section in
conflict_types.md for what the tiebreaker
does and why validation matters here.
This ends in the same UPDATE spock.node that a hand-written UPDATE
would use, so it propagates identically: automatically to every direct
subscriber of this node (see
Automatic node metadata propagation),
with no manual step required. A raw UPDATE spock.node SET ... on this
node’s own row remains fully supported and behaves the same way –
spock.node_alter exists to validate the input and merge info safely,
not to gate access to the underlying table.
ARGUMENTS
p_location
Optional. Replaces this node’s location. Left unchanged if omitted
(or NULL).
p_country
Optional. Replaces this node’s country. Left unchanged if omitted
(or NULL).
p_info_patch
Optional. A JSON object merged into this node’s existing info
(existing keys not mentioned are preserved). Left unchanged if
omitted (or NULL). A tiebreaker key, if present, must be a JSON
number representable as a 32-bit integer.
EXAMPLE
Assign a custom tiebreaker on n1, without disturbing any other info
keys already set:
n1=# SELECT spock.node_alter(p_info_patch => '{"tiebreaker": 42}'::jsonb);
node_alter
------------
t
(1 row)
Every direct subscriber of n1 picks this up automatically – no
spock.node_refresh_info call needed:
n2=# SELECT info->>'tiebreaker' FROM spock.node WHERE node_name = 'n1';
?column?
----------
42
(1 row)
Update location and country together in one call:
n1=# SELECT spock.node_alter(p_location => 'us-east', p_country => 'US');
node_alter
------------
t
(1 row)
An invalid tiebreaker is rejected and changes nothing:
n1=# SELECT spock.node_alter(p_info_patch => '{"tiebreaker": "42"}'::jsonb);
ERROR: invalid "tiebreaker" value "42": must be a JSON number, not a string or null
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
8 - spock.node_create()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.node_create()
SYNOPSIS
spock.node_create (node_name name, dsn text, location text, country text, info jsonb)
RETURNS
The OID of the newly created Spock node.
DESCRIPTION
Creates a new Spock node definition.
A node represents a PostgreSQL instance that participates in Spock replication. The node definition includes the connection information that other nodes will use to communicate with this node.
Optional metadata fields such as location, country, and info can be provided to describe the node for organizational or management purposes. These values are stored in the Spock catalogs but are not required for replication to function.
This function writes metadata into the Spock catalogs but does not modify Postgres server configuration or networking settings.
This command must be executed by a superuser.
ARGUMENTS
node_name
A unique name for the Spock node.
dsn
A PostgreSQL connection string that other nodes will use to connect to this node.
location
Optional descriptive text indicating the physical or logical location of the node. The default is NULL.
country
Optional country code or name associated with the node. The default is NULL.
info
Optional JSONB field for storing arbitrary metadata about the node. The default is NULL.
A tiebreaker key in this field overrides the node’s default
last-update-wins tiebreaker (otherwise the node’s unique ID). Each
node caches this value locally, populated once when it first learns
about the node. A later change (via spock.node_alter, the
recommended way, or a raw UPDATE) propagates automatically to every
direct subscriber. spock.node_refresh_info updates a node that missed
the change – see the Tiebreaker section in conflict_types.md for
details.
EXAMPLE
In the following example, Spock creates a node named n3, with a connection to a database named ‘inventory’:
inventory=# SELECT spock.node_create('n3','host=10.0.0.12 port=5432 dbname=inventory');
node_create
-------------
9057
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
9 - spock.node_drop_interface()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.node_drop_interface()
SYNOPSIS
spock.node_drop_interface (node_name name, interface_name name)
RETURNS
true if the interface was dropped successfully.
Raises an ERROR if the interface does not exist, the call has invalid parameters or insufficient privileges, or the interface cannot be removed.
DESCRIPTION
Removes an existing network interface definition from a Spock node.
This function deletes the interface definition from the Spock catalogs. It does not modify PostgreSQL server configuration or networking settings; it only removes Spock’s logical representation of the interface.
Other nodes that were using this interface to connect will no longer be able to use it. To avoid a client error, ensure that no active subscriptions rely on this interface before attempting to remove it.
This function writes metadata into the Spock catalogs but does not modify PostgreSQL server configuration or networking settings.
This command must be executed by a superuser.
ARGUMENTS
node_name
The name of an existing Spock node.
interface_name
The name of the interface to remove from the node.
EXAMPLE
The following example drops an interface named ‘private_net’:
inventory=# SELECT spock.node_drop_interface('n3', 'private_net');
node_drop_interface
---------------------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
10 - spock.node_drop()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.node_drop()
SYNOPSIS
spock.node_drop(node_name name, ifexists boolean)
RETURNS
true if the node was dropped successfully.
false if the node did not exist and ifexists was set to true.
ERROR if the call has invalid parameters, if the invoker has insufficient privileges, or the node cannot be removed due to existing dependencies.
DESCRIPTION
Removes an existing Spock node from the cluster metadata.
This function deletes the node definition and all associated metadata from the Spock catalogs. It does not remove any PostgreSQL data directory or stop the PostgreSQL server; it only removes Spock’s logical representation of the node.
If ifexists is set to false (default), an error is raised when the specified node does not exist. If ifexists is true, the function returns false instead of raising an error.
This command must be executed by a superuser and modifies Spock catalog tables.
ARGUMENTS
node_name
The name of the existing Spock node to remove.
ifexists
If true, do not raise an error when the node does not exist; return false instead. Default is false.
EXAMPLE
The following function call drops a node named ’n3':
inventory=# SELECT spock.node_drop('n3');
node_drop
-----------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
11 - spock.node_info()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.node_info()
SYNOPSIS
spock.node_info()
RETURNS
A record containing information about the local Spock node:
- node_id is the OID of the node.
- node_name is the name of the node.
- sysid is the system identifier.
- dbname is the database name.
- replication_sets is the available replication sets.
- location is the node location (if set).
- country is the node country (if set).
- info is additional metadata stored in JSONB format (if set).
DESCRIPTION
Returns information about the local Spock node.
This function queries the Spock catalogs and returns metadata about the current node, including its identifier, name, database information, and any optional descriptive fields that were set during node creation.
This is a read-only query function that does not modify data.
ARGUMENTS
This function takes no arguments.
EXAMPLE
postgres=# SELECT * FROM spock.node_info();
-[ RECORD 1 ]----+--------------------------------------
node_id | 49708
node_name | n1
sysid | 7600444661598442547
dbname | postgres
replication_sets | "default",default_insert_only,ddl_sql
location |
country |
info |
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
12 - spock.node_refresh_info()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.node_refresh_info()
SYNOPSIS
spock.node_refresh_info (p_node_name name DEFAULT NULL)
RETURNS
true if the refresh (or, with no argument, every refresh attempted)
succeeded; false if one or more nodes could not be refreshed when called
with no argument. Raises an error if called with a specific node_name
that does not exist or that names the local node, or if refreshing that
node fails for any reason – including an unreachable or misconfigured
interface, a dsn that now answers as a different node, or any other error
from the remote fetch.
DESCRIPTION
Re-fetches a known peer node’s location, country, and info (including
any tiebreaker key within info) directly from that node, and overwrites
this node’s locally cached copy.
spock.node is a local catalog: each node populates its row for a peer
once, either when that node is created or when a subscription to it is
first created. A peer’s later location/country/info change – most
commonly to assign a custom tiebreaker and resolve an equal-tiebreaker
collision – propagates automatically to every node that subscribes to
that peer directly (see
Automatic Node Metadata Propagation),
with no call to this function needed. The message is not forwarded, and a
node normally has a row for a peer only through its own subscription to it,
so a cascade node that does not subscribe to the changed peer has no row to
refresh. This function is needed when a node’s cached row missed an update,
for example because the transaction carrying it was skipped or discarded,
and to force a specific peer’s info to be re-fetched on demand.
spock.sub_resync_table() warns when the provider’s row differs from the
cached one. See the Tiebreaker section in
conflict_types.md for why this matters and why
spock.node is not simply replicated wholesale.
Called with a specific node_name, only that node’s row is refreshed and
any failure refreshing it is reported as an error. Called with no
argument, every known node other than the local one is refreshed on a
best-effort basis: a node that fails to refresh for any reason logs a
WARNING and does not stop the others from being refreshed, and the
overall return value is false if any node failed.
This command must be executed by a superuser.
ARGUMENTS
p_node_name
Optional. The name of a single peer node to refresh. If omitted (or NULL), every node other than the local one is refreshed.
EXAMPLE
After assigning a custom tiebreaker on n1 to resolve a collision:
n1=# UPDATE spock.node SET info = COALESCE(info, '{}'::jsonb) ||
'{"tiebreaker": 42}' WHERE node_name = 'n1';
Refresh that on every other node:
n2=# SELECT spock.node_refresh_info('n1');
node_refresh_info
--------------------
t
(1 row)
Or refresh everything this node knows about in one call:
n3=# SELECT spock.node_refresh_info();
node_refresh_info
--------------------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
13 - spock.replicate_ddl()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.replicate_ddl()
SYNOPSIS
spock.replicate_ddl (command text[], replication_sets text[], search_path text, role text)
RETURNS
true if the DDL command was successfully executed and queued for replication.
false if the command execution fails or replication queueing fails.
When called with a text array, returns a set of boolean values, one for each command in the array.
DESCRIPTION
Executes DDL commands locally and queues them for replication to subscribers.
This function runs the specified DDL command on the local node first, then adds it to the replication queue for execution on all subscriber nodes that are subscribed to one of the specified replication sets.
The function accepts either a single DDL command as text or an array of DDL commands. When provided with an array, each command is executed and queued sequentially.
The search_path and role parameters allow you to control the execution context for the DDL command on both the provider and subscriber nodes.
This function writes to the replication queue and modifies the database schema locally before propagating changes.
This command must be executed by a user with sufficient privileges to execute the DDL command.
ARGUMENTS
command
A DDL command as text, or an array of DDL commands to execute and replicate.
replication_sets
An array of replication set names. Only subscribers subscribed to one of these sets will receive and execute the DDL. Default is ‘{ddl_sql}’.
search_path
The schema search path to use when executing the DDL command. Default is the current session’s search_path setting.
role
The role (user) under which to execute the DDL command. Default is the current user.
EXAMPLES
The following command creates a table and instructs Spock to replicate the DDL to other nodes:
postgres=# SELECT spock.replicate_ddl('CREATE TABLE users (id SERIAL PRIMARY KEY,
name TEXT)');
-[ RECORD 1 ]-+--
replicate_ddl | t
The following command alters the table adding a column, and instructs Spock to replicate the DDL to other nodes:
postgres=# SELECT spock.replicate_ddl('ALTER TABLE users ADD COLUMN email TEXT',
'{default,ddl_sql}');
-[ RECORD 1 ]-+--
replicate_ddl | t
The following command creates a table and an index on the tables, and instructs Spock to replicate DDL to other nodes:
postgres=# SELECT spock.replicate_ddl(ARRAY['CREATE TABLE orders (id SERIAL)',
'CREATE INDEX ON orders(id)']);
-[ RECORD 1 ]-+--
replicate_ddl | t
-[ RECORD 2 ]-+--
replicate_ddl | t
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
14 - spock.repset_add_all_seqs()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_add_all_seqs()
SYNOPSIS
spock.repset_add_all_seqs (set_name name, schema_names text[], synchronize_data boolean)
RETURNS
true if all sequences were successfully added to the replication set.
ERROR if the call has invalid parameters, insufficient privileges, or the operation fails.
DESCRIPTION
Adds all existing sequences from the specified schemas to a replication set.
This function registers all sequence objects found in the given schemas with the specified replication set. Only sequences that exist at the time of execution are added; sequences created afterward must be added separately using spock.repset_add_seq().
The synchronize_data parameter controls whether sequence values are immediately synchronized across nodes. When set to true, the current value of each sequence is propagated to subscribers.
This function writes metadata into the Spock catalogs to track which sequences are part of the replication set.
This command must be executed by a superuser.
Warning: If you’re deploying a multi-master replication scenario, we recommend that you not add sequences to a replication set. Instead, use Snowflake Sequences to manage sequences in a distributed environment and avoid conflicts.
ARGUMENTS
set_name
The name of an existing replication set.
schema_names
An array of schema names from which all sequences will be added.
synchronize_data
If true, synchronize the current value of each sequence immediately. Default is false.
EXAMPLE
You can specify one or more schemas in the call to repset_add_all_seqs. The first command adds the sequences in the ‘public’ schema to the ‘default’ replication set:
postgres=# SELECT spock.repset_add_all_seqs('default', ARRAY['public']);
-[ RECORD 1 ]-------+--
repset_add_all_seqs | t
The following command adds all sequences in the schemas named ‘public’ and ‘alice’ to the ‘default’ replication set:
postgres=# SELECT spock.repset_add_all_seqs('default', ARRAY['public', 'alice'],true);
-[ RECORD 1 ]-------+--
repset_add_all_seqs | t
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
15 - spock.repset_add_all_tables()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_add_all_tables()
SYNOPSIS
spock.repset_add_all_tables (set_name name, schema_names text[], synchronize_data boolean)
RETURNS
true if every replicatable table was added to the replication set.
false if the call has invalid parameters, insufficient privileges, or the operation fails.
DESCRIPTION
Adds all existing tables from the specified schemas to a replication set.
This function registers all table objects found in the given schemas with the specified replication set. Only tables that exist at the time of execution are added; tables created afterward must be added separately using spock.repset_add_table().
A table that cannot be replicated is skipped and reported with a WARNING naming its schema and table; the remaining tables are still added. A table is skipped when the replication set replicates UPDATEs or DELETEs and the table has no index-based replica identity, or when the table belongs to an extension listed in spock.reserved_object. A schema listed in spock.reserved_object is reported once and passed over as a whole.
A replication set that replicates UPDATEs or DELETEs has to locate the affected row on the subscriber, so it can only take tables with an index-based replica identity — a PRIMARY KEY, or a unique index on NOT NULL columns nominated with ALTER TABLE … REPLICA IDENTITY USING INDEX. Note that REPLICA IDENTITY FULL and REPLICA IDENTITY NOTHING do not qualify, even when the table has a PRIMARY KEY. Tables without an index-based replica identity can be added to a set that replicates only INSERTs and TRUNCATEs.
Unlike spock.repset_add_table(), which raises an error when the table cannot be replicated, this function never refuses the whole call on account of a single relation. A schema that does not exist is still an error.
Views, materialized views, sequences, and UNLOGGED and TEMPORARY tables are not considered at all.
Partitioned tables and their partitions are collected independently, each in its own right, and each is checked separately. ALTER TABLE … REPLICA IDENTITY does not cascade to partitions in any supported PostgreSQL version, so a partitioned table and its partitions can differ here: a partition may be skipped while its parent is added, or the reverse. Spock resolves replication set membership per relation, so a skipped partition means changes to the rows stored in that partition are not replicated, even when the parent is a member.
The synchronize_data parameter controls whether existing table data is immediately synchronized to subscribers. When set to true, a full table copy is initiated for each table on all subscribers subscribed to the replication set.
This function writes metadata into the Spock catalogs to track which tables are part of the replication set.
This command must be executed by a superuser.
ARGUMENTS
set_name
The name of an existing replication set.
schema_names
An array of schema names from which all tables will be added.
synchronize_data
If true, synchronize existing table data to all subscribers immediately. Default is false.
EXAMPLE
Specify the names of one or more schemas in an array to add all of the tables in the schemas to the specified replication set; the following command adds all of the tables in the public schema to the default replication set:
postgres=# SELECT spock.repset_add_all_tables('default', ARRAY['public']);
-[ RECORD 1 ]---------+--
repset_add_all_tables | t
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
16 - spock.repset_add_partition()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset-add-partition ()
SYNOPSIS
spock.repset_add_partition ( parent regclass, partition regclass, row_filter text)
RETURNS
0 if the parent table is not a partitioned table or if all partitions are already in the replication sets.
A positive integer indicating the count of partitions successfully added to replication sets.
DESCRIPTION
Adds a partition of a table to the same replication set(s) as its parent table.
This function is used when working with partitioned tables to ensure that new or existing partitions are properly included in replication. If the partition argument is omitted, Spock automatically discovers and adds all partitions of the specified parent table.
An optional row_filter can be supplied to limit which rows from the partition are replicated.
This function writes metadata into the Spock catalogs and does not modify PostgreSQL configuration.
This command must be executed by a superuser.
ARGUMENTS
parent
The parent partitioned table, specified as a regclass.
partition
A specific partition table to add. If omitted, all partitions of the parent are added. The default is NULL.
row_filter
An optional SQL expression used to filter which rows from the partition are replicated. The default is NULL.
EXAMPLE
Add all four partitions of a parent table (named ‘public.sales_parent’) to the replication set to which the parent belongs:
SELECT spock.repset_add_partition('public.sales_parent');
-[ RECORD 1 ]--------+--
repset_add_partition | 4
Add a specific partition (named public.sales_2026_q1) to the replication set to which the parent table belongs:
postgres=# SELECT spock.repset_add_partition(
'public.sales_parent',
'public.sales_2026_q1',
'region = ''US'''
);
-[ RECORD 1 ]--------+--
repset_add_partition | 1
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
17 - spock.repset_add_seq()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_add_seq()
SYNOPSIS
spock.repset_add_seq ( set_name name, relation regclass, synchronize_data boolean)
RETURNS
- true if the sequence was successfully added to 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
Adds a sequence to an existing Spock replication set.
Once added, changes to the sequence value are replicated to subscribers that are subscribed to the replication set. This ensures that nextval operations remain consistent across nodes in a multi-master environment.
If synchronize_data is true, the current sequence value is immediately synchronized to all subscribers.
This function updates metadata stored in the Spock catalogs and does not modify PostgreSQL configuration.
This command must be executed by a superuser.
ARGUMENTS
set_name
The name of an existing replication set.
relation
The sequence to add, specified as a regclass (for example, ‘public.my_sequence’).
synchronize_data
If true, the current sequence value is synchronized to all subscribers. The default is false.
EXAMPLE
Add a sequence (named public.sales_order_no_seq) to the ‘default’ replication set:
postgres=# SELECT spock.repset_add_seq('default', 'public.sales_order_no_seq');
repset_add_seq
----------------
t
(1 row)
Add a sequence (named public.sales_invoice_no_seq) and synchronize its current value:
postgres=# SELECT spock.repset_add_seq(
'default',
'public.sales_invoice_no_seq',
synchronize_data := true
);
repset_add_seq
----------------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
18 - spock.repset_add_table()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_add_table()
SYNOPSIS
spock.repset_add_table ( set_name name, relation regclass, synchronize_data boolean, columns text[], row_filter text, include_partitions boolean )
RETURNS
- true if the table was successfully added to 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
Adds a specific table to an existing Spock replication set.
This function allows fine-grained control over what data is replicated by optionally specifying:
- A subset of columns to replicate.
- A row filter to restrict which rows are replicated.
- Whether partitions of a partitioned table should also be included.
If synchronize_data is set to true, existing table data is copied to all subscribers that are subscribed to this replication set. Otherwise, only future changes are replicated.
When used with partitioned tables, include_partitions controls whether child partitions are automatically included in the replication set.
This function writes metadata into the Spock catalogs and does not modify PostgreSQL configuration.
This command must be executed by a superuser.
ARGUMENTS
set_name
The name of an existing replication set.
relation
The table to add, specified as a regclass (for example, ‘public.mytable’).
synchronize_data
If true, existing table data is synchronized to all subscribers. Default is false.
columns
An optional list of column names to replicate. If NULL, all columns are replicated.
row_filter
An optional SQL WHERE clause used to filter which rows are replicated.
include_partitions
If true and the table is partitioned, all partitions are included automatically. Default is true.
EXAMPLE
The following command adds a table named public.accounts to the demo_repset replication set with full replication:
SELECT spock.repset_add_table('demo_repset', 'public.accounts');
The following command adds a table named public.accounts to the demo_repset replication set, and synchronizes existing data:
SELECT spock.repset_add_table('demo_repset',
'public.accounts',
synchronize_data := true);
The following command adds only specific columns (id and balance) from the public.accounts table to the demo_repset replication set, and filters the rows:
SELECT spock.repset_add_table('demo_repset',
'public.accounts',
columns := ARRAY['id','balance'],
row_filter := 'balance > 0');
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 the subscriber. You may need to call
spock.sub_resync_table() to fix it.
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
19 - spock.repset_alter()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_alter()
SYNOPSIS
spock.repset_alter ( set_name name, replicate_insert boolean, replicate_update boolean, replicate_delete boolean, replicate_truncate boolean )
RETURNS
The OID of the altered replication set.
DESCRIPTION
Modifies the replication behavior of an existing Spock replication set.
Each replication set defines which types of table operations are replicated to subscribers. This function allows you to change those behaviors after the set has been created.
Any argument left as NULL will retain its current setting. Only the specified operation types are modified.
This function updates metadata in the Spock catalogs and does not change PostgreSQL server configuration.
This command must be executed by a superuser.
ARGUMENTS
set_name
The name of an existing replication set.
replicate_insert
If true, INSERT operations are replicated; the default is NULL.
replicate_update
If true, UPDATE operations are replicated; the default is NULL.
replicate_delete
If true, DELETE operations are replicated; the default is NULL.
replicate_truncate
If true, TRUNCATE operations are replicated; the default is NULL.
EXAMPLE
The following command enables all operations in the demo_repset replication set:
postgres=# SELECT spock.repset_alter('demo_repset',
replicate_insert := true,
replicate_update := true,
replicate_delete := true,
replicate_truncate := true);
repset_alter
--------------
3356172311
(1 row)
The following command disables DELETE and TRUNCATE replication in the audit_only replication_set:
postgres=# SELECT spock.repset_alter('audit_only',
replicate_delete := false,
replicate_truncate := false);
repset_alter
--------------
3744767607
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
20 - spock.repset_create()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_create()
SYNOPSIS
spock.repset_create ( set_name name, replicate_insert boolean = true, replicate_update boolean = true, replicate_delete boolean = true, replicate_truncate boolean = true )
RETURNS
The OID of the newly created replication set.
DESCRIPTION
Creates a new Spock replication set.
A replication set defines which types of table operations are replicated to subscribers. Tables can later be added to this replication set with other Spock functions.
By default, all data modification operations are replicated; INSERT, UPDATE, DELETE, and TRUNCATE.
You can selectively disable specific operation types when creating the set.
This function writes metadata into the Spock catalogs but does not alter any PostgreSQL server configuration.
This command must be executed by a superuser.
ARGUMENTS
set_name
The unique name for the replication set.
replicate_insert
If true (the default), INSERT operations are replicated.
replicate_update
If true (the default), UPDATE operations are replicated.
replicate_delete
If true (the default), DELETE operations are replicated.
replicate_truncate
If true (the default), TRUNCATE operations are replicated.
EXAMPLE
The following example creates a replication set named demo_repset; all operations are replicated to the set:
postgres=# SELECT spock.repset_create('demo_repset');
repset_create
---------------
3356172311
(1 row)
The following command creates a replication set named audit_only; only INSERT and UPDATE statements are replicated:
postgres=# SELECT spock.repset_create('audit_only',
replicate_delete := false,
replicate_truncate := false);
repset_create
---------------
3744767607
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
21 - spock.repset_drop()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_drop()
SYNOPSIS
spock.repset_drop (set_name name, ifexists boolean)
RETURNS
true if the replication set was successfully dropped.
false if the replication set does not exist and ifexists is true.
ERROR if the replication set does not exist and ifexists is false.
DESCRIPTION
Drops an existing replication set.
This function removes a replication set from the Spock configuration. When a replication set is dropped, all table, sequence, and DDL memberships associated with it are removed. However, the actual tables and sequences themselves remain in the database - only their association with the replication set is deleted.
Dropping a replication set does not affect existing subscriptions that reference it, but those subscriptions will stop receiving changes for objects that were in the dropped replication set. Subscriptions can be modified to remove the dropped replication set using spock.sub_remove_repset().
The ifexists parameter controls error-handling behavior for the function; when set to true, the function returns false if the replication set does not exist instead of raising an error. This is useful in situations where the replication set may or may not be present.
This function modifies the Spock catalogs but does not modify any user data or the Postgres server configuration.
ARGUMENTS
set_name
The name of the replication set to drop.
ifexists
If true, the function returns false instead of raising an error when the replication set does not exist. Defaults to false.
EXAMPLE
The following command drops a replication set named demo_repset; it does not raise an error if the set does not exist:
postgres=# SELECT spock.repset_drop('demo_repset', true);
repset_drop
-------------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
22 - spock.repset_remove_partition()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_remove_partition()
SYNOPSIS
spock.repset_remove_partition (parent regclass, partition regclass)
RETURNS
The number of partitions removed from replication sets as an integer.
DESCRIPTION
Removes a partition or all partitions of a partitioned table from the replication sets that include the parent table.
This function removes partition tables from replication without affecting the parent table’s replication membership. When a specific partition is provided, only that partition is removed. When the partition parameter is NULL, all partitions of the parent table are removed from replication.
This is useful when you want to exclude specific partitions from replication while keeping the parent table and other partitions replicated. For example, you might want to replicate recent partitions but not historical data stored in older partitions.
Removing a partition from replication does not drop the partition table itself - it only removes the partition from the replication sets. The partition remains in the database and can still be accessed locally.
The function returns the count of partitions that were actually removed from replication sets. If no partitions were removed (because they were not in any replication sets), it returns 0.
This function modifies the Spock catalogs but does not modify any user data or PostgreSQL server configuration.
ARGUMENTS
parent
The parent partitioned table whose partition(s) should be removed from replication.
partition
The specific partition to remove from replication. If NULL, all partitions of the parent table are removed. Defaults to NULL.
EXAMPLE
SELECT spock.repset_remove_partition('public.mytable',
'public.mytable_202012');
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
23 - spock.repset_remove_seq()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_remove_seq ()
SYNOPSIS
spock.repset_remove_seq ( set_name name, relation regclass)
RETURNS
- true if the sequence was successfully removed from 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
Removes a sequence from an existing Spock replication set.
After removal, changes to the sequence value are no longer replicated to subscribers of the replication set.
This function updates metadata stored in the Spock catalogs and does not modify PostgreSQL configuration.
This command must be executed by a superuser.
ARGUMENTS
set_name
The name of an existing replication set.
relation
The sequence to remove, specified as a regclass (for example, ‘public.my_sequence’).
EXAMPLE
Remove a sequence (public.orders_id_seq) from a replication set (demo_repset):
postgres=# SELECT spock.repset_remove_seq('demo_repset', 'public.orders_id_seq');
repset_remove_seq
-------------------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
24 - spock.repset_remove_table()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_remove_table ()
SYNOPSIS
spock.repset_remove_table ( set_name name, relation regclass, include_partitions boolean)
RETURNS
- true if the table was successfully removed from 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
Removes a table from an existing Spock replication set. After removal, changes to this table will no longer be replicated to subscribers that are subscribed to the replication set.
If the table is partitioned, the include_partitions argument controls whether all child partitions are also removed from the replication set.
This function updates metadata stored in the Spock catalogs and does not modify the PostgreSQL configuration.
This command must be executed by a superuser.
ARGUMENTS
set_name
The name of an existing replication set.
relation
The table to remove, specified as a regclass (for example, ‘public.mytable’).
include_partitions
If true and the table is partitioned, all partitions are also removed from the replication set. Default is true.
EXAMPLE
Remove a table (public.users) from the default replication set:
postgres=# SELECT spock.repset_remove_table('default', 'public.users');
repset_remove_table
---------------------
t
(1 row)
Remove a partitioned table named public.sales_parent from the default replication set without removing its partitions:
postgres=# SELECT spock.repset_remove_table('default',
'public.users',
include_partitions := false);
---------------------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
25 - spock.repset_show_table()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.repset_show_table()
SYNOPSIS
spock.repset_show_table (relation regclass, repsets text[])
RETURNS
A record containing detailed information about how a table is configured for replication:
- relid is the OID of the table relation.
- nspname is the schema name of the table.
- relname is the table name.
- att_list is an array of column names included in replication.
- has_row_filter is true if a row filter is applied to the table.
- relkind is the relation kind (‘r’ for regular table, ‘p’ for partitioned table).
- relispartition is true if the table is a partition of a partitioned table.
DESCRIPTION
Returns detailed replication configuration information for a specific table within the specified replication sets.
This function queries how a table is configured for replication across one or more replication sets. It shows which columns are included in replication, whether row filtering is applied, and metadata about the table type and partition status.
The att_list field shows the specific columns that will be replicated. If all columns are replicated, this will contain all column names. If column filtering was configured when the table was added to a replication set, only the specified columns appear in this list.
The has_row_filter field indicates whether a row filter expression is applied to the table, which would limit which rows are replicated based on custom criteria.
The repsets parameter allows you to check the table’s configuration across multiple replication sets. The function returns information based on how the table is configured in those sets.
This is a read-only query function that does not modify any data.
ARGUMENTS
relation
The table to query information about.
repsets
An array of replication set names to check the table’s configuration within.
EXAMPLE
The following command shows detailed information about the public.invoices table:
postgres=# SELECT * FROM spock.repset_show_table('public.invoices',
ARRAY['default', 'ddl_sql']);
-[ RECORD 1 ]--+-----------------------------------------
relid | 17241
nspname | public
relname | invoices
att_list | {order_id,customer_id,order_date,amount}
has_row_filter | f
relkind | r
relispartition | f
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
26 - spock.sub_add_repset()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.sub_add_repset()
SYNOPSIS
spock.sub_add_repset (subscription_name name, replication_set name)
RETURNS
true if the replication set was successfully added.
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
Adds a replication set to an existing subscription.
This function modifies a subscription to begin receiving changes from an additional replication set on the provider node. The subscription will start consuming events from the newly added replication set immediately.
This operation does not perform data synchronization. It only activates the consumption of future events from the replication set. If you need to synchronize existing data from the replication set, you must handle that separately.
This function writes metadata into the Spock catalogs.
Returns NULL if any argument is NULL.
This command must be executed by a superuser.
ARGUMENTS
subscription_name
The name of an existing subscription.
replication_set
The name of the replication set to add to the subscription.
EXAMPLE
The following example adds a replication set named audit_only to a subscription named sub_n2_n1:
postgres=# SELECT spock.sub_add_repset('sub_n2_n1', 'audit_only');
-[ RECORD 1 ]--+--
sub_add_repset | t
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
27 - spock.sub_alter_interface()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.sub_alter_interface()
SYNOPSIS
spock.sub_alter_interface (subscription_name name, interface_name name)
RETURNS
true if the interface was successfully changed.
Raises an ERROR if the subscription or interface does not exist, or if the call has invalid parameters or insufficient privileges.
DESCRIPTION
Changes the network interface used by a subscription to connect to its provider node.
This function modifies an existing subscription to use a different interface when establishing the replication connection to the provider. The specified interface must already exist on the provider node.
This is useful for switching between different network paths, such as moving from a public network to a private network connection, or switching to a different hostname or IP address for the same provider node.
The subscription connection will be restarted using the new interface.
This function writes metadata into the Spock catalogs.
This command must be executed by a superuser.
ARGUMENTS
subscription_name
The name of an existing subscription.
interface_name
The name of an existing interface on the provider node.
EXAMPLE
The following example modifies the interface used when connecting to the replication cluster to use the connection string associated with an interface named private_net:
postgres=# SELECT spock.sub_alter_interface('sub_n2_n1', 'private_net');
sub_alter_interface
---------------------
t
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
28 - spock.sub_alter_options()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.sub_alter_options()
SYNOPSIS
spock.sub_alter_options (subscription_name name, options jsonb)
RETURNS
true if the
optionsobject contained at least one key; the Spock catalog is updated and the apply worker is signalled to restart.false if the
optionsobject was empty ({}); the catalog is not touched and the apply worker is not restarted.Raises an ERROR if the subscription does not exist, if
optionsis not a JSON object, if an unrecognised key is supplied, or if any option value fails validation.
DESCRIPTION
Changes one or more options on an existing subscription in a single atomic operation.
Only the keys present in the options object are modified; omitted
options retain their current values. If the object is empty ({}), the
function returns false without touching the catalog or restarting the
apply worker.
When at least one key is present in options, the function writes the
new values to the Spock catalog and signals the apply worker to restart
so that they take effect. The caller can use spock.sub_show_status()
or spock.sub_wait_for_sync() to confirm the worker has restarted and
reached replicating status.
ARGUMENTS
subscription_name
The name of an existing subscription.
options
A JSON object whose keys are the option names to change. Unrecognised keys raise an error. Supported keys:
forward_origins
A JSON array of origin names whose transactions the subscriber should apply or receive based on their origin. The only accepted element is the string “all”. Pass an empty array ([]) to disable origin forwarding.
See Origin Forwarding for the restriction on combining this with other enabled subscriptions.
apply_delay
A PostgreSQL interval string (e.g. “2 seconds”, “500ms”, “0”) that sets how long the apply worker waits before applying each transaction. The value must be a string; passing a bare number raises an error.
skip_schema
A JSON array of schema names to exclude from apply. Pass an empty array ([]) to clear the exclusion list.
EXAMPLE
Set a 2-second apply delay:
postgres=# SELECT spock.sub_alter_options('sub_n2_n1',
'{"apply_delay": "2 seconds"}');
sub_alter_options
-------------------
t
(1 row)
Enable forwarding of all origins and exclude the audit schema in a
single call:
postgres=# SELECT spock.sub_alter_options('sub_n2_n1',
'{"forward_origins": ["all"], "skip_schema": ["audit"]}');
sub_alter_options
-------------------
t
(1 row)
No-op call (empty object); returns false without restarting the worker:
postgres=# SELECT spock.sub_alter_options('sub_n2_n1', '{}');
sub_alter_options
-------------------
f
(1 row)
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
29 - spock.sub_alter_skiplsn()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.sub_alter_skiplsn()
SYNOPSIS
spock.sub_alter_skiplsn (subscription_name name, lsn pg_lsn) RETURNS boolean
RETURNS
true if the skip LSN was successfully set, false otherwise.
DESCRIPTION
Advances the replication position of an existing subscription to the specified Log Sequence Number (LSN). This is typically used as a recovery operation when a subscription is unable to proceed due to a problematic change in the replication stream. Any changes between the old LSN and the specified LSN will be permanently skipped.
This command must be executed by a superuser.
ARGUMENTS
subscription_name
The name of an existing subscription.
lsn
The Log Sequence Number to which the subscription should advance.
EXAMPLE
SELECT spock.sub_alter_skiplsn('sub_n1_to_n2', '0/16B6A50');
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
30 - spock.sub_alter_sync
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_alter_sync() function synchronizes all unsynchronized tables
in all sets in a single operation.
Synopsis
Description
The spock.sub_alter_sync() function synchronizes all unsynchronized tables
in all sets in a single operation. The function copies and synchronizes
tables one by one. The function does not wait for completion before returning
to the caller; use spock.sub_wait_for_sync() to wait for completion.
Arguments
The function accepts the following arguments:
- The
subscription_nameargument specifies the name of an existing subscription. - The
truncateargument accepts a boolean value; when set totrue, the function truncates tables before copying, and the default value isfalse.
Example
In the following example, the spock.sub_alter_sync() function synchronizes
all unsynchronized tables for a subscription named sub_n1_n2:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
31 - spock.sub_create()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.sub_create()
SYNOPSIS
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[])
RETURNS
The OID of the newly created subscription.
DESCRIPTION
Creates a subscription from the current node to a provider node.
This function establishes a replication subscription that allows the current (subscriber) node to receive changes from the specified provider node. The subscription defines which replication sets to subscribe to and how to handle initial synchronization.
The command returns immediately without waiting for the subscription to complete its initialization. Use spock.sub_wait_for_sync() to wait for the subscription to finish synchronizing and begin replicating.
The subscription_name is used as the application_name for the replication connection, making it visible in pg_stat_replication. This can be useful for monitoring and for configuring synchronous_standby_names in synchronous replication scenarios.
This function writes metadata into the Spock catalogs and initiates a replication connection to the provider.
This command must be executed by a superuser.
ARGUMENTS
subscription_name
A unique name for the subscription. Must be unique across the cluster. This name appears in pg_stat_replication as application_name.
provider_dsn
A PostgreSQL connection string specifying how to connect to the provider node.
replication_sets
An array of replication set names to subscribe to. Accepted values are default, default_insert_only, ddl_sql.
synchronize_structure
If true, synchronize table and schema structure from the provider before starting replication. Default is false.
synchronize_data
If true, perform an initial data copy for all tables in the subscribed replication sets. Default is false.
forward_origins
Controls which changes to replicate based on their origin. Use ‘{}’ to
only replicate changes originating locally on the provider node (origin ID 0,
i.e. not already replicated in from another node — useful for bidirectional
replication to avoid forwarding changes in a loop). Use {all} to replicate all
changes regardless of origin. The default is {} (local-origin changes only).
See Origin Forwarding for the restriction on combining this with other enabled subscriptions.
apply_delay
An interval specifying how long to delay applying changes from the provider. Useful for delayed standby scenarios. Default is ‘0’.
force_text_transfer
If true, replicate all columns using text representation. This is slower but allows type conversions on the subscriber. Default is false.
enabled
If true, the subscription is enabled immediately. If false, the subscription is created but not activated. Default is true.
skip_schema
An array of schema names to exclude from structure and data synchronization. Default is ‘{}’ (no schemas skipped).
EXAMPLE
SELECT spock.sub_create('sub_n2_n1',
'host=127.0.0.1 port=5432 dbname=postgres');
SELECT spock.sub_create('sub_n2_n1',
'host=10.0.0.10 port=5432 dbname=postgres',
replication_sets := '{default}',
synchronize_structure := true,
synchronize_data := true);
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
32 - spock.sub_disable
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_disable() function disables a subscription and disconnects
from the provider.
Synopsis
Arguments
The function accepts the following arguments:
subscription_name- The name of an existing subscription.immediate- Iftrue, the subscription is disabled immediately; otherwise it is disabled at the end of the current transaction. The default isfalse.
Example
In the following example, the spock.sub_disable() function disables a
subscription named sub_n1_n2:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
33 - spock.sub_drop()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.sub_drop()
SYNOPSIS
spock.sub_drop (subscription_name name, ifexists boolean)
RETURNS
The OID of the dropped subscription.
DESCRIPTION
Disconnects and removes a subscription from the cluster.
This function terminates the replication connection for the specified subscription and removes all associated metadata from the Spock catalogs. It does not affect data that has already been replicated to the subscriber.
If ifexists is set to false (default), an error is raised when the specified subscription does not exist. If ifexists is true, the function returns successfully without error.
Returns NULL if any argument is NULL.
This command must be executed by a superuser.
ARGUMENTS
subscription_name
The name of the existing subscription to remove.
ifexists
If true, do not raise an error when the subscription does not exist. Default is false.
EXAMPLE
SELECT spock.sub_drop('sub_n2_n1');
SELECT spock.sub_drop('sub_n2_n1', true);
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
34 - spock.sub_enable
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_enable() function enables a subscription. Replication workers
then resume normal processing for that subscription.
Synopsis
Description
The spock.sub_enable() function enables a subscription.
This fails if another subscription on this node already has origin forwarding active; see Origin Forwarding.
Arguments
The function accepts the following arguments:
subscription_name- The name of an existing subscription.immediate- Iftrue, the subscription is started immediately; otherwise the subscription will be started only at the end of the current transaction. The default isfalse.
Example
In the following example, the spock.sub_enable() function enables a
subscription named sub_n1_n2:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
35 - spock.sub_remove_repset
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_remove_repset() function removes a replication set from a
subscription.
Synopsis
Description
The spock.sub_remove_repset() function removes a replication set from a
subscription.
Arguments
The function accepts the following arguments:
subscription_name- The name of an existing subscription.replication_set- The name of the replication set to remove.
Example
In the following example, the spock.sub_remove_repset() function removes a
replication set named test from a subscription named sub_n1_n2:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
36 - spock.sub_resync_table
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_resync_table() function resynchronizes one existing table.
Synopsis
Description
The spock.sub_resync_table() function resynchronizes one existing table.
After the resynchronization is scheduled, the function compares the cached
spock.node row of the subscription’s provider with the provider’s own row.
If they differ, it raises a WARNING that suggests
spock.node_refresh_info(). The check does not
change spock.node, and a provider that cannot be reached for the check
produces a WARNING without failing the resynchronization.
Arguments
The function accepts the following arguments:
subscription_name- The name of an existing subscription.relation- The name of an existing table, optionally schema qualified.truncate- Truncate the table before synchronization; the default value istrue. Omitting the argument truncates the target table. Passfalseto keep existing rows. In that case, conflicting incoming rows can cause errors.
Example
In the following example, the spock.sub_resync_table() function
resynchronizes a table named public.users for a subscription named
sub_n1_n2:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
37 - spock.sub_show_status
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_show_status() function displays the status and basic
information about a subscription.
Synopsis
Returns
A set of rows describing the current state of one or more subscriptions. Each row contains:
- the name of the subscription.
- the current replication status.
- the name of the provider node.
- the connection string used to reach the provider.
- the name of the logical replication slot used by the subscription.
- the replication sets associated with the subscription.
- the origins that are forwarded by this subscription.
Status Values
The following table describes each possible value for the status
column:
| Status | Description |
|---|---|
replicating | The apply worker is running and initial synchronization is complete; changes from the provider are being applied normally. |
initializing | The apply worker is running but initial synchronization has not yet completed; table data is still being copied from the provider. |
disabled | The subscription was explicitly disabled with spock.sub_disable(); the apply worker is not running. |
down | The subscription is enabled but the apply worker is not running; the worker may not have started yet or may have exited unexpectedly. |
unknown | The apply worker is running but no synchronization status record was found; this is a transient state that typically resolves quickly. |
Description
spock.sub_show_status() displays detailed runtime information about
Spock subscriptions on the current node.
If a specific subscription name is provided, only that subscription is
shown. If NULL (the default), the function returns status for all
subscriptions on the node.
This function is useful for monitoring replication health, validating configuration, and verifying which replication sets and origins are in use. The information is derived from Spock catalog metadata and the current state of logical replication workers.
This function does not modify any configuration.
Arguments
subscription_name- The optional name of an existing subscription. If no name is provided, the function shows the status for all subscriptions on the local node.
Example
To display the status of all subscriptions, run:
In the following example, the spock.sub_show_status() function displays the
status of a subscription named sub_n1_n2:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
38 - spock.sub_show_table
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_show_table() function displays the synchronization status of a
table.
Synopsis
Description
The spock.sub_show_table() function shows the synchronization status of a
table.
Arguments
The function accepts the following arguments:
subscription_name- The name of an existing subscription.relation- The name of an existing table, optionally qualified.
Example
In the following example, the spock.sub_show_table() function displays the
synchronization status of a table named test for a subscription named
sub_n2:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
39 - spock.sub_wait_for_sync
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sub_wait_for_sync() function waits until a specified subscription
has completed its initial schema and data synchronization.
Synopsis
Description
The spock.sub_wait_for_sync() function waits until the specified subscription
has completed its initial schema and data synchronization, and any pending
table resynchronizations have finished.
This function blocks the current session until the subscription is fully synchronized. The function monitors both the initial sync phase (if the subscription is newly created) and any tables that are undergoing individual resynchronization due to replication set changes or manual resync operations.
For optimal results, execute spock.wait_slot_confirm_lsn() on the provider
node after making replication set changes that trigger resyncs. This approach
ensures the provider has flushed all necessary changes before checking sync
status on the subscriber. Only after the provider confirms the LSN should you
call spock.sub_wait_for_sync() on the subscriber.
The function will continue waiting indefinitely until synchronization completes, so callers should ensure the subscription is actively processing and that there are no blocking issues preventing sync completion.
Arguments
The function accepts the following argument:
subscription_name- The name of the subscription to monitor for sync completion.
Example
In the following example, the spock.sub_wait_for_sync() function waits for a
subscription named sub_n2_n1 to complete synchronization:
For more information about using subscription synchronization with Zero-Downtime Add Node, see the ZODAN Tutorial.
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
40 - spock.sync_event
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sync_event() function creates a synchronization event in the
replication stream and returns its Log Sequence Number (LSN).
Synopsis
Returns
The function returns the Log Sequence Number (LSN) of the created
synchronization event as pg_lsn.
Description
The spock.sync_event() function creates a synchronization event in the
replication stream and returns its LSN.
This function inserts a special synchronization marker into the logical
replication stream at the current write position. The returned LSN identifies
this marker’s location in the write-ahead log and can be used with functions
like spock.wait_slot_confirm_lsn() to verify that subscribers have processed
replication up to this point.
Synchronization events are useful for coordinating activities across multiple nodes in a replication topology. By creating a sync event on a provider and then waiting for subscribers to reach that LSN, you can ensure all nodes have processed a consistent set of changes before proceeding with operations that depend on synchronized state.
The sync event itself does not contain data or modify any tables; the event serves purely as a coordination marker in the replication stream.
This function modifies the replication stream by inserting a sync marker.
Arguments
transactional(optional, defaultfalse) - Whenfalse, the sync event marker is emitted immediately into the WAL stream, independent of the calling transaction. Whentrue, the marker is bound to the calling transaction and is only visible to subscribers if the transaction commits.
Example
In the following example, the spock.sync_event() function creates a
synchronization event and returns the LSN:
For more information about using synchronization events with Zero-Downtime Add Node, see the ZODAN Tutorial.
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
41 - spock.sync_seq
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
The spock.sync_seq() function synchronizes the current state of a sequence
to all subscribers.
Synopsis
Description
Captures the current value of a sequence on the provider node and pushes it into the replication stream so that subscribers can update their local copy to match. This ensures sequence values remain coordinated across nodes.
This function must be executed on the provider node. The sequence state update is embedded in the transaction where this function is called, and subscribers apply the update when they replicate that transaction.
Replication set filtering applies — only subscribers whose subscriptions include the replication set containing this sequence will receive the update.
Arguments
The function accepts the following argument:
relation- The name of the sequence to synchronize, optionally schema-qualified.
Example
In the following example, the spock.sync_seq() function synchronizes a
sequence named public.sales_order_no_seq:
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
42 - spock.table_wait_for_sync()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.table_wait_for_sync()
SYNOPSIS
spock.table_wait_for_sync (subscription_name name, relation regclass)
RETURNS
void (returns nothing upon successful completion).
DESCRIPTION
Waits until the specified table has completed synchronization for the given subscription.
This function blocks the current session until the specified table finishes its synchronization process. This is useful when you need to ensure a specific table is fully synchronized before proceeding with operations that depend on its data.
Unlike spock.sub_wait_for_sync() which waits for all tables in a subscription to sync, this function targets a single table. This allows for more granular control when monitoring synchronization progress or when only specific tables are critical to downstream operations.
For optimal results, execute spock.wait_slot_confirm_lsn() on the provider node after making replication set changes that trigger table resyncs. This ensures the provider has flushed all necessary changes before checking sync status on the subscriber. Only after the provider confirms the LSN should you call spock.table_wait_for_sync() on the subscriber.
The function will continue waiting indefinitely until the table synchronization completes, so callers should ensure the subscription is actively processing and that there are no blocking issues preventing sync completion.
ARGUMENTS
subscription_name
The name of the subscription to monitor.
relation
The name of the table to wait for, specified as a regclass (can be schema-qualified).
EXAMPLE
SELECT spock.table_wait_for_sync('sub_n2_n1', 'public.mytable');
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
43 - spock.version_num()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.spock_version_num()
SYNOPSIS
spock.spock_version_num ()
RETURNS
The version number of the installed Spock extension as an integer.
DESCRIPTION
Returns the version number of the Spock extension as an integer.
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.
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 is a read-only query function that does not modify any data.
ARGUMENTS
This function takes no arguments.
EXAMPLE
The following command returns the current Spock extension version as an integer:
postgres=# SELECT spock.spock_version_num();
-[ RECORD 1 ]-----+------
spock_version_num | 50005
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
44 - spock.version()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.spock_version()
SYNOPSIS
spock.spock_version ()
DESCRIPTION
Returns the Spock version in a human-readable major/minor form (for example, 5.0.5).
EXAMPLE
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
45 - spock.wait_slot_confirm_lsn()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.wait_slot_confirm_lsn()
SYNOPSIS
spock.wait_slot_confirm_lsn (slotname name, target pg_lsn)
RETURNS
void (returns nothing upon successful completion).
DESCRIPTION
Waits until the specified replication slot has confirmed receipt of changes up to the target Log Sequence Number (LSN).
This function blocks the current session until the replication slot’s confirmed flush LSN reaches or exceeds the specified target LSN. This is useful for ensuring that a subscriber has received and acknowledged replication changes before proceeding with subsequent operations.
The confirmed flush LSN represents the position up to which the subscriber has successfully received, applied, and durably stored the replicated changes. This function provides a synchronization mechanism to coordinate activities between the provider and subscriber nodes.
If the replication slot does not exist, the function will raise an error. The function will continue waiting indefinitely until the target LSN is reached, so callers should ensure the target LSN is reachable and that the subscription is actively processing changes.
This function does not modify any data but may block for an extended period depending on replication lag and network conditions.
ARGUMENTS
slotname
The name of the replication slot to monitor.
target
The target Log Sequence Number to wait for. The function returns when the slot’s confirmed flush LSN reaches or exceeds this value.
EXAMPLE
The following command waits for a slot named spock_local_sync_346_79a to confirm that it has received changes to the target LSN (0/3000000):
SELECT spock.wait_slot_confirm_lsn('spock_local_sync_346_79a',
'0/3000000');
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.
46 - spock.xact_commit_timestamp_origin()
The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use Spock 5.0.15.
spock.xact_commit_timestamp_origin()
SYNOPSIS
spock.xact_commit_timestamp_origin (xid xid, OUT timestamp timestamptz, OUT roident oid)
RETURNS
A record containing transaction commit information:
- timestamp is the commit timestamp of the transaction.
- roident is the replication origin identifier of the transaction.
DESCRIPTION
Returns the commit timestamp and replication origin identifier for a given transaction ID.
This function queries PostgreSQL’s commit timestamp tracking system to retrieve when a specific transaction was committed and which replication origin it came from. The replication origin identifies the source node in a multi-node replication topology, allowing you to trace where changes originated.
The commit timestamp tracking feature (track_commit_timestamp) must be enabled in PostgreSQL for this function to return meaningful results. If commit timestamp tracking is disabled, the function may return NULL or raise an error.
The replication origin identifier (roident) will be 0 for transactions
committed locally on this node (i.e., not replicated in from another node).
For replicated transactions, it identifies the origin node from which the
changes were received. A NULL result for the timestamp or origin means the
origin metadata is unavailable or unknown (for example, because
track_commit_timestamp was not enabled at the time of the commit) — NULL
is distinct from 0 and does not indicate a local change.
This is a read-only query function that does not modify any data.
ARGUMENTS
xid
The transaction ID to query.
EXAMPLE
SELECT * FROM spock.xact_commit_timestamp_origin('12345'::xid);
Upstream source · d05e2e2b6a82 · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. PostgreSQL License.