Skip to content

Spock Functions

The following user functions are available via the Spock extension:

Command Description
Node Management Functions You can add and remove nodes dynamically using Spock interfaces.
spock.node_info Returns information about the node on which the function is invoked.
spock.node_create Define a node for spock.
spock.node_drop Remove a spock node.
node_add_interface Add a new node interface.
spock.node_drop_interface Delete a node interface.
Replication Set Management Functions Replication sets provide a mechanism to control which tables in the database will be replicated and which actions on those tables will be replicated. Each replicated set can specify individually if INSERTs, UPDATEs, DELETEs and TRUNCATEs on the set are replicated. Each table can be in multiple replication sets, and each subscriber can subscribe to multiple replication sets. The resulting set of tables and actions replicated is the union of the sets the table is in. Spock installation creates three replication sets: default, default_insert_only and ddl_sql. The default replication set is defined to replicate all changes to tables in it. The default_insert_only replication set only replicates INSERT statements, and is meant for use by tables that don't have primary key. The ddl_sql replication set is defined to replicate schema changes specified by spock.replicate_ddl.
spock.repset_create Define a replication set.
spock.repset_alter Modify a replication set.
repset_drop Remove a replication set.
spock.repset_add_partition Add a partition to a replication set.
spock.repset_remove_partition Remove a partition from the replication set that the parent table is a part of.
spock.repset_add_table Add table(s) to replication set.
spock.repset_add_all_tables Add all existing table(s) to the replication set.
spock.repset_remove_table Remove table from replication set.
spock.repset_show_table
repset_add_seq Deprecated; Adds a sequence to a replication set.
repset_add_all_seqs Deprecated; Adds all sequences from the specified schemas to a replication set.
repset_remove_seq Deprecated; Remove a sequence from a replication set.
spock.sync_seq Synchronize the specified sequence.
Subscription Management Functions
spock.sub_create Create a subscription.
spock.sub_drop Delete a subscription.
spock.sub_disable Put a subscription on hold, and disconnect from the provider.
spock.sub_enable Make a subscription live.
spock.sub_add_repset Add a replication set to a subscription.
spock.sub_remove_repset Drop a replication set from a subscription.
spock.sub_show_status Display the status of the subcription.
spock.sub_show_table Show subscription tables.
spock.sub_alter_interface Modify an interface to a subscription.
spock.sub_wait_for_sync Pause until the subscription is synchronized.
spock.sub_alter_skiplsn Skip transactions until the specified lsn.
spock.sub_alter_sync Synchronize all missing tables.
spock.sub_resync_table Synchronize a specific table.
Miscellaneous Management Functions
spock.table_wait_for_sync Pause until a table finishes synchronizing.
spock.replicate_ddl 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.convert_sequence_to_snowflake Convert a Postgres native sequence to a Snowflake sequence.
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.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.
spock.xact_commit_timestamp_origin Returns the commit timestamp and origin of the specified transaction.