Skip to content

Instantly share code, notes, and snippets.

@hanefi
Last active April 14, 2023 14:11
Show Gist options
  • Save hanefi/5685b62049706662afd7abd8985e380d to your computer and use it in GitHub Desktop.
Save hanefi/5685b62049706662afd7abd8985e380d to your computer and use it in GitHub Desktop.
Generated Documentation of Citus using pg_readme

Intro

I recently found out about pg_readme extension, and I tried to generate a documentation for Citus extension using it. This gist is an inital dump on what we can accomplish using this tool.

TOC

What is pg_readme PostgreSQL extension

The pg_readme PostgreSQL extension provides functions to generate a README.md document for a database extension or schema, based on COMMENT objects found in the pg_description system catalog.

My steps to generate these files

I generated 2 different markdown files for the last release as of today (Citus 11.1), and the one we aim to release this week (Citus 11.2). Apart from these 2, I also created a diff that might be handy to show what changed between these 2 releases.

  1. I created a new cluster with Citus and pg_readme installed.
  2. I updated the comment on Citus extension to contain the necessary template for pg_readme.
COMMENT ON EXTENSION citus IS $markdown$
# Citus distributed database #

<?pg-readme-reference?>
$markdown$;
  1. I generated the markdown documentation using the following shell command:
psql -p9700 --no-align --tuples-only --command "SELECT pg_extension_readme('citus');" --output 11.2.md

Future ideas

  • Improve the format of this documentation and let it live inside the codebase of Citus.
  • Create this documentation automatically by a CI job.
    • Try to create a bot that pushes commits on PRs whenever Citus API changes.
  • Make this generated documentation efforts part of our major release procedures
  • Try to create a blog post out of this efforts.
  • Fix some bugs found in pg_readme. The author is quite responsive.

t

pg_extension_name: citus pg_extension_version: 11.1-1 pg_readme_generated_at: 2023-01-30 17:35:52.80893+03 pg_readme_version: 0.5.5

Citus distributed database

Object reference

Schema: pg_catalog

citus must be installed in the pg_catalog schema. Hence, it is not relocatable.


system catalog schema

Tables

There are 16 tables that directly belong to the citus extension.

Table: pg_dist_shard

The pg_dist_shard table has 6 attributes:

  1. pg_dist_shard.logicalrelid regclass

    • NOT NULL
  2. pg_dist_shard.shardid bigint

    • NOT NULL
  3. pg_dist_shard.shardstorage "char"

    • NOT NULL
  4. pg_dist_shard.........pg.dropped.4........ -

  5. pg_dist_shard.shardminvalue text

  6. pg_dist_shard.shardmaxvalue text

Table: pg_dist_transaction

The pg_dist_transaction table has 2 attributes:

  1. pg_dist_transaction.groupid integer

    • NOT NULL
  2. pg_dist_transaction.gid text

    • NOT NULL

Table: pg_dist_local_group

The pg_dist_local_group table has 1 attributes:

  1. pg_dist_local_group.groupid integer

    • NOT NULL
    • PRIMARY KEY (groupid)

Table: pg_dist_placement

The pg_dist_placement table has 5 attributes:

  1. pg_dist_placement.placementid bigint

    • NOT NULL
    • DEFAULT nextval('pg_dist_placement_placementid_seq'::regclass)
  2. pg_dist_placement.shardid bigint

    • NOT NULL
  3. pg_dist_placement.shardstate integer

    • NOT NULL
  4. pg_dist_placement.shardlength bigint

    • NOT NULL
  5. pg_dist_placement.groupid integer

    • NOT NULL

Table: pg_dist_node_metadata

The pg_dist_node_metadata table has 1 attributes:

  1. pg_dist_node_metadata.metadata jsonb

    • NOT NULL

Table: pg_dist_authinfo

The pg_dist_authinfo table has 3 attributes:

  1. pg_dist_authinfo.nodeid integer

    • NOT NULL
  2. pg_dist_authinfo.rolename name

    • NOT NULL
    • CHECK (role_exists(rolename))
  3. pg_dist_authinfo.authinfo text

    • NOT NULL
    • CHECK (authinfo_valid(authinfo))

Table: pg_dist_poolinfo

The pg_dist_poolinfo table has 2 attributes:

  1. pg_dist_poolinfo.nodeid integer

    • NOT NULL
    • PRIMARY KEY (nodeid)
  2. pg_dist_poolinfo.poolinfo text

    • NOT NULL
    • CHECK (poolinfo_valid(poolinfo))

Table: pg_dist_node

The pg_dist_node table has 11 attributes:

  1. pg_dist_node.nodeid integer

    • NOT NULL
    • DEFAULT nextval('pg_dist_node_nodeid_seq'::regclass)
    • PRIMARY KEY (nodeid)
  2. pg_dist_node.groupid integer

    • NOT NULL
    • DEFAULT nextval('pg_dist_groupid_seq'::regclass)
  3. pg_dist_node.nodename text

    • NOT NULL
  4. pg_dist_node.nodeport integer

    • NOT NULL
    • DEFAULT 5432
  5. pg_dist_node.noderack text

    • NOT NULL
    • DEFAULT 'default'::text
  6. pg_dist_node.hasmetadata boolean

    • NOT NULL
    • DEFAULT false
  7. pg_dist_node.isactive boolean

    • NOT NULL
    • DEFAULT true
  8. pg_dist_node.noderole noderole

    • NOT NULL
    • DEFAULT 'primary'::noderole
  9. pg_dist_node.nodecluster name

    • NOT NULL
    • DEFAULT 'default'::name
  10. pg_dist_node.metadatasynced boolean

indicates whether the node has the most recent metadata

  • DEFAULT false
  1. pg_dist_node.shouldhaveshards boolean

indicates whether the node is eligible to contain data from distributed tables

  • NOT NULL
  • DEFAULT true

Table: pg_dist_colocation

The pg_dist_colocation table has 5 attributes:

  1. pg_dist_colocation.colocationid integer

    • NOT NULL
    • PRIMARY KEY (colocationid)
  2. pg_dist_colocation.shardcount integer

    • NOT NULL
  3. pg_dist_colocation.replicationfactor integer

    • NOT NULL
  4. pg_dist_colocation.distributioncolumntype oid

    • NOT NULL
  5. pg_dist_colocation.distributioncolumncollation oid

    • NOT NULL

Table: pg_dist_rebalance_strategy

The pg_dist_rebalance_strategy table has 8 attributes:

  1. pg_dist_rebalance_strategy.name name

    • NOT NULL
    • UNIQUE (name)
  2. pg_dist_rebalance_strategy.default_strategy boolean

    • NOT NULL
    • DEFAULT false
  3. pg_dist_rebalance_strategy.shard_cost_function regproc

    • NOT NULL
  4. pg_dist_rebalance_strategy.node_capacity_function regproc

    • NOT NULL
  5. pg_dist_rebalance_strategy.shard_allowed_on_node_function regproc

    • NOT NULL
  6. pg_dist_rebalance_strategy.default_threshold real

    • NOT NULL
  7. pg_dist_rebalance_strategy.minimum_threshold real

    • NOT NULL
    • DEFAULT 0
  8. pg_dist_rebalance_strategy.improvement_threshold real

    • NOT NULL
    • DEFAULT 0

Table: pg_dist_partition

The pg_dist_partition table has 6 attributes:

  1. pg_dist_partition.logicalrelid regclass

    • NOT NULL
  2. pg_dist_partition.partmethod "char"

    • NOT NULL
  3. pg_dist_partition.partkey text

  4. pg_dist_partition.colocationid integer

    • NOT NULL
    • DEFAULT 0
  5. pg_dist_partition.repmodel "char"

    • NOT NULL
    • DEFAULT 'c'::"char"
  6. pg_dist_partition.autoconverted boolean

    • DEFAULT false

Table: pg_dist_object

The pg_dist_object table has 9 attributes:

  1. pg_dist_object.classid oid

    • NOT NULL
  2. pg_dist_object.objid oid

    • NOT NULL
  3. pg_dist_object.objsubid integer

    • NOT NULL
  4. pg_dist_object.type text

  5. pg_dist_object.object_names text[]

  6. pg_dist_object.object_args text[]

  7. pg_dist_object.distribution_argument_index integer

  8. pg_dist_object.colocationid integer

  9. pg_dist_object.force_delegation boolean

Table: pg_dist_cleanup

The pg_dist_cleanup table has 6 attributes:

  1. pg_dist_cleanup.record_id bigint

    • NOT NULL
    • PRIMARY KEY (record_id)
  2. pg_dist_cleanup.operation_id bigint

    • NOT NULL
  3. pg_dist_cleanup.object_type integer

    • NOT NULL
  4. pg_dist_cleanup.object_name text

    • NOT NULL
  5. pg_dist_cleanup.node_group_id integer

    • NOT NULL
  6. pg_dist_cleanup.policy_type integer

    • NOT NULL

Table: pg_dist_background_job

The pg_dist_background_job table has 6 attributes:

  1. pg_dist_background_job.job_id bigint

    • NOT NULL
    • DEFAULT nextval('pg_dist_background_job_job_id_seq'::regclass)
    • PRIMARY KEY (job_id)
  2. pg_dist_background_job.state citus_job_status

    • NOT NULL
    • DEFAULT 'scheduled'::citus_job_status
  3. pg_dist_background_job.job_type name

    • NOT NULL
  4. pg_dist_background_job.description text

    • NOT NULL
  5. pg_dist_background_job.started_at timestamp with time zone

  6. pg_dist_background_job.finished_at timestamp with time zone

Table: pg_dist_background_task

The pg_dist_background_task table has 9 attributes:

  1. pg_dist_background_task.job_id bigint

    • NOT NULL
    • FOREIGN KEY (job_id) REFERENCES pg_dist_background_job(job_id)
  2. pg_dist_background_task.task_id bigint

    • NOT NULL
    • DEFAULT nextval('pg_dist_background_task_task_id_seq'::regclass)
    • PRIMARY KEY (task_id)
  3. pg_dist_background_task.owner regrole

    • NOT NULL
    • DEFAULT CURRENT_USER::regrole
  4. pg_dist_background_task.pid integer

  5. pg_dist_background_task.status citus_task_status

    • NOT NULL
    • DEFAULT 'runnable'::citus_task_status
  6. pg_dist_background_task.command text

    • NOT NULL
  7. pg_dist_background_task.retry_count integer

  8. pg_dist_background_task.not_before timestamp with time zone

  9. pg_dist_background_task.message text

    • NOT NULL
    • DEFAULT ''::text

Table: pg_dist_background_task_depend

The pg_dist_background_task_depend table has 3 attributes:

  1. pg_dist_background_task_depend.job_id bigint

    • NOT NULL
    • FOREIGN KEY (job_id) REFERENCES pg_dist_background_job(job_id) ON DELETE CASCADE
  2. pg_dist_background_task_depend.task_id bigint

    • NOT NULL
  3. pg_dist_background_task_depend.depends_on bigint

    • NOT NULL

Views

View: pg_dist_shard_placement

 SELECT placement.shardid, placement.shardstate, placement.shardlength,
    node.nodename, node.nodeport, placement.placementid
   FROM pg_dist_placement placement
     JOIN pg_dist_node node ON placement.groupid = node.groupid AND node.noderole = 'primary'::noderole;

View: citus_stat_statements

 SELECT citus_stat_statements.queryid, citus_stat_statements.userid,
    citus_stat_statements.dbid, citus_stat_statements.query,
    citus_executor_name(citus_stat_statements.executor::integer) AS executor,
    citus_stat_statements.partition_key, citus_stat_statements.calls
   FROM citus_stat_statements() citus_stat_statements(queryid, userid, dbid, query, executor, partition_key, calls);

View: citus_shards_on_worker

 SELECT s.schema_name AS "Schema", s.shard_name AS "Name",
    s.table_type AS "Type", s.owner_name AS "Owner"
   FROM citus_shards_on_worker() s(schema_name, shard_name, table_type, owner_name);

View: citus_shard_indexes_on_worker

 SELECT s.schema_name AS "Schema", s.index_name AS "Name",
    s.table_type AS "Type", s.owner_name AS "Owner", s.shard_name AS "Table"
   FROM citus_shard_indexes_on_worker() s(schema_name, index_name, table_type, owner_name, shard_name);

View: time_partitions

 SELECT partitions.partrelid AS parent_table,
    partitions.attname AS partition_column, partitions.relid AS partition,
    partitions.lower_bound AS from_value, partitions.upper_bound AS to_value,
    partitions.amname AS access_method
   FROM ( SELECT p.partrelid::regclass AS partrelid, a.attname,
            c.oid::regclass AS relid, time_partition_range.lower_bound,
            time_partition_range.upper_bound, am.amname
           FROM pg_class c
             JOIN pg_inherits i ON c.oid = i.inhrelid
             JOIN pg_partitioned_table p ON i.inhparent = p.partrelid
             JOIN pg_attribute a ON p.partrelid = a.attrelid
             JOIN pg_type t ON a.atttypid = t.oid
             JOIN pg_namespace tn ON t.typnamespace = tn.oid
             LEFT JOIN pg_am am ON c.relam = am.oid,
            LATERAL time_partition_range(c.oid::regclass) time_partition_range(lower_bound, upper_bound)
          WHERE c.relpartbound IS NOT NULL AND p.partstrat = 'r'::"char" AND p.partnatts = 1 AND (a.attnum = ANY (p.partattrs::smallint[]))) partitions
  ORDER BY (partitions.partrelid::text), partitions.lower_bound;

View: citus_shards

 SELECT pg_dist_shard.logicalrelid AS table_name, pg_dist_shard.shardid,
    shard_name(pg_dist_shard.logicalrelid, pg_dist_shard.shardid) AS shard_name,
        CASE
            WHEN pg_dist_partition.partkey IS NOT NULL THEN 'distributed'::text
            WHEN pg_dist_partition.repmodel = 't'::"char" THEN 'reference'::text
            ELSE 'local'::text
        END AS citus_table_type,
    pg_dist_partition.colocationid AS colocation_id, pg_dist_node.nodename,
    pg_dist_node.nodeport, shard_sizes.size AS shard_size
   FROM pg_dist_shard
     JOIN pg_dist_placement ON pg_dist_shard.shardid = pg_dist_placement.shardid
     JOIN pg_dist_node ON pg_dist_placement.groupid = pg_dist_node.groupid
     JOIN pg_dist_partition ON pg_dist_partition.logicalrelid::oid = pg_dist_shard.logicalrelid::oid
     LEFT JOIN ( SELECT (regexp_matches(citus_shard_sizes.table_name, '_(\d+)$'::text))[1]::integer AS shard_id,
            max(citus_shard_sizes.size) AS size
           FROM citus_shard_sizes() citus_shard_sizes(table_name, size)
          GROUP BY ((regexp_matches(citus_shard_sizes.table_name, '_(\d+)$'::text))[1]::integer)) shard_sizes ON pg_dist_shard.shardid = shard_sizes.shard_id
  WHERE pg_dist_placement.shardstate = 1 AND NOT (pg_dist_partition.logicalrelid::oid IN ( SELECT pg_depend.objid
           FROM pg_depend
          WHERE pg_depend.classid = 'pg_class'::regclass::oid AND pg_depend.refclassid = 'pg_extension'::regclass::oid AND pg_depend.deptype = 'e'::"char"))
  ORDER BY (pg_dist_shard.logicalrelid::text), pg_dist_shard.shardid;

View: citus_tables

 SELECT p.logicalrelid AS table_name,
        CASE
            WHEN p.partkey IS NOT NULL THEN 'distributed'::text
            ELSE
            CASE
                WHEN p.repmodel = 't'::"char" THEN 'reference'::text
                ELSE 'local'::text
            END
        END AS citus_table_type,
    COALESCE(column_to_column_name(p.logicalrelid, p.partkey), '<none>'::text) AS distribution_column,
    p.colocationid AS colocation_id,
    pg_size_pretty(citus_total_relation_size(p.logicalrelid, fail_on_error => false)) AS table_size,
    ( SELECT count(*) AS count
           FROM pg_dist_shard
          WHERE pg_dist_shard.logicalrelid::oid = p.logicalrelid::oid) AS shard_count,
    pg_get_userbyid(c.relowner) AS table_owner, a.amname AS access_method
   FROM pg_dist_partition p
     JOIN pg_class c ON p.logicalrelid::oid = c.oid
     LEFT JOIN pg_am a ON a.oid = c.relam
  WHERE NOT (p.logicalrelid::oid IN ( SELECT pg_depend.objid
           FROM pg_depend
          WHERE pg_depend.classid = 'pg_class'::regclass::oid AND pg_depend.refclassid = 'pg_extension'::regclass::oid AND pg_depend.deptype = 'e'::"char"))
  ORDER BY (p.logicalrelid::text);

View: citus_stat_activity

 SELECT citus_stat_activity.global_pid, citus_stat_activity.nodeid,
    citus_stat_activity.is_worker_query, citus_stat_activity.datid,
    citus_stat_activity.datname, citus_stat_activity.pid,
    citus_stat_activity.leader_pid, citus_stat_activity.usesysid,
    citus_stat_activity.usename, citus_stat_activity.application_name,
    citus_stat_activity.client_addr, citus_stat_activity.client_hostname,
    citus_stat_activity.client_port, citus_stat_activity.backend_start,
    citus_stat_activity.xact_start, citus_stat_activity.query_start,
    citus_stat_activity.state_change, citus_stat_activity.wait_event_type,
    citus_stat_activity.wait_event, citus_stat_activity.state,
    citus_stat_activity.backend_xid, citus_stat_activity.backend_xmin,
    citus_stat_activity.query_id, citus_stat_activity.query,
    citus_stat_activity.backend_type
   FROM citus_stat_activity() citus_stat_activity(global_pid, nodeid, is_worker_query, datid, datname, pid, leader_pid, usesysid, usename, application_name, client_addr, client_hostname, client_port, backend_start, xact_start, query_start, state_change, wait_event_type, wait_event, state, backend_xid, backend_xmin, query_id, query, backend_type);

View: citus_dist_stat_activity

 SELECT citus_stat_activity.global_pid, citus_stat_activity.nodeid,
    citus_stat_activity.is_worker_query, citus_stat_activity.datid,
    citus_stat_activity.datname, citus_stat_activity.pid,
    citus_stat_activity.leader_pid, citus_stat_activity.usesysid,
    citus_stat_activity.usename, citus_stat_activity.application_name,
    citus_stat_activity.client_addr, citus_stat_activity.client_hostname,
    citus_stat_activity.client_port, citus_stat_activity.backend_start,
    citus_stat_activity.xact_start, citus_stat_activity.query_start,
    citus_stat_activity.state_change, citus_stat_activity.wait_event_type,
    citus_stat_activity.wait_event, citus_stat_activity.state,
    citus_stat_activity.backend_xid, citus_stat_activity.backend_xmin,
    citus_stat_activity.query_id, citus_stat_activity.query,
    citus_stat_activity.backend_type
   FROM citus_stat_activity
  WHERE citus_stat_activity.is_worker_query = false;

View: citus_lock_waits

 WITH unique_global_wait_edges_with_calculated_gpids AS (
         SELECT
                CASE
                    WHEN citus_internal_global_blocked_processes.waiting_global_pid <> 0 THEN citus_internal_global_blocked_processes.waiting_global_pid
                    ELSE citus_calculate_gpid(get_nodeid_for_groupid(citus_internal_global_blocked_processes.waiting_node_id), citus_internal_global_blocked_processes.waiting_pid)
                END AS waiting_global_pid,
                CASE
                    WHEN citus_internal_global_blocked_processes.blocking_global_pid <> 0 THEN citus_internal_global_blocked_processes.blocking_global_pid
                    ELSE citus_calculate_gpid(get_nodeid_for_groupid(citus_internal_global_blocked_processes.blocking_node_id), citus_internal_global_blocked_processes.blocking_pid)
                END AS blocking_global_pid,
            get_nodeid_for_groupid(citus_internal_global_blocked_processes.blocking_node_id) AS blocking_node_id,
            get_nodeid_for_groupid(citus_internal_global_blocked_processes.waiting_node_id) AS waiting_node_id,
            citus_internal_global_blocked_processes.blocking_transaction_waiting
           FROM citus_internal_global_blocked_processes() citus_internal_global_blocked_processes(waiting_global_pid, waiting_pid, waiting_node_id, waiting_transaction_num, waiting_transaction_stamp, blocking_global_pid, blocking_pid, blocking_node_id, blocking_transaction_num, blocking_transaction_stamp, blocking_transaction_waiting)
        ), unique_global_wait_edges AS (
         SELECT DISTINCT ON (unique_global_wait_edges_with_calculated_gpids.waiting_global_pid, unique_global_wait_edges_with_calculated_gpids.blocking_global_pid) unique_global_wait_edges_with_calculated_gpids.waiting_global_pid,
            unique_global_wait_edges_with_calculated_gpids.blocking_global_pid,
            unique_global_wait_edges_with_calculated_gpids.blocking_node_id,
            unique_global_wait_edges_with_calculated_gpids.waiting_node_id,
            unique_global_wait_edges_with_calculated_gpids.blocking_transaction_waiting
           FROM unique_global_wait_edges_with_calculated_gpids
        ), citus_dist_stat_activity_with_calculated_gpids AS (
         SELECT
                CASE
                    WHEN citus_dist_stat_activity.global_pid <> 0 THEN citus_dist_stat_activity.global_pid
                    ELSE citus_calculate_gpid(citus_dist_stat_activity.nodeid, citus_dist_stat_activity.pid)
                END AS global_pid,
            citus_dist_stat_activity.nodeid, citus_dist_stat_activity.pid,
            citus_dist_stat_activity.query
           FROM citus_dist_stat_activity
        )
 SELECT waiting.global_pid AS waiting_gpid, blocking.global_pid AS blocking_gpid,
    waiting.query AS blocked_statement,
    blocking.query AS current_statement_in_blocking_process,
    waiting.nodeid AS waiting_nodeid, blocking.nodeid AS blocking_nodeid
   FROM unique_global_wait_edges
     JOIN citus_dist_stat_activity_with_calculated_gpids waiting ON unique_global_wait_edges.waiting_global_pid = waiting.global_pid
     JOIN citus_dist_stat_activity_with_calculated_gpids blocking ON unique_global_wait_edges.blocking_global_pid = blocking.global_pid;

View: citus_locks

 SELECT citus_locks.global_pid, citus_locks.nodeid, citus_locks.locktype,
    citus_locks.database, citus_locks.relation, citus_locks.relation_name,
    citus_locks.page, citus_locks.tuple, citus_locks.virtualxid,
    citus_locks.transactionid, citus_locks.classid, citus_locks.objid,
    citus_locks.objsubid, citus_locks.virtualtransaction, citus_locks.pid,
    citus_locks.mode, citus_locks.granted, citus_locks.fastpath,
    citus_locks.waitstart
   FROM citus_locks() citus_locks(global_pid, nodeid, locktype, database, relation, relation_name, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath, waitstart);

Routines

Function: alter_distributed_table (regclass, text, integer, text, boolean)

alters a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_column text NULL::text
$3 IN shard_count integer NULL::integer
$4 IN colocate_with text NULL::text
$5 IN cascade_to_colocated boolean NULL::boolean

Function return type: void

Function attributes: COST 1

Procedure: alter_old_partitions_set_access_method (regclass, timestamp with time zone, name)

convert old partitions of a time-partitioned table to a new access method

Procedure arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN parent_table_name regclass
$2 IN older_than timestamp with time zone
$3 IN new_access_method name

Function: alter_role_if_exists (text, text)

runs the utility query, if the role exists

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN role_name text
$2 IN utility_query text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: alter_table_set_access_method (regclass, text)

alters a table's access method

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN access_method text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: any_value (anyelement)

Returns the value of any row in the group. It is mostly useful when you know there will be only 1 element.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN anyelement

Function return type: anyelement

Function attributes: IMMUTABLE, COST 1

Function: any_value_agg (anyelement, anyelement)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN anyelement
$2 IN anyelement

Function return type: anyelement

Function attributes: STABLE

Function: array_cat_agg (anycompatiblearray)

concatenate input arrays into a single array

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN anycompatiblearray

Function return type: anycompatiblearray

Function attributes: IMMUTABLE, COST 1

Function: assign_distributed_transaction_id (integer, bigint, timestamp with time zone)

Only intended for internal use, users should not call this. The function sets the distributed transaction id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN initiator_node_identifier integer
$2 IN transaction_number bigint
$3 IN transaction_stamp timestamp with time zone

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: authinfo_valid (text)

returns whether an authinfo is valid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: broadcast_intermediate_result (text, text)

execute a query and write its results to an result file on all workers

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_id text
$2 IN query text

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: check_distributed_deadlocks()

does a distributed deadlock check, if a deadlock found cancels one of the participating backends and returns true

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_activate_node (text, integer)

activate a node which is in the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_inactive_node (text, integer, integer, noderole, name)

prepare node by adding it to pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_local_table_to_metadata (regclass, boolean)

create a citus local table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN cascade_via_foreign_keys boolean false

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_node (text, integer, integer, noderole, name)

add node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_rebalance_strategy (name, regproc, regproc, regproc, real, real, real)

adds a new rebalance strategy which can be used when rebalancing shards or draining nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN name name
$2 IN shard_cost_function regproc
$3 IN node_capacity_function regproc
$4 IN shard_allowed_on_node_function regproc
$5 IN default_threshold real
$6 IN minimum_threshold real 0
$7 IN improvement_threshold real 0

Function return type: void

Function: citus_add_secondary_node (text, integer, text, integer, name)

add a secondary node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN primaryname text
$4 IN primaryport integer
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_backend_gpid()

returns gpid of the current backend

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_blocking_pids (integer)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN pblockedpid integer

Function return type: integer[]

Function: citus_calculate_gpid (integer, integer)

calculate gpid of a backend running on any node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodeid integer
$2 IN pid integer

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_check_cluster_node_health()

checks connections between all nodes in the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT from_nodename text
$2 OUT from_nodeport integer
$3 OUT to_nodename text
$4 OUT to_nodeport integer
$5 OUT result boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_check_connection_to_node (text, integer)

checks connection to another node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer 5432

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Procedure: citus_cleanup_orphaned_resources()

cleanup orphaned resources

Procedure attributes: COST 1

Procedure: citus_cleanup_orphaned_shards()

cleanup orphaned shards

Procedure attributes: COST 1

Function: citus_conninfo_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_coordinator_nodeid()

returns node id of the coordinator node

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_copy_shard_placement (bigint, text, integer, text, integer, citus.shard_transfer_mode)

copy a shard from the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_create_restore_point (text)

temporarily block writes and create a named restore point on all nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: pg_lsn

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_disable_node (text, integer, boolean)

removes node from the cluster temporarily

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN synchronous boolean false

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_dist_local_group_cache_invalidate()

register node cache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_node_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_object_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_partition_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_placement_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_shard_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_drain_node (text, integer, citus.shard_transfer_mode, name)

mark a node to be drained of data and actually drain it as well

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode
$4 IN rebalance_strategy name NULL::name

Function return type: void

Function attributes: COST 1

Function: citus_drop_all_shards (regclass, text, text, boolean)

drop all shards in a relation and update metadata

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN schema_name text
$3 IN table_name text
$4 IN drop_shards_metadata_only boolean false

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_drop_trigger()

perform checks and actions at the end of DROP actions

Function return type: event_trigger

Function-local settings:

  • SET search_path TO pg_catalog

Function: citus_executor_name (integer)

return the name of the external based for the value in citus_stat_statements() output

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN executor_type integer

Function return type: text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_extradata_container (internal)

placeholder function to store additional data in postgres node trees

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal

Function return type: SETOF record

Function attributes: COST 1, ROWS 1000

Function: citus_finalize_upgrade_to_citus11 (boolean)

finalizes upgrade to Citus

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN enforce_version_check boolean true

Function return type: boolean

Procedure: citus_finish_citus_upgrade()

after upgrading Citus on all nodes call this function to upgrade the distributed schema

Procedure-local settings:

  • SET search_path TO pg_catalog

Function: citus_finish_pg_upgrade()

perform tasks to restore citus settings from a location that has been prepared before pg_upgrade

Function return type: void

Function-local settings:

  • SET search_path TO pg_catalog

Function: citus_get_active_worker_nodes()

fetch set of active worker nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT node_name text
$2 OUT node_port bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 100

Function: citus_internal.find_groupid_for_node (text, integer)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text
$2 IN integer

Function return type: integer

Function: citus_internal.pg_dist_node_trigger_func()

Function return type: trigger

Function: citus_internal.pg_dist_rebalance_strategy_trigger_func()

Function return type: trigger

Function: citus_internal.pg_dist_shard_placement_trigger_func()

Function return type: trigger

Function: citus_internal.refresh_isolation_tester_prepared_statement()

Function return type: void

Function: citus_internal.replace_isolation_tester_func()

Function return type: void

Function: citus_internal.restore_isolation_tester_func()

Function return type: void

Function: citus_internal_add_colocation_metadata (integer, integer, integer, regtype, oid)

Inserts a co-location group into pg_dist_colocation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN colocation_id integer
$2 IN shard_count integer
$3 IN replication_factor integer
$4 IN distribution_column_type regtype
$5 IN distribution_column_collation oid

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_add_object_metadata (text, text[], text[], integer, integer, boolean)

Inserts distributed object into pg_dist_object

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN typetext text
$2 IN objnames text[]
$3 IN objargs text[]
$4 IN distribution_argument_index integer
$5 IN colocationid integer
$6 IN force_delegation boolean

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_add_partition_metadata (regclass, "char", text, integer, "char")

Inserts into pg_dist_partition with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation_id regclass
$2 IN distribution_method "char"
$3 IN distribution_column text
$4 IN colocation_id integer
$5 IN replication_model "char"

Function return type: void

Function attributes: COST 1

Function: citus_internal_add_placement_metadata (bigint, integer, bigint, integer, bigint)

Inserts into pg_dist_shard_placement with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN shard_state integer
$3 IN shard_length bigint
$4 IN group_id integer
$5 IN placement_id bigint

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_add_shard_metadata (regclass, bigint, "char", text, text)

Inserts into pg_dist_shard with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation_id regclass
$2 IN shard_id bigint
$3 IN storage_type "char"
$4 IN shard_min_value text
$5 IN shard_max_value text

Function return type: void

Function attributes: COST 1

Function: citus_internal_delete_colocation_metadata (integer)

deletes a co-location group from pg_dist_colocation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN colocation_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_delete_partition_metadata (regclass)

Deletes a row from pg_dist_partition with table ownership checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_delete_shard_metadata (bigint)

Deletes rows from pg_dist_shard and pg_dist_shard_placement with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_global_blocked_processes()

returns a global list of blocked backends originating from this node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_global_pid bigint
$2 OUT waiting_pid integer
$3 OUT waiting_node_id integer
$4 OUT waiting_transaction_num bigint
$5 OUT waiting_transaction_stamp timestamp with time zone
$6 OUT blocking_global_pid bigint
$7 OUT blocking_pid integer
$8 OUT blocking_node_id integer
$9 OUT blocking_transaction_num bigint
$10 OUT blocking_transaction_stamp timestamp with time zone
$11 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_internal_local_blocked_processes()

returns all local lock wait chains, that start from any citus backend

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_global_pid bigint
$2 OUT waiting_pid integer
$3 OUT waiting_node_id integer
$4 OUT waiting_transaction_num bigint
$5 OUT waiting_transaction_stamp timestamp with time zone
$6 OUT blocking_global_pid bigint
$7 OUT blocking_pid integer
$8 OUT blocking_node_id integer
$9 OUT blocking_transaction_num bigint
$10 OUT blocking_transaction_stamp timestamp with time zone
$11 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_internal_update_placement_metadata (bigint, integer, integer)

Updates into pg_dist_placement with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_group_id integer
$3 IN target_group_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_update_relation_colocation (oid, integer)

Updates colocationId field of pg_dist_partition for the relation_id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation_id oid
$2 IN target_colocation_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_is_coordinator()

returns whether the current node is a coordinator

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_isolation_test_session_is_blocked (integer, integer[])

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN pblockedpid integer
$2 IN pinterestingpids integer[]

Function return type: boolean

Function: citus_job_cancel (bigint)

cancel a scheduled or running job and all of its tasks that didn't finish yet

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN jobid bigint

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_job_wait (bigint, citus_job_status)

blocks till the job identified by jobid is at the specified status, or reached a terminal status. Only waits for terminal status when no desired_status was specified. The return value indicates if the desired status was reached or not. When no desired status was specified it will assume any terminal status was desired

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN jobid bigint
$2 IN desired_status citus_job_status NULL::citus_job_status

Function return type: void

Function attributes: COST 1

Function: citus_json_concatenate (json, json)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state json
$2 IN val json

Function return type: json

Function: citus_json_concatenate_final (json)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state json

Function return type: json

Function: citus_jsonb_concatenate (jsonb, jsonb)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state jsonb
$2 IN val jsonb

Function return type: jsonb

Function: citus_jsonb_concatenate_final (jsonb)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state jsonb

Function return type: jsonb

Function: citus_local_disk_space_stats()

returns statistics on available disk space on the local node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT available_disk_size bigint
$2 OUT total_disk_size bigint

Function return type: record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_locks()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT global_pid bigint
$2 OUT nodeid integer
$3 OUT locktype text
$4 OUT database oid
$5 OUT relation oid
$6 OUT relation_name text
$7 OUT page integer
$8 OUT tuple smallint
$9 OUT virtualxid text
$10 OUT transactionid xid
$11 OUT classid oid
$12 OUT objid oid
$13 OUT objsubid smallint
$14 OUT virtualtransaction text
$15 OUT pid integer
$16 OUT mode text
$17 OUT granted boolean
$18 OUT fastpath boolean
$19 OUT waitstart timestamp with time zone

Function return type: SETOF record

Function attributes: ROWS 1000

Function: citus_move_shard_placement (bigint, text, integer, text, integer, citus.shard_transfer_mode)

move a shard from a the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_node_capacity_1 (integer)

a node capacity function for use by the rebalance algorithm that always returns 1

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN integer

Function return type: real

Function: citus_nodeid_for_gpid (bigint)

returns node id for the global process with given global pid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_nodename_for_nodeid (integer)

returns node name for the node with given node id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodeid integer

Function return type: text

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_nodeport_for_nodeid (integer)

returns node port for the node with given node id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodeid integer

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_pid_for_gpid (bigint)

returns process id for the global process with given global pid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_prepare_pg_upgrade()

perform tasks to copy citus settings to a location that could later be restored after pg_upgrade is done

Function return type: void

Function-local settings:

  • SET search_path TO pg_catalog

Function: citus_query_stats()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT queryid bigint
$2 OUT userid oid
$3 OUT dbid oid
$4 OUT executor bigint
$5 OUT partition_key text
$6 OUT calls bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_rebalance_start (name, boolean, citus.shard_transfer_mode)

rebalance the shards in the cluster in the background

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN rebalance_strategy name NULL::name
$2 IN drain_only boolean false
$3 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: bigint

Function attributes: COST 1

Function: citus_rebalance_stop()

stop a rebalance that is running in the background

Function return type: void

Function attributes: COST 1

Function: citus_rebalance_wait()

wait on a running rebalance in the background

Function return type: void

Function attributes: COST 1

Function: citus_relation_size (regclass)

get disk space used by the 'main' fork

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_remote_connection_stats()

returns statistics about remote connections

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT hostname text
$2 OUT port integer
$3 OUT database_name text
$4 OUT connection_count_to_node integer

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_remove_node (text, integer)

remove node from the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_run_local_command (text)

citus_run_local_command executes the input command

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text

Function return type: void

Function: citus_server_id()

generates a random UUID to be used as server identifier

Function return type: uuid

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_set_coordinator_host (text, integer, noderole, name)

set the host and port of the coordinator

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN host text
$2 IN port integer (current_setting('port'::text))::integer
$3 IN node_role noderole 'primary'::noderole
$4 IN node_cluster name 'default'::name

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_set_default_rebalance_strategy (text)

changes the default rebalance strategy to the one with the specified name

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT

Function: citus_set_node_property (text, integer, text, boolean)

set a property of a node in pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN property text
$4 IN value boolean

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_shard_allowed_on_node_true (bigint, integer)

a shard_allowed_on_node_function for use by the rebalance algorithm that always returns true

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint
$2 IN integer

Function return type: boolean

Function: citus_shard_cost_1 (bigint)

a shard cost function for use by the rebalance algorithm that always returns 1

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint

Function return type: real

Function: citus_shard_cost_by_disk_size (bigint)

a shard cost function for use by the rebalance algorithm that returns the disk size in bytes for the specified shard and the shards that are colocated with it

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint

Function return type: real

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_shard_indexes_on_worker()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT schema_name name
$2 OUT index_name name
$3 OUT table_type text
$4 OUT owner_name name
$5 OUT shard_name name

Function return type: SETOF record

Function attributes: ROWS 1000

Function-local settings:

  • SET citus.show_shards_for_app_name_prefixes TO *

Function: citus_shard_sizes()

returns shards sizes across citus cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT table_name text
$2 OUT size bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_shards_on_worker()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT schema_name name
$2 OUT shard_name name
$3 OUT table_type text
$4 OUT owner_name name

Function return type: SETOF record

Function attributes: ROWS 1000

Function-local settings:

  • SET citus.show_shards_for_app_name_prefixes TO *

Function: citus_split_shard_by_split_points (bigint, text[], integer[], citus.shard_transfer_mode)

split a shard using split mode.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN split_points text[]
$3 IN node_ids integer[]
$4 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_stat_activity()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT global_pid bigint
$2 OUT nodeid integer
$3 OUT is_worker_query boolean
$4 OUT datid oid
$5 OUT datname name
$6 OUT pid integer
$7 OUT leader_pid integer
$8 OUT usesysid oid
$9 OUT usename name
$10 OUT application_name text
$11 OUT client_addr inet
$12 OUT client_hostname text
$13 OUT client_port integer
$14 OUT backend_start timestamp with time zone
$15 OUT xact_start timestamp with time zone
$16 OUT query_start timestamp with time zone
$17 OUT state_change timestamp with time zone
$18 OUT wait_event_type text
$19 OUT wait_event text
$20 OUT state text
$21 OUT backend_xid xid
$22 OUT backend_xmin xid
$23 OUT query_id bigint
$24 OUT query text
$25 OUT backend_type text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: citus_stat_statements()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT queryid bigint
$2 OUT userid oid
$3 OUT dbid oid
$4 OUT query text
$5 OUT executor bigint
$6 OUT partition_key text
$7 OUT calls bigint

Function return type: SETOF record

Function attributes: ROWS 1000

Function: citus_stat_statements_reset()

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_table_is_visible (oid)

wrapper on pg_table_is_visible, filtering out tables (and indexes) that are known to be shards

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN oid

Function return type: boolean

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1

Function: citus_table_size (regclass)

get disk space used by the specified table, excluding indexes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_text_send_as_jsonb (text)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: bytea

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1

Function: citus_total_relation_size (regclass, boolean)

get total disk space used by the specified table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN fail_on_error boolean true

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_truncate_trigger()

trigger function called when truncating the distributed table

Function return type: trigger

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_unmark_object_distributed (oid, oid, integer)

remove an object address from citus.pg_dist_object once the object has been deleted

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN classid oid
$2 IN objid oid
$3 IN objsubid integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_update_node (integer, text, integer, boolean, integer)

change the location of a node. when force => true it will wait lock_cooldown ms before killing competing locks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN node_id integer
$2 IN new_node_name text
$3 IN new_node_port integer
$4 IN force boolean false
$5 IN lock_cooldown integer 10000

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_update_shard_statistics (bigint)

updates shard statistics and returns the updated shard size

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_update_table_statistics (regclass)

updates shard statistics of the given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_validate_rebalance_strategy_functions (regproc, regproc, regproc)

internal function used by citus to validate signatures of functions used in rebalance strategy

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_cost_function regproc
$2 IN node_capacity_function regproc
$3 IN shard_allowed_on_node_function regproc

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_version()

Citus version string

Function return type: text

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: column_name_to_column (regclass, text)

convert a column name to its textual Var representation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN column_name text

Function return type: text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: column_to_column_name (regclass, text)

convert the textual Var representation to a column name

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN column_var_text text

Function return type: text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: coord_combine_agg (oid, cstring, anyelement)

support aggregate for implementing combining partial aggregate results from workers

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN oid
$2 IN cstring
$3 IN anyelement

Function return type: anyelement

Function attributes: IMMUTABLE, COST 1

Function: coord_combine_agg_ffunc (internal, oid, cstring, anyelement)

finalizer for coord_combine_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal
$2 IN oid
$3 IN cstring
$4 IN anyelement

Function return type: anyelement

Function attributes: PARALLEL SAFE, COST 1

Function: coord_combine_agg_sfunc (internal, oid, cstring, anyelement)

transition function for coord_combine_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal
$2 IN oid
$3 IN cstring
$4 IN anyelement

Function return type: internal

Function attributes: PARALLEL SAFE, COST 1

Function: create_distributed_function (regprocedure, text, text, boolean)

creates a distributed function

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN function_name regprocedure
$2 IN distribution_arg_name text NULL::text
$3 IN colocate_with text 'default'::text
$4 IN force_delegation boolean NULL::boolean

Function return type: void

Function attributes: COST 1

Function: create_distributed_table (regclass, text, citus.distribution_type, text, integer)

creates a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_column text
$3 IN distribution_type citus.distribution_type 'hash'::citus.distribution_type
$4 IN colocate_with text 'default'::text
$5 IN shard_count integer NULL::integer

Function return type: void

Function attributes: COST 1

Function: create_distributed_table_concurrently (regclass, text, citus.distribution_type, text, integer)

creates a distributed table and avoids blocking writes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_column text
$3 IN distribution_type citus.distribution_type 'hash'::citus.distribution_type
$4 IN colocate_with text 'default'::text
$5 IN shard_count integer NULL::integer

Function return type: void

Function attributes: COST 1

Function: create_intermediate_result (text, text)

execute a query and write its results to local result file

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_id text
$2 IN query text

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: create_reference_table (regclass)

create a distributed reference table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: create_time_partitions (regclass, interval, timestamp with time zone, timestamp with time zone)

create time partitions for the given range

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN partition_interval interval
$3 IN end_at timestamp with time zone
$4 IN start_from timestamp with time zone now()

Function return type: boolean

Function: distributed_tables_colocated (regclass, regclass)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table1 regclass
$2 IN table2 regclass

Function return type: boolean

Procedure: drop_old_time_partitions (regclass, timestamp with time zone)

drop old partitions of a time-partitioned table

Procedure arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN older_than timestamp with time zone

Function: dump_global_wait_edges()

returns a global list of blocked transactions originating from this node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_pid integer
$2 OUT waiting_node_id integer
$3 OUT waiting_transaction_num bigint
$4 OUT waiting_transaction_stamp timestamp with time zone
$5 OUT blocking_pid integer
$6 OUT blocking_node_id integer
$7 OUT blocking_transaction_num bigint
$8 OUT blocking_transaction_stamp timestamp with time zone
$9 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: dump_local_wait_edges()

returns all local lock wait chains, that start from distributed transactions

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_pid integer
$2 OUT waiting_node_id integer
$3 OUT waiting_transaction_num bigint
$4 OUT waiting_transaction_stamp timestamp with time zone
$5 OUT blocking_pid integer
$6 OUT blocking_node_id integer
$7 OUT blocking_transaction_num bigint
$8 OUT blocking_transaction_stamp timestamp with time zone
$9 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: fetch_intermediate_results (text[], text, integer)

fetch array of intermediate results from a remote node. returns number of bytes read.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_ids text[]
$2 IN node_name text
$3 IN node_port integer

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: fix_all_partition_shard_index_names()

fix index names on partition shards of all tables

Function return type: SETOF regclass

Function attributes: ROWS 1000

Function: fix_partition_shard_index_names (regclass)

fix index names on partition shards of given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: fix_pre_citus10_partitioned_table_constraint_names()

fix constraint names on all partition shards

Function return type: SETOF regclass

Function attributes: ROWS 1000

Function: fix_pre_citus10_partitioned_table_constraint_names (regclass)

fix constraint names on partition shards

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_all_active_transactions()

returns transaction information for all Citus initiated transactions

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT datid oid
$2 OUT process_id integer
$3 OUT initiator_node_identifier integer
$4 OUT worker_query boolean
$5 OUT transaction_number bigint
$6 OUT transaction_stamp timestamp with time zone
$7 OUT global_pid bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: get_colocated_shard_array (bigint)

returns the array of colocated shards of the given shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint

Function return type: bigint[]

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_colocated_table_array (regclass)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN regclass

Function return type: regclass[]

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_current_transaction_id()

returns the current backend data including distributed transaction id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT database_id oid
$2 OUT process_id integer
$3 OUT initiator_node_identifier integer
$4 OUT transaction_number bigint
$5 OUT transaction_stamp timestamp with time zone

Function return type: record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_global_active_transactions()

returns transaction information for all Citus initiated transactions from each node of the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT datid oid
$2 OUT process_id integer
$3 OUT initiator_node_identifier integer
$4 OUT worker_query boolean
$5 OUT transaction_number bigint
$6 OUT transaction_stamp timestamp with time zone
$7 OUT global_pid bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: get_missing_time_partition_ranges (regclass, interval, timestamp with time zone, timestamp with time zone)

get missing partitions ranges for table within the range using the given interval

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN partition_interval interval
$3 IN to_value timestamp with time zone
$4 IN from_value timestamp with time zone now()
$5 TABLE partition_name text
$6 TABLE range_from_value text
$7 TABLE range_to_value text

Function return type: TABLE(partition_name text, range_from_value text, range_to_value text)

Function attributes: ROWS 1000

Function: get_nodeid_for_groupid (integer)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN groupidinput integer

Function return type: integer

Function: get_rebalance_progress()

provides progress information about the ongoing rebalance operations

Function return type: TABLE(sessionid integer, table_name regclass, shardid bigint, shard_size bigint, sourcename text, sourceport integer, targetname text, targetport integer, progress bigint, source_shard_size bigint, target_shard_size bigint, operation_type text)

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: get_rebalance_table_shards_plan (regclass, real, integer, bigint[], boolean, name, real)

returns the list of shard placement moves to be done on a rebalance operation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass NULL::regclass
$2 IN threshold real NULL::real
$3 IN max_shard_moves integer 1000000
$4 IN excluded_shard_list bigint[] '{}'::bigint[]
$5 IN drain_only boolean false
$6 IN rebalance_strategy name NULL::name
$7 IN improvement_threshold real NULL::real
$8 TABLE table_name regclass
$9 TABLE shardid bigint
$10 TABLE shard_size bigint
$11 TABLE sourcename text
$12 TABLE sourceport integer
$13 TABLE targetname text
$14 TABLE targetport integer

Function return type: TABLE(table_name regclass, shardid bigint, shard_size bigint, sourcename text, sourceport integer, targetname text, targetport integer)

Function attributes: COST 1, ROWS 1000

Function: get_shard_id_for_distribution_column (regclass, "any")

return shard id which belongs to given table and contains given value

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_value "any" NULL::unknown

Function return type: bigint

Function attributes: COST 1

Function: isolate_tenant_to_new_shard (regclass, "any", text, citus.shard_transfer_mode)

isolate a tenant to its own shard and return the new shard id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN tenant_id "any"
$3 IN cascade_option text ''::text
$4 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: json_cat_agg (json)

concatenate input jsons into a single json

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN json

Function return type: json

Function attributes: IMMUTABLE, COST 1

Function: jsonb_cat_agg (jsonb)

concatenate input jsonbs into a single jsonb

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN jsonb

Function return type: jsonb

Function attributes: IMMUTABLE, COST 1

Function: lock_relation_if_exists (text, text)

used internally to locks relation in the lock_mode if the relation exists without throwing errors; consider using LOCK * IN * MODE instead

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text
$2 IN lock_mode text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: lock_shard_metadata (integer, bigint[])

lock shard metadata to prevent writes during metadata changes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN lock_mode integer
$2 IN shard_id bigint[]

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: lock_shard_resources (integer, bigint[])

lock shard resource to serialise non-commutative writes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN lock_mode integer
$2 IN shard_id bigint[]

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_activate_node (text, integer)

activate a node which is in the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_add_inactive_node (text, integer, integer, noderole, name)

prepare node by adding it to pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_add_node (text, integer, integer, noderole, name)

add node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_add_secondary_node (text, integer, text, integer, name)

add a secondary node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN primaryname text
$4 IN primaryport integer
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_copy_shard_placement (bigint, text, integer, text, integer, boolean, citus.shard_transfer_mode)

copy a shard from the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN do_repair boolean true
$7 IN transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_create_empty_shard (text)

create an empty shard and shard placements for the table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_disable_node (text, integer)

removes node from the cluster temporarily

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_drain_node (text, integer, citus.shard_transfer_mode, name)

mark a node to be drained of data and actually drain it as well

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode
$4 IN rebalance_strategy name NULL::name

Function return type: void

Function attributes: COST 1

Function: master_get_active_worker_nodes()

fetch set of active worker nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT node_name text
$2 OUT node_port bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 100

Function: master_get_new_placementid()

fetch unique placementid

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_get_new_shardid()

fetch unique shardId

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_get_table_ddl_events (text)

fetch set of ddl statements for the table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: SETOF text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 100

Function: master_move_shard_placement (bigint, text, integer, text, integer, citus.shard_transfer_mode)

move a shard from a the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_remove_distributed_table_metadata_from_workers (regclass, text, text)

drops the table and removes all the metadata belonging the distributed table in the worker nodes with metadata.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN schema_name text
$3 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_remove_node (text, integer)

remove node from the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_remove_partition_metadata (regclass, text, text)

deletes the partition metadata of a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN schema_name text
$3 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_run_on_worker (text[], integer[], text[], boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN worker_name text[]
$2 IN port integer[]
$3 IN command text[]
$4 IN parallel boolean
$5 OUT node_name text
$6 OUT node_port integer
$7 OUT success boolean
$8 OUT result text

Function return type: SETOF record

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: master_set_node_property (text, integer, text, boolean)

set a property of a node in pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN property text
$4 IN value boolean

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_unmark_object_distributed (oid, oid, integer)

remove an object address from citus.pg_dist_object once the object has been deleted

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN classid oid
$2 IN objid oid
$3 IN objsubid integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_update_node (integer, text, integer, boolean, integer)

change the location of a node. when force => true it will wait lock_cooldown ms before killing competing locks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN node_id integer
$2 IN new_node_name text
$3 IN new_node_port integer
$4 IN force boolean false
$5 IN lock_cooldown integer 10000

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_update_shard_statistics (bigint)

updates shard statistics and returns the updated shard size

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_update_table_statistics (regclass)

updates shard statistics of the given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: notify_constraint_dropped()

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: pg_cancel_backend (bigint)

cancels a Citus query which might be on any node in the Citus cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint

Function return type: boolean

Function attributes: COST 1

Function: pg_terminate_backend (bigint, bigint)

terminates a Citus query which might be on any node in the Citus cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint
$2 IN timeout bigint 0

Function return type: boolean

Function attributes: COST 1

Function: poolinfo_valid (text)

returns whether a poolinfo is valid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: read_intermediate_result (text, citus_copy_format)

read a file and return it as a set of records

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_id text
$2 IN format citus_copy_format 'csv'::citus_copy_format

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1, ROWS 1000

Function: read_intermediate_results (text[], citus_copy_format)

read a set files and return them as a set of records

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_ids text[]
$2 IN format citus_copy_format 'csv'::citus_copy_format

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1, ROWS 1000

Function: rebalance_table_shards (regclass, real, integer, bigint[], citus.shard_transfer_mode, boolean, name)

rebalance the shards of the given table across the worker nodes (including colocated shards of other tables)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass NULL::regclass
$2 IN threshold real NULL::real
$3 IN max_shard_moves integer 1000000
$4 IN excluded_shard_list bigint[] '{}'::bigint[]
$5 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode
$6 IN drain_only boolean false
$7 IN rebalance_strategy name NULL::name

Function return type: void

Function attributes: COST 1

Function: recover_prepared_transactions()

recover prepared transactions started by this node

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: relation_is_a_known_shard (regclass)

returns true if the given relation is a known shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN regclass

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: remove_local_tables_from_metadata()

undistribute citus local tables that are not chained with any reference tables via foreign keys

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: replicate_reference_tables (citus.shard_transfer_mode)

replicate reference tables to all nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: replicate_table_shards (regclass, integer, integer, bigint[], citus.shard_transfer_mode)

replicates under replicated shards of the the given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass
$2 IN shard_replication_factor integer (current_setting('citus.shard_replication_factor'::text))::integer
$3 IN max_shard_copies integer 1000000
$4 IN excluded_shard_list bigint[] '{}'::bigint[]
$5 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: role_exists (name)

returns whether a role exists

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN name

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: run_command_on_all_nodes (text, boolean, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text
$2 IN parallel boolean true
$3 IN give_warning_for_connection_errors boolean false
$4 OUT nodeid integer
$5 OUT success boolean
$6 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_colocated_placements (regclass, regclass, text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name1 regclass
$2 IN table_name2 regclass
$3 IN command text
$4 IN parallel boolean true
$5 OUT nodename text
$6 OUT nodeport integer
$7 OUT shardid1 bigint
$8 OUT shardid2 bigint
$9 OUT success boolean
$10 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_coordinator (text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text
$2 IN give_warning_for_connection_errors boolean false
$3 OUT nodeid integer
$4 OUT success boolean
$5 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_placements (regclass, text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN command text
$3 IN parallel boolean true
$4 OUT nodename text
$5 OUT nodeport integer
$6 OUT shardid bigint
$7 OUT success boolean
$8 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_shards (regclass, text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN command text
$3 IN parallel boolean true
$4 OUT shardid bigint
$5 OUT success boolean
$6 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_workers (text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text
$2 IN parallel boolean true
$3 OUT nodename text
$4 OUT nodeport integer
$5 OUT success boolean
$6 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: shard_name (regclass, bigint)

returns schema-qualified, shard-extended identifier of object name

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN object_name regclass
$2 IN shard_id bigint

Function return type: text

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: start_metadata_sync_to_all_nodes()

sync metadata to all active primary nodes

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: start_metadata_sync_to_node (text, integer)

sync metadata to node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: stop_metadata_sync_to_node (text, integer, boolean)

stop metadata sync to node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN clear_metadata boolean true

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: time_partition_range (regclass)

returns the start and end of partition boundaries

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 OUT lower_bound text
$3 OUT upper_bound text

Function return type: record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: truncate_local_data_after_distributing_table (regclass)

truncates local records of a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN function_name regclass

Function return type: void

Function attributes: COST 1

Function: undistribute_table (regclass, boolean)

undistributes a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN cascade_via_foreign_keys boolean false

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: update_distributed_table_colocation (regclass, text)

updates colocation of a table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN colocate_with text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_append_table_to_shard (text, text, text, integer)

append a regular table's contents to the shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text
$2 IN text
$3 IN text
$4 IN integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_inter_shard_ddl_command (bigint, text, bigint, text, text)

executes inter shard ddl command

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN referencing_shard bigint
$2 IN referencing_schema_name text
$3 IN referenced_shard bigint
$4 IN referenced_schema_name text
$5 IN command text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_sequence_command (text)

create a sequence which products globally unique values

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_sequence_command (text, regtype)

create a sequence which produces globally unique values

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN create_sequence_command text
$2 IN sequence_type_id regtype 'bigint'::regtype

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_shard_ddl_command (bigint, text)

extend ddl command with shardId and apply on database

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint
$2 IN text

Function return type: void

Function: worker_apply_shard_ddl_command (bigint, text, text)

extend ddl command with shardId and apply on database

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint
$2 IN text
$3 IN text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_change_sequence_dependency (regclass, regclass, regclass)

changes sequence's dependency from source table to target table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN sequence regclass
$2 IN source_table regclass
$3 IN target_table regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_copy_table_to_node (regclass, integer)

Perform copy of a shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN source_table regclass
$2 IN target_node_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_create_or_alter_role (text, text, text)

runs the create role query, if the role doesn't exists, runs the alter role query if it does

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN role_name text
$2 IN create_role_utility_query text
$3 IN alter_role_utility_query text

Function return type: boolean

Function attributes: COST 1

Function: worker_create_or_replace_object (text)

takes a sql CREATE statement, before executing the create it will check if an object with that name already exists and safely replaces that named object with the new object

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN statement text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_create_or_replace_object (text[])

takes an array of sql statements, before executing these it will check if the object already exists in that exact state otherwise replaces that named object with the new object

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN statements text[]

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_create_truncate_trigger (regclass)

create truncate trigger for distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_drop_distributed_table (text)

drop the distributed table and its reference from metadata tables

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_drop_sequence_dependency (text)

drop the Citus tables sequence dependency

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_drop_shell_table (text)

drop the distributed table only without the metadata

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_fix_partition_shard_index_names (regclass, text, text)

fix the name of the index on given partition shard that is child of given parent_index

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN parent_shard_index regclass
$2 IN partition_shard text
$3 IN new_partition_shard_index_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_fix_pre_citus10_partitioned_table_constraint_names (regclass, bigint, text)

fix constraint names on partition shards on worker nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN shardid bigint
$3 IN constraint_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_hash ("any")

calculate hashed value and return it

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN value "any"

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_last_saved_explain_analyze()

Returns the saved explain analyze output for the last run query

Function return type: TABLE(explain_analyze_output text, execution_duration double precision)

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: worker_nextval (regclass)

calculates nextval() for column defaults of type int or smallint

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN sequence regclass

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_partial_agg (oid, anyelement)

support aggregate for implementing partial aggregation on workers

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN oid
$2 IN anyelement

Function return type: cstring

Function attributes: IMMUTABLE, COST 1

Function: worker_partial_agg_ffunc (internal)

finalizer for worker_partial_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal

Function return type: cstring

Function attributes: PARALLEL SAFE, COST 1

Function: worker_partial_agg_sfunc (internal, oid, anyelement)

transition function for worker_partial_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal
$2 IN oid
$3 IN anyelement

Function return type: internal

Function attributes: PARALLEL SAFE, COST 1

Function: worker_partition_query_result (text, text, integer, citus.distribution_type, text[], text[], boolean, boolean, boolean)

execute a query and partitions its results in set of local result files

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_prefix text
$2 IN query text
$3 IN partition_column_index integer
$4 IN partition_method citus.distribution_type
$5 IN partition_min_values text[]
$6 IN partition_max_values text[]
$7 IN binary_copy boolean
$8 IN allow_null_partition_column boolean false
$9 IN generate_empty_results boolean false
$10 OUT partition_index integer
$11 OUT rows_written bigint
$12 OUT bytes_written bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: worker_partitioned_relation_size (regclass)

Calculates and returns the size of a partitioned relation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: bigint

Function: worker_partitioned_relation_total_size (regclass)

Calculates and returns the total size of a partitioned relation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: bigint

Function: worker_partitioned_table_size (regclass)

Calculates and returns the size of a partitioned table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: bigint

Function: worker_record_sequence_dependency (regclass, regclass, name)

record the fact that the sequence depends on the table in pg_depend

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN seq_name regclass
$2 IN table_name regclass
$3 IN column_name name

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_save_query_explain_analyze (text, jsonb)

Executes and returns results of query while saving its EXPLAIN ANALYZE to be fetched later

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN query text
$2 IN options jsonb

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: worker_split_copy (bigint, text, split_copy_info[])

Perform split copy for shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN source_shard_id bigint
$2 IN distribution_column text
$3 IN splitcopyinfos split_copy_info[]

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_split_shard_release_dsm()

Releases shared memory segment allocated by non-blocking split workflow

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_split_shard_replication_setup (split_shard_info[])

Replication setup for splitting a shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN splitshardinfo split_shard_info[]

Function return type: SETOF replication_slot_info

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Types

The following extra types have been defined besides the implicit composite types of the tables and views in this extension.

####Type: distribution_type

####Type: noderole

####Type: shard_transfer_mode

####Type: citus_copy_format

Composite type: split_copy_info

CREATE TYPE split_copy_info AS (
  destination_shard_id bigint,
  destination_shard_min_value text,
  destination_shard_max_value text,
  destination_shard_node_id integer
);

Composite type: split_shard_info

Stores split child shard information

CREATE TYPE split_shard_info AS (
  source_shard_id bigint,
  distribution_column text,
  child_shard_id bigint,
  shard_min_value text,
  shard_max_value text,
  node_id integer
);

Composite type: replication_slot_info

Replication slot information to be used for subscriptions during non blocking shard split

CREATE TYPE replication_slot_info AS (
  node_id integer,
  slot_owner text,
  slot_name text
);

####Type: citus_job_status

####Type: citus_task_status

t

pg_extension_name: citus pg_extension_version: 11.2-1 pg_readme_generated_at: 2023-01-30 17:15:41.943399+03 pg_readme_version: 0.5.5

Citus distributed database

Object reference

Schema: pg_catalog

citus must be installed in the pg_catalog schema. Hence, it is not relocatable.


system catalog schema

Tables

There are 17 tables that directly belong to the citus extension.

Table: tbl

The tbl table has 1 attributes:

  1. tbl.a my_schema.my_type

Table: pg_dist_shard

The pg_dist_shard table has 6 attributes:

  1. pg_dist_shard.logicalrelid regclass

    • NOT NULL
  2. pg_dist_shard.shardid bigint

    • NOT NULL
  3. pg_dist_shard.shardstorage "char"

    • NOT NULL
  4. pg_dist_shard.........pg.dropped.4........ -

  5. pg_dist_shard.shardminvalue text

  6. pg_dist_shard.shardmaxvalue text

Table: pg_dist_transaction

The pg_dist_transaction table has 2 attributes:

  1. pg_dist_transaction.groupid integer

    • NOT NULL
  2. pg_dist_transaction.gid text

    • NOT NULL

Table: pg_dist_local_group

The pg_dist_local_group table has 1 attributes:

  1. pg_dist_local_group.groupid integer

    • NOT NULL
    • PRIMARY KEY (groupid)

Table: pg_dist_placement

The pg_dist_placement table has 5 attributes:

  1. pg_dist_placement.placementid bigint

    • NOT NULL
    • DEFAULT nextval('pg_dist_placement_placementid_seq'::regclass)
  2. pg_dist_placement.shardid bigint

    • NOT NULL
  3. pg_dist_placement.shardstate integer

    • NOT NULL
  4. pg_dist_placement.shardlength bigint

    • NOT NULL
  5. pg_dist_placement.groupid integer

    • NOT NULL

Table: pg_dist_node_metadata

The pg_dist_node_metadata table has 1 attributes:

  1. pg_dist_node_metadata.metadata jsonb

    • NOT NULL

Table: pg_dist_authinfo

The pg_dist_authinfo table has 3 attributes:

  1. pg_dist_authinfo.nodeid integer

    • NOT NULL
  2. pg_dist_authinfo.rolename name

    • NOT NULL
    • CHECK (role_exists(rolename))
  3. pg_dist_authinfo.authinfo text

    • NOT NULL
    • CHECK (authinfo_valid(authinfo))

Table: pg_dist_poolinfo

The pg_dist_poolinfo table has 2 attributes:

  1. pg_dist_poolinfo.nodeid integer

    • NOT NULL
    • PRIMARY KEY (nodeid)
  2. pg_dist_poolinfo.poolinfo text

    • NOT NULL
    • CHECK (poolinfo_valid(poolinfo))

Table: pg_dist_node

The pg_dist_node table has 11 attributes:

  1. pg_dist_node.nodeid integer

    • NOT NULL
    • DEFAULT nextval('pg_dist_node_nodeid_seq'::regclass)
    • PRIMARY KEY (nodeid)
  2. pg_dist_node.groupid integer

    • NOT NULL
    • DEFAULT nextval('pg_dist_groupid_seq'::regclass)
  3. pg_dist_node.nodename text

    • NOT NULL
  4. pg_dist_node.nodeport integer

    • NOT NULL
    • DEFAULT 5432
  5. pg_dist_node.noderack text

    • NOT NULL
    • DEFAULT 'default'::text
  6. pg_dist_node.hasmetadata boolean

    • NOT NULL
    • DEFAULT false
  7. pg_dist_node.isactive boolean

    • NOT NULL
    • DEFAULT true
  8. pg_dist_node.noderole noderole

    • NOT NULL
    • DEFAULT 'primary'::noderole
  9. pg_dist_node.nodecluster name

    • NOT NULL
    • DEFAULT 'default'::name
  10. pg_dist_node.metadatasynced boolean

indicates whether the node has the most recent metadata

  • DEFAULT false
  1. pg_dist_node.shouldhaveshards boolean

indicates whether the node is eligible to contain data from distributed tables

  • NOT NULL
  • DEFAULT true

Table: pg_dist_colocation

The pg_dist_colocation table has 5 attributes:

  1. pg_dist_colocation.colocationid integer

    • NOT NULL
    • PRIMARY KEY (colocationid)
  2. pg_dist_colocation.shardcount integer

    • NOT NULL
  3. pg_dist_colocation.replicationfactor integer

    • NOT NULL
  4. pg_dist_colocation.distributioncolumntype oid

    • NOT NULL
  5. pg_dist_colocation.distributioncolumncollation oid

    • NOT NULL

Table: pg_dist_rebalance_strategy

The pg_dist_rebalance_strategy table has 8 attributes:

  1. pg_dist_rebalance_strategy.name name

    • NOT NULL
    • UNIQUE (name)
  2. pg_dist_rebalance_strategy.default_strategy boolean

    • NOT NULL
    • DEFAULT false
  3. pg_dist_rebalance_strategy.shard_cost_function regproc

    • NOT NULL
  4. pg_dist_rebalance_strategy.node_capacity_function regproc

    • NOT NULL
  5. pg_dist_rebalance_strategy.shard_allowed_on_node_function regproc

    • NOT NULL
  6. pg_dist_rebalance_strategy.default_threshold real

    • NOT NULL
  7. pg_dist_rebalance_strategy.minimum_threshold real

    • NOT NULL
    • DEFAULT 0
  8. pg_dist_rebalance_strategy.improvement_threshold real

    • NOT NULL
    • DEFAULT 0

Table: pg_dist_partition

The pg_dist_partition table has 6 attributes:

  1. pg_dist_partition.logicalrelid regclass

    • NOT NULL
  2. pg_dist_partition.partmethod "char"

    • NOT NULL
  3. pg_dist_partition.partkey text

  4. pg_dist_partition.colocationid integer

    • NOT NULL
    • DEFAULT 0
  5. pg_dist_partition.repmodel "char"

    • NOT NULL
    • DEFAULT 'c'::"char"
  6. pg_dist_partition.autoconverted boolean

    • DEFAULT false

Table: pg_dist_object

The pg_dist_object table has 9 attributes:

  1. pg_dist_object.classid oid

    • NOT NULL
  2. pg_dist_object.objid oid

    • NOT NULL
  3. pg_dist_object.objsubid integer

    • NOT NULL
  4. pg_dist_object.type text

  5. pg_dist_object.object_names text[]

  6. pg_dist_object.object_args text[]

  7. pg_dist_object.distribution_argument_index integer

  8. pg_dist_object.colocationid integer

  9. pg_dist_object.force_delegation boolean

Table: pg_dist_cleanup

The pg_dist_cleanup table has 6 attributes:

  1. pg_dist_cleanup.record_id bigint

    • NOT NULL
    • PRIMARY KEY (record_id)
  2. pg_dist_cleanup.operation_id bigint

    • NOT NULL
  3. pg_dist_cleanup.object_type integer

    • NOT NULL
  4. pg_dist_cleanup.object_name text

    • NOT NULL
  5. pg_dist_cleanup.node_group_id integer

    • NOT NULL
  6. pg_dist_cleanup.policy_type integer

    • NOT NULL

Table: pg_dist_background_job

The pg_dist_background_job table has 6 attributes:

  1. pg_dist_background_job.job_id bigint

    • NOT NULL
    • DEFAULT nextval('pg_dist_background_job_job_id_seq'::regclass)
    • PRIMARY KEY (job_id)
  2. pg_dist_background_job.state citus_job_status

    • NOT NULL
    • DEFAULT 'scheduled'::citus_job_status
  3. pg_dist_background_job.job_type name

    • NOT NULL
  4. pg_dist_background_job.description text

    • NOT NULL
  5. pg_dist_background_job.started_at timestamp with time zone

  6. pg_dist_background_job.finished_at timestamp with time zone

Table: pg_dist_background_task

The pg_dist_background_task table has 9 attributes:

  1. pg_dist_background_task.job_id bigint

    • NOT NULL
    • FOREIGN KEY (job_id) REFERENCES pg_dist_background_job(job_id)
  2. pg_dist_background_task.task_id bigint

    • NOT NULL
    • DEFAULT nextval('pg_dist_background_task_task_id_seq'::regclass)
    • PRIMARY KEY (task_id)
  3. pg_dist_background_task.owner regrole

    • NOT NULL
    • DEFAULT CURRENT_USER::regrole
  4. pg_dist_background_task.pid integer

  5. pg_dist_background_task.status citus_task_status

    • NOT NULL
    • DEFAULT 'runnable'::citus_task_status
  6. pg_dist_background_task.command text

    • NOT NULL
  7. pg_dist_background_task.retry_count integer

  8. pg_dist_background_task.not_before timestamp with time zone

  9. pg_dist_background_task.message text

    • NOT NULL
    • DEFAULT ''::text

Table: pg_dist_background_task_depend

The pg_dist_background_task_depend table has 3 attributes:

  1. pg_dist_background_task_depend.job_id bigint

    • NOT NULL
    • FOREIGN KEY (job_id) REFERENCES pg_dist_background_job(job_id) ON DELETE CASCADE
  2. pg_dist_background_task_depend.task_id bigint

    • NOT NULL
  3. pg_dist_background_task_depend.depends_on bigint

    • NOT NULL

Views

View: pg_dist_shard_placement

 SELECT placement.shardid, placement.shardstate, placement.shardlength,
    node.nodename, node.nodeport, placement.placementid
   FROM pg_dist_placement placement
     JOIN pg_dist_node node ON placement.groupid = node.groupid AND node.noderole = 'primary'::noderole;

View: citus_stat_statements

 SELECT citus_stat_statements.queryid, citus_stat_statements.userid,
    citus_stat_statements.dbid, citus_stat_statements.query,
    citus_executor_name(citus_stat_statements.executor::integer) AS executor,
    citus_stat_statements.partition_key, citus_stat_statements.calls
   FROM citus_stat_statements() citus_stat_statements(queryid, userid, dbid, query, executor, partition_key, calls);

View: citus_shards_on_worker

 SELECT s.schema_name AS "Schema", s.shard_name AS "Name",
    s.table_type AS "Type", s.owner_name AS "Owner"
   FROM citus_shards_on_worker() s(schema_name, shard_name, table_type, owner_name);

View: citus_shard_indexes_on_worker

 SELECT s.schema_name AS "Schema", s.index_name AS "Name",
    s.table_type AS "Type", s.owner_name AS "Owner", s.shard_name AS "Table"
   FROM citus_shard_indexes_on_worker() s(schema_name, index_name, table_type, owner_name, shard_name);

View: time_partitions

 SELECT partitions.partrelid AS parent_table,
    partitions.attname AS partition_column, partitions.relid AS partition,
    partitions.lower_bound AS from_value, partitions.upper_bound AS to_value,
    partitions.amname AS access_method
   FROM ( SELECT p.partrelid::regclass AS partrelid, a.attname,
            c.oid::regclass AS relid, time_partition_range.lower_bound,
            time_partition_range.upper_bound, am.amname
           FROM pg_class c
             JOIN pg_inherits i ON c.oid = i.inhrelid
             JOIN pg_partitioned_table p ON i.inhparent = p.partrelid
             JOIN pg_attribute a ON p.partrelid = a.attrelid
             JOIN pg_type t ON a.atttypid = t.oid
             JOIN pg_namespace tn ON t.typnamespace = tn.oid
             LEFT JOIN pg_am am ON c.relam = am.oid,
            LATERAL time_partition_range(c.oid::regclass) time_partition_range(lower_bound, upper_bound)
          WHERE c.relpartbound IS NOT NULL AND p.partstrat = 'r'::"char" AND p.partnatts = 1 AND (a.attnum = ANY (p.partattrs::smallint[]))) partitions
  ORDER BY (partitions.partrelid::text), partitions.lower_bound;

View: citus_shards

 SELECT pg_dist_shard.logicalrelid AS table_name, pg_dist_shard.shardid,
    shard_name(pg_dist_shard.logicalrelid, pg_dist_shard.shardid) AS shard_name,
        CASE
            WHEN pg_dist_partition.partkey IS NOT NULL THEN 'distributed'::text
            WHEN pg_dist_partition.repmodel = 't'::"char" THEN 'reference'::text
            ELSE 'local'::text
        END AS citus_table_type,
    pg_dist_partition.colocationid AS colocation_id, pg_dist_node.nodename,
    pg_dist_node.nodeport, shard_sizes.size AS shard_size
   FROM pg_dist_shard
     JOIN pg_dist_placement ON pg_dist_shard.shardid = pg_dist_placement.shardid
     JOIN pg_dist_node ON pg_dist_placement.groupid = pg_dist_node.groupid
     JOIN pg_dist_partition ON pg_dist_partition.logicalrelid::oid = pg_dist_shard.logicalrelid::oid
     LEFT JOIN ( SELECT (regexp_matches(citus_shard_sizes.table_name, '_(\d+)$'::text))[1]::integer AS shard_id,
            max(citus_shard_sizes.size) AS size
           FROM citus_shard_sizes() citus_shard_sizes(table_name, size)
          GROUP BY ((regexp_matches(citus_shard_sizes.table_name, '_(\d+)$'::text))[1]::integer)) shard_sizes ON pg_dist_shard.shardid = shard_sizes.shard_id
  WHERE pg_dist_placement.shardstate = 1 AND NOT (pg_dist_partition.logicalrelid::oid IN ( SELECT pg_depend.objid
           FROM pg_depend
          WHERE pg_depend.classid = 'pg_class'::regclass::oid AND pg_depend.refclassid = 'pg_extension'::regclass::oid AND pg_depend.deptype = 'e'::"char"))
  ORDER BY (pg_dist_shard.logicalrelid::text), pg_dist_shard.shardid;

View: citus_tables

 SELECT p.logicalrelid AS table_name,
        CASE
            WHEN p.partkey IS NOT NULL THEN 'distributed'::text
            ELSE
            CASE
                WHEN p.repmodel = 't'::"char" THEN 'reference'::text
                ELSE 'local'::text
            END
        END AS citus_table_type,
    COALESCE(column_to_column_name(p.logicalrelid, p.partkey), '<none>'::text) AS distribution_column,
    p.colocationid AS colocation_id,
    pg_size_pretty(citus_total_relation_size(p.logicalrelid, fail_on_error => false)) AS table_size,
    ( SELECT count(*) AS count
           FROM pg_dist_shard
          WHERE pg_dist_shard.logicalrelid::oid = p.logicalrelid::oid) AS shard_count,
    pg_get_userbyid(c.relowner) AS table_owner, a.amname AS access_method
   FROM pg_dist_partition p
     JOIN pg_class c ON p.logicalrelid::oid = c.oid
     LEFT JOIN pg_am a ON a.oid = c.relam
  WHERE NOT (p.logicalrelid::oid IN ( SELECT pg_depend.objid
           FROM pg_depend
          WHERE pg_depend.classid = 'pg_class'::regclass::oid AND pg_depend.refclassid = 'pg_extension'::regclass::oid AND pg_depend.deptype = 'e'::"char"))
  ORDER BY (p.logicalrelid::text);

View: citus_stat_activity

 SELECT citus_stat_activity.global_pid, citus_stat_activity.nodeid,
    citus_stat_activity.is_worker_query, citus_stat_activity.datid,
    citus_stat_activity.datname, citus_stat_activity.pid,
    citus_stat_activity.leader_pid, citus_stat_activity.usesysid,
    citus_stat_activity.usename, citus_stat_activity.application_name,
    citus_stat_activity.client_addr, citus_stat_activity.client_hostname,
    citus_stat_activity.client_port, citus_stat_activity.backend_start,
    citus_stat_activity.xact_start, citus_stat_activity.query_start,
    citus_stat_activity.state_change, citus_stat_activity.wait_event_type,
    citus_stat_activity.wait_event, citus_stat_activity.state,
    citus_stat_activity.backend_xid, citus_stat_activity.backend_xmin,
    citus_stat_activity.query_id, citus_stat_activity.query,
    citus_stat_activity.backend_type
   FROM citus_stat_activity() citus_stat_activity(global_pid, nodeid, is_worker_query, datid, datname, pid, leader_pid, usesysid, usename, application_name, client_addr, client_hostname, client_port, backend_start, xact_start, query_start, state_change, wait_event_type, wait_event, state, backend_xid, backend_xmin, query_id, query, backend_type);

View: citus_dist_stat_activity

 SELECT citus_stat_activity.global_pid, citus_stat_activity.nodeid,
    citus_stat_activity.is_worker_query, citus_stat_activity.datid,
    citus_stat_activity.datname, citus_stat_activity.pid,
    citus_stat_activity.leader_pid, citus_stat_activity.usesysid,
    citus_stat_activity.usename, citus_stat_activity.application_name,
    citus_stat_activity.client_addr, citus_stat_activity.client_hostname,
    citus_stat_activity.client_port, citus_stat_activity.backend_start,
    citus_stat_activity.xact_start, citus_stat_activity.query_start,
    citus_stat_activity.state_change, citus_stat_activity.wait_event_type,
    citus_stat_activity.wait_event, citus_stat_activity.state,
    citus_stat_activity.backend_xid, citus_stat_activity.backend_xmin,
    citus_stat_activity.query_id, citus_stat_activity.query,
    citus_stat_activity.backend_type
   FROM citus_stat_activity
  WHERE citus_stat_activity.is_worker_query = false;

View: citus_lock_waits

 WITH unique_global_wait_edges_with_calculated_gpids AS (
         SELECT
                CASE
                    WHEN citus_internal_global_blocked_processes.waiting_global_pid <> 0 THEN citus_internal_global_blocked_processes.waiting_global_pid
                    ELSE citus_calculate_gpid(get_nodeid_for_groupid(citus_internal_global_blocked_processes.waiting_node_id), citus_internal_global_blocked_processes.waiting_pid)
                END AS waiting_global_pid,
                CASE
                    WHEN citus_internal_global_blocked_processes.blocking_global_pid <> 0 THEN citus_internal_global_blocked_processes.blocking_global_pid
                    ELSE citus_calculate_gpid(get_nodeid_for_groupid(citus_internal_global_blocked_processes.blocking_node_id), citus_internal_global_blocked_processes.blocking_pid)
                END AS blocking_global_pid,
            get_nodeid_for_groupid(citus_internal_global_blocked_processes.blocking_node_id) AS blocking_node_id,
            get_nodeid_for_groupid(citus_internal_global_blocked_processes.waiting_node_id) AS waiting_node_id,
            citus_internal_global_blocked_processes.blocking_transaction_waiting
           FROM citus_internal_global_blocked_processes() citus_internal_global_blocked_processes(waiting_global_pid, waiting_pid, waiting_node_id, waiting_transaction_num, waiting_transaction_stamp, blocking_global_pid, blocking_pid, blocking_node_id, blocking_transaction_num, blocking_transaction_stamp, blocking_transaction_waiting)
        ), unique_global_wait_edges AS (
         SELECT DISTINCT ON (unique_global_wait_edges_with_calculated_gpids.waiting_global_pid, unique_global_wait_edges_with_calculated_gpids.blocking_global_pid) unique_global_wait_edges_with_calculated_gpids.waiting_global_pid,
            unique_global_wait_edges_with_calculated_gpids.blocking_global_pid,
            unique_global_wait_edges_with_calculated_gpids.blocking_node_id,
            unique_global_wait_edges_with_calculated_gpids.waiting_node_id,
            unique_global_wait_edges_with_calculated_gpids.blocking_transaction_waiting
           FROM unique_global_wait_edges_with_calculated_gpids
        ), citus_dist_stat_activity_with_calculated_gpids AS (
         SELECT
                CASE
                    WHEN citus_dist_stat_activity.global_pid <> 0 THEN citus_dist_stat_activity.global_pid
                    ELSE citus_calculate_gpid(citus_dist_stat_activity.nodeid, citus_dist_stat_activity.pid)
                END AS global_pid,
            citus_dist_stat_activity.nodeid, citus_dist_stat_activity.pid,
            citus_dist_stat_activity.query
           FROM citus_dist_stat_activity
        )
 SELECT waiting.global_pid AS waiting_gpid, blocking.global_pid AS blocking_gpid,
    waiting.query AS blocked_statement,
    blocking.query AS current_statement_in_blocking_process,
    waiting.nodeid AS waiting_nodeid, blocking.nodeid AS blocking_nodeid
   FROM unique_global_wait_edges
     JOIN citus_dist_stat_activity_with_calculated_gpids waiting ON unique_global_wait_edges.waiting_global_pid = waiting.global_pid
     JOIN citus_dist_stat_activity_with_calculated_gpids blocking ON unique_global_wait_edges.blocking_global_pid = blocking.global_pid;

View: citus_locks

 SELECT citus_locks.global_pid, citus_locks.nodeid, citus_locks.locktype,
    citus_locks.database, citus_locks.relation, citus_locks.relation_name,
    citus_locks.page, citus_locks.tuple, citus_locks.virtualxid,
    citus_locks.transactionid, citus_locks.classid, citus_locks.objid,
    citus_locks.objsubid, citus_locks.virtualtransaction, citus_locks.pid,
    citus_locks.mode, citus_locks.granted, citus_locks.fastpath,
    citus_locks.waitstart
   FROM citus_locks() citus_locks(global_pid, nodeid, locktype, database, relation, relation_name, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted, fastpath, waitstart);

Routines

Function: alter_distributed_table (regclass, text, integer, text, boolean)

alters a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_column text NULL::text
$3 IN shard_count integer NULL::integer
$4 IN colocate_with text NULL::text
$5 IN cascade_to_colocated boolean NULL::boolean

Function return type: void

Function attributes: COST 1

Procedure: alter_old_partitions_set_access_method (regclass, timestamp with time zone, name)

convert old partitions of a time-partitioned table to a new access method

Procedure arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN parent_table_name regclass
$2 IN older_than timestamp with time zone
$3 IN new_access_method name

Function: alter_role_if_exists (text, text)

runs the utility query, if the role exists

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN role_name text
$2 IN utility_query text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: alter_table_set_access_method (regclass, text)

alters a table's access method

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN access_method text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: any_value (anyelement)

Returns the value of any row in the group. It is mostly useful when you know there will be only 1 element.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN anyelement

Function return type: anyelement

Function attributes: IMMUTABLE, COST 1

Function: any_value_agg (anyelement, anyelement)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN anyelement
$2 IN anyelement

Function return type: anyelement

Function attributes: STABLE

Function: array_cat_agg (anycompatiblearray)

concatenate input arrays into a single array

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN anycompatiblearray

Function return type: anycompatiblearray

Function attributes: IMMUTABLE, COST 1

Function: assign_distributed_transaction_id (integer, bigint, timestamp with time zone)

Only intended for internal use, users should not call this. The function sets the distributed transaction id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN initiator_node_identifier integer
$2 IN transaction_number bigint
$3 IN transaction_stamp timestamp with time zone

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: authinfo_valid (text)

returns whether an authinfo is valid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: broadcast_intermediate_result (text, text)

execute a query and write its results to an result file on all workers

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_id text
$2 IN query text

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: check_distributed_deadlocks()

does a distributed deadlock check, if a deadlock found cancels one of the participating backends and returns true

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_activate_node (text, integer)

activate a node which is in the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_inactive_node (text, integer, integer, noderole, name)

prepare node by adding it to pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_local_table_to_metadata (regclass, boolean)

create a citus local table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN cascade_via_foreign_keys boolean false

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_node (text, integer, integer, noderole, name)

add node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_add_rebalance_strategy (name, regproc, regproc, regproc, real, real, real)

adds a new rebalance strategy which can be used when rebalancing shards or draining nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN name name
$2 IN shard_cost_function regproc
$3 IN node_capacity_function regproc
$4 IN shard_allowed_on_node_function regproc
$5 IN default_threshold real
$6 IN minimum_threshold real 0
$7 IN improvement_threshold real 0

Function return type: void

Function: citus_add_secondary_node (text, integer, text, integer, name)

add a secondary node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN primaryname text
$4 IN primaryport integer
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_backend_gpid()

returns gpid of the current backend

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_blocking_pids (integer)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN pblockedpid integer

Function return type: integer[]

Function: citus_calculate_gpid (integer, integer)

calculate gpid of a backend running on any node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodeid integer
$2 IN pid integer

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_check_cluster_node_health()

checks connections between all nodes in the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT from_nodename text
$2 OUT from_nodeport integer
$3 OUT to_nodename text
$4 OUT to_nodeport integer
$5 OUT result boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_check_connection_to_node (text, integer)

checks connection to another node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer 5432

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Procedure: citus_cleanup_orphaned_resources()

cleanup orphaned resources

Procedure attributes: COST 1

Procedure: citus_cleanup_orphaned_shards()

cleanup orphaned shards

Procedure attributes: COST 1

Function: citus_conninfo_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_coordinator_nodeid()

returns node id of the coordinator node

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_copy_shard_placement (bigint, integer, integer, citus.shard_transfer_mode)

copy a shard from the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_id integer
$3 IN target_node_id integer
$4 IN transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_copy_shard_placement (bigint, text, integer, text, integer, citus.shard_transfer_mode)

copy a shard from the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_create_restore_point (text)

temporarily block writes and create a named restore point on all nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: pg_lsn

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_disable_node (text, integer, boolean)

removes node from the cluster temporarily

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN synchronous boolean false

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_dist_local_group_cache_invalidate()

register node cache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_node_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_object_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_partition_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_placement_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_dist_shard_cache_invalidate()

register relcache invalidation for changed rows

Function return type: trigger

Function attributes: COST 1

Function: citus_drain_node (text, integer, citus.shard_transfer_mode, name)

mark a node to be drained of data and actually drain it as well

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode
$4 IN rebalance_strategy name NULL::name

Function return type: void

Function attributes: COST 1

Function: citus_drop_all_shards (regclass, text, text, boolean)

drop all shards in a relation and update metadata

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN schema_name text
$3 IN table_name text
$4 IN drop_shards_metadata_only boolean false

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_drop_trigger()

perform checks and actions at the end of DROP actions

Function return type: event_trigger

Function-local settings:

  • SET search_path TO pg_catalog

Function: citus_executor_name (integer)

return the name of the external based for the value in citus_stat_statements() output

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN executor_type integer

Function return type: text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_extradata_container (internal)

placeholder function to store additional data in postgres node trees

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal

Function return type: SETOF record

Function attributes: COST 1, ROWS 1000

Function: citus_finalize_upgrade_to_citus11 (boolean)

finalizes upgrade to Citus

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN enforce_version_check boolean true

Function return type: boolean

Procedure: citus_finish_citus_upgrade()

after upgrading Citus on all nodes call this function to upgrade the distributed schema

Procedure-local settings:

  • SET search_path TO pg_catalog

Function: citus_finish_pg_upgrade()

perform tasks to restore citus settings from a location that has been prepared before pg_upgrade

Function return type: void

Function-local settings:

  • SET search_path TO pg_catalog

Function: citus_get_active_worker_nodes()

fetch set of active worker nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT node_name text
$2 OUT node_port bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 100

Function: citus_get_node_clock()

Returns monotonically increasing timestamp with logical clock value as close to epoch value (in milli seconds) as possible, and a counter for ticks(maximum of 4 million) within the logical clock

Function return type: cluster_clock

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_get_transaction_clock()

Returns a transaction timestamp logical clock

Function return type: cluster_clock

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal.find_groupid_for_node (text, integer)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text
$2 IN integer

Function return type: integer

Function: citus_internal.pg_dist_node_trigger_func()

Function return type: trigger

Function: citus_internal.pg_dist_rebalance_strategy_trigger_func()

Function return type: trigger

Function: citus_internal.pg_dist_shard_placement_trigger_func()

Function return type: trigger

Function: citus_internal.refresh_isolation_tester_prepared_statement()

Function return type: void

Function: citus_internal.replace_isolation_tester_func()

Function return type: void

Function: citus_internal.restore_isolation_tester_func()

Function return type: void

Function: citus_internal_add_colocation_metadata (integer, integer, integer, regtype, oid)

Inserts a co-location group into pg_dist_colocation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN colocation_id integer
$2 IN shard_count integer
$3 IN replication_factor integer
$4 IN distribution_column_type regtype
$5 IN distribution_column_collation oid

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_add_object_metadata (text, text[], text[], integer, integer, boolean)

Inserts distributed object into pg_dist_object

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN typetext text
$2 IN objnames text[]
$3 IN objargs text[]
$4 IN distribution_argument_index integer
$5 IN colocationid integer
$6 IN force_delegation boolean

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_add_partition_metadata (regclass, "char", text, integer, "char")

Inserts into pg_dist_partition with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation_id regclass
$2 IN distribution_method "char"
$3 IN distribution_column text
$4 IN colocation_id integer
$5 IN replication_model "char"

Function return type: void

Function attributes: COST 1

Function: citus_internal_add_placement_metadata (bigint, bigint, integer, bigint)

Inserts into pg_dist_shard_placement with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN shard_length bigint
$3 IN group_id integer
$4 IN placement_id bigint

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_add_placement_metadata (bigint, integer, bigint, integer, bigint)

Inserts into pg_dist_shard_placement with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN shard_state integer
$3 IN shard_length bigint
$4 IN group_id integer
$5 IN placement_id bigint

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_add_shard_metadata (regclass, bigint, "char", text, text)

Inserts into pg_dist_shard with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation_id regclass
$2 IN shard_id bigint
$3 IN storage_type "char"
$4 IN shard_min_value text
$5 IN shard_max_value text

Function return type: void

Function attributes: COST 1

Function: citus_internal_adjust_local_clock_to_remote (cluster_clock)

Internal UDF used to adjust the local clock to the maximum of nodes in the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock

Function return type: void

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1

Function: citus_internal_delete_colocation_metadata (integer)

deletes a co-location group from pg_dist_colocation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN colocation_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_delete_partition_metadata (regclass)

Deletes a row from pg_dist_partition with table ownership checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_delete_shard_metadata (bigint)

Deletes rows from pg_dist_shard and pg_dist_shard_placement with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_global_blocked_processes()

returns a global list of blocked backends originating from this node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_global_pid bigint
$2 OUT waiting_pid integer
$3 OUT waiting_node_id integer
$4 OUT waiting_transaction_num bigint
$5 OUT waiting_transaction_stamp timestamp with time zone
$6 OUT blocking_global_pid bigint
$7 OUT blocking_pid integer
$8 OUT blocking_node_id integer
$9 OUT blocking_transaction_num bigint
$10 OUT blocking_transaction_stamp timestamp with time zone
$11 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_internal_local_blocked_processes()

returns all local lock wait chains, that start from any citus backend

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_global_pid bigint
$2 OUT waiting_pid integer
$3 OUT waiting_node_id integer
$4 OUT waiting_transaction_num bigint
$5 OUT waiting_transaction_stamp timestamp with time zone
$6 OUT blocking_global_pid bigint
$7 OUT blocking_pid integer
$8 OUT blocking_node_id integer
$9 OUT blocking_transaction_num bigint
$10 OUT blocking_transaction_stamp timestamp with time zone
$11 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_internal_update_placement_metadata (bigint, integer, integer)

Updates into pg_dist_placement with user checks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_group_id integer
$3 IN target_group_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_internal_update_relation_colocation (oid, integer)

Updates colocationId field of pg_dist_partition for the relation_id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation_id oid
$2 IN target_colocation_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_is_clock_after (cluster_clock, cluster_clock)

Accepts logical clock timestamps of two causally related events and returns true if the argument1 happened before argument2

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN clock_one cluster_clock
$2 IN clock_two cluster_clock

Function return type: boolean

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1

Function: citus_is_coordinator()

returns whether the current node is a coordinator

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_isolation_test_session_is_blocked (integer, integer[])

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN pblockedpid integer
$2 IN pinterestingpids integer[]

Function return type: boolean

Function: citus_job_cancel (bigint)

cancel a scheduled or running job and all of its tasks that didn't finish yet

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN jobid bigint

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_job_list()

Function return type: TABLE(job_id bigint, state citus_job_status, job_type name, description text, started_at timestamp with time zone, finished_at timestamp with time zone)

Function attributes: ROWS 1000

Function: citus_job_status (bigint, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN job_id bigint
$2 IN raw boolean false
$3 TABLE job_id bigint
$4 TABLE state citus_job_status
$5 TABLE job_type name
$6 TABLE description text
$7 TABLE started_at timestamp with time zone
$8 TABLE finished_at timestamp with time zone
$9 TABLE details jsonb

Function return type: TABLE(job_id bigint, state citus_job_status, job_type name, description text, started_at timestamp with time zone, finished_at timestamp with time zone, details jsonb)

Function attributes: RETURNS NULL ON NULL INPUT, ROWS 1000

Function: citus_job_wait (bigint, citus_job_status)

blocks till the job identified by jobid is at the specified status, or reached a terminal status. Only waits for terminal status when no desired_status was specified. The return value indicates if the desired status was reached or not. When no desired status was specified it will assume any terminal status was desired

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN jobid bigint
$2 IN desired_status citus_job_status NULL::citus_job_status

Function return type: void

Function attributes: COST 1

Function: citus_json_concatenate (json, json)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state json
$2 IN val json

Function return type: json

Function: citus_json_concatenate_final (json)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state json

Function return type: json

Function: citus_jsonb_concatenate (jsonb, jsonb)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state jsonb
$2 IN val jsonb

Function return type: jsonb

Function: citus_jsonb_concatenate_final (jsonb)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN state jsonb

Function return type: jsonb

Function: citus_local_disk_space_stats()

returns statistics on available disk space on the local node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT available_disk_size bigint
$2 OUT total_disk_size bigint

Function return type: record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_locks()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT global_pid bigint
$2 OUT nodeid integer
$3 OUT locktype text
$4 OUT database oid
$5 OUT relation oid
$6 OUT relation_name text
$7 OUT page integer
$8 OUT tuple smallint
$9 OUT virtualxid text
$10 OUT transactionid xid
$11 OUT classid oid
$12 OUT objid oid
$13 OUT objsubid smallint
$14 OUT virtualtransaction text
$15 OUT pid integer
$16 OUT mode text
$17 OUT granted boolean
$18 OUT fastpath boolean
$19 OUT waitstart timestamp with time zone

Function return type: SETOF record

Function attributes: ROWS 1000

Function: citus_move_shard_placement (bigint, integer, integer, citus.shard_transfer_mode)

move a shard from the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_id integer
$3 IN target_node_id integer
$4 IN transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_move_shard_placement (bigint, text, integer, text, integer, citus.shard_transfer_mode)

move a shard from a the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_node_capacity_1 (integer)

a node capacity function for use by the rebalance algorithm that always returns 1

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN integer

Function return type: real

Function: citus_nodeid_for_gpid (bigint)

returns node id for the global process with given global pid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_nodename_for_nodeid (integer)

returns node name for the node with given node id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodeid integer

Function return type: text

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_nodeport_for_nodeid (integer)

returns node port for the node with given node id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodeid integer

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_pid_for_gpid (bigint)

returns process id for the global process with given global pid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint

Function return type: integer

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: citus_prepare_pg_upgrade()

perform tasks to copy citus settings to a location that could later be restored after pg_upgrade is done

Function return type: void

Function-local settings:

  • SET search_path TO pg_catalog

Function: citus_query_stats()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT queryid bigint
$2 OUT userid oid
$3 OUT dbid oid
$4 OUT executor bigint
$5 OUT partition_key text
$6 OUT calls bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_rebalance_start (name, boolean, citus.shard_transfer_mode)

rebalance the shards in the cluster in the background

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN rebalance_strategy name NULL::name
$2 IN drain_only boolean false
$3 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: bigint

Function attributes: COST 1

Function: citus_rebalance_status (boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN raw boolean false
$2 TABLE job_id bigint
$3 TABLE state citus_job_status
$4 TABLE job_type name
$5 TABLE description text
$6 TABLE started_at timestamp with time zone
$7 TABLE finished_at timestamp with time zone
$8 TABLE details jsonb

Function return type: TABLE(job_id bigint, state citus_job_status, job_type name, description text, started_at timestamp with time zone, finished_at timestamp with time zone, details jsonb)

Function attributes: RETURNS NULL ON NULL INPUT, ROWS 1000

Function: citus_rebalance_stop()

stop a rebalance that is running in the background

Function return type: void

Function attributes: COST 1

Function: citus_rebalance_wait()

wait on a running rebalance in the background

Function return type: void

Function attributes: COST 1

Function: citus_relation_size (regclass)

get disk space used by the 'main' fork

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_remote_connection_stats()

returns statistics about remote connections

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT hostname text
$2 OUT port integer
$3 OUT database_name text
$4 OUT connection_count_to_node integer

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_remove_node (text, integer)

remove node from the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_run_local_command (text)

citus_run_local_command executes the input command

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text

Function return type: void

Function: citus_server_id()

generates a random UUID to be used as server identifier

Function return type: uuid

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_set_coordinator_host (text, integer, noderole, name)

set the host and port of the coordinator

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN host text
$2 IN port integer (current_setting('port'::text))::integer
$3 IN node_role noderole 'primary'::noderole
$4 IN node_cluster name 'default'::name

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_set_default_rebalance_strategy (text)

changes the default rebalance strategy to the one with the specified name

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT

Function: citus_set_node_property (text, integer, text, boolean)

set a property of a node in pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN property text
$4 IN value boolean

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_shard_allowed_on_node_true (bigint, integer)

a shard_allowed_on_node_function for use by the rebalance algorithm that always returns true

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint
$2 IN integer

Function return type: boolean

Function: citus_shard_cost_1 (bigint)

a shard cost function for use by the rebalance algorithm that always returns 1

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint

Function return type: real

Function: citus_shard_cost_by_disk_size (bigint)

a shard cost function for use by the rebalance algorithm that returns the disk size in bytes for the specified shard and the shards that are colocated with it

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint

Function return type: real

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_shard_indexes_on_worker()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT schema_name name
$2 OUT index_name name
$3 OUT table_type text
$4 OUT owner_name name
$5 OUT shard_name name

Function return type: SETOF record

Function attributes: ROWS 1000

Function-local settings:

  • SET citus.show_shards_for_app_name_prefixes TO *

Function: citus_shard_sizes()

returns shards sizes across citus cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT table_name text
$2 OUT size bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: citus_shards_on_worker()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT schema_name name
$2 OUT shard_name name
$3 OUT table_type text
$4 OUT owner_name name

Function return type: SETOF record

Function attributes: ROWS 1000

Function-local settings:

  • SET citus.show_shards_for_app_name_prefixes TO *

Function: citus_split_shard_by_split_points (bigint, text[], integer[], citus.shard_transfer_mode)

split a shard using split mode.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN split_points text[]
$3 IN node_ids integer[]
$4 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_stat_activity()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT global_pid bigint
$2 OUT nodeid integer
$3 OUT is_worker_query boolean
$4 OUT datid oid
$5 OUT datname name
$6 OUT pid integer
$7 OUT leader_pid integer
$8 OUT usesysid oid
$9 OUT usename name
$10 OUT application_name text
$11 OUT client_addr inet
$12 OUT client_hostname text
$13 OUT client_port integer
$14 OUT backend_start timestamp with time zone
$15 OUT xact_start timestamp with time zone
$16 OUT query_start timestamp with time zone
$17 OUT state_change timestamp with time zone
$18 OUT wait_event_type text
$19 OUT wait_event text
$20 OUT state text
$21 OUT backend_xid xid
$22 OUT backend_xmin xid
$23 OUT query_id bigint
$24 OUT query text
$25 OUT backend_type text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: citus_stat_statements()

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT queryid bigint
$2 OUT userid oid
$3 OUT dbid oid
$4 OUT query text
$5 OUT executor bigint
$6 OUT partition_key text
$7 OUT calls bigint

Function return type: SETOF record

Function attributes: ROWS 1000

Function: citus_stat_statements_reset()

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_table_is_visible (oid)

wrapper on pg_table_is_visible, filtering out tables (and indexes) that are known to be shards

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN oid

Function return type: boolean

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1

Function: citus_table_size (regclass)

get disk space used by the specified table, excluding indexes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_task_wait (bigint, citus_task_status)

blocks till the task identified by taskid is at the specified status, or reached a terminal status. Only waits for terminal status when no desired_status was specified. The return value indicates if the desired status was reached or not. When no desired status was specified it will assume any terminal status was desired

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN taskid bigint
$2 IN desired_status citus_task_status NULL::citus_task_status

Function return type: void

Function attributes: COST 1

Function: citus_text_send_as_jsonb (text)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: bytea

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1

Function: citus_total_relation_size (regclass, boolean)

get total disk space used by the specified table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN fail_on_error boolean true

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_truncate_trigger()

trigger function called when truncating the distributed table

Function return type: trigger

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_unmark_object_distributed (oid, oid, integer)

remove an object address from citus.pg_dist_object once the object has been deleted

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN classid oid
$2 IN objid oid
$3 IN objsubid integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_update_node (integer, text, integer, boolean, integer)

change the location of a node. when force => true it will wait lock_cooldown ms before killing competing locks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN node_id integer
$2 IN new_node_name text
$3 IN new_node_port integer
$4 IN force boolean false
$5 IN lock_cooldown integer 10000

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_update_shard_statistics (bigint)

updates shard statistics and returns the updated shard size

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_update_table_statistics (regclass)

updates shard statistics of the given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_validate_rebalance_strategy_functions (regproc, regproc, regproc)

internal function used by citus to validate signatures of functions used in rebalance strategy

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_cost_function regproc
$2 IN node_capacity_function regproc
$3 IN shard_allowed_on_node_function regproc

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: citus_version()

Citus version string

Function return type: text

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_cmp (cluster_clock, cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock
$2 IN cluster_clock

Function return type: integer

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_eq (cluster_clock, cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock
$2 IN cluster_clock

Function return type: boolean

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_ge (cluster_clock, cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock
$2 IN cluster_clock

Function return type: boolean

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_gt (cluster_clock, cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock
$2 IN cluster_clock

Function return type: boolean

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_in (cstring)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cstring

Function return type: cluster_clock

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_le (cluster_clock, cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock
$2 IN cluster_clock

Function return type: boolean

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_logical (cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock

Function return type: bigint

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_lt (cluster_clock, cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock
$2 IN cluster_clock

Function return type: boolean

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_ne (cluster_clock, cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock
$2 IN cluster_clock

Function return type: boolean

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_out (cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock

Function return type: cstring

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_recv (internal)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal

Function return type: cluster_clock

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: cluster_clock_send (cluster_clock)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN cluster_clock

Function return type: bytea

Function attributes: IMMUTABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: column_name_to_column (regclass, text)

convert a column name to its textual Var representation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN column_name text

Function return type: text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: column_to_column_name (regclass, text)

convert the textual Var representation to a column name

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN column_var_text text

Function return type: text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: coord_combine_agg (oid, cstring, anyelement)

support aggregate for implementing combining partial aggregate results from workers

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN oid
$2 IN cstring
$3 IN anyelement

Function return type: anyelement

Function attributes: IMMUTABLE, COST 1

Function: coord_combine_agg_ffunc (internal, oid, cstring, anyelement)

finalizer for coord_combine_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal
$2 IN oid
$3 IN cstring
$4 IN anyelement

Function return type: anyelement

Function attributes: PARALLEL SAFE, COST 1

Function: coord_combine_agg_sfunc (internal, oid, cstring, anyelement)

transition function for coord_combine_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal
$2 IN oid
$3 IN cstring
$4 IN anyelement

Function return type: internal

Function attributes: PARALLEL SAFE, COST 1

Function: create_distributed_function (regprocedure, text, text, boolean)

creates a distributed function

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN function_name regprocedure
$2 IN distribution_arg_name text NULL::text
$3 IN colocate_with text 'default'::text
$4 IN force_delegation boolean NULL::boolean

Function return type: void

Function attributes: COST 1

Function: create_distributed_table (regclass, text, citus.distribution_type, text, integer)

creates a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_column text
$3 IN distribution_type citus.distribution_type 'hash'::citus.distribution_type
$4 IN colocate_with text 'default'::text
$5 IN shard_count integer NULL::integer

Function return type: void

Function attributes: COST 1

Function: create_distributed_table_concurrently (regclass, text, citus.distribution_type, text, integer)

creates a distributed table and avoids blocking writes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_column text
$3 IN distribution_type citus.distribution_type 'hash'::citus.distribution_type
$4 IN colocate_with text 'default'::text
$5 IN shard_count integer NULL::integer

Function return type: void

Function attributes: COST 1

Function: create_intermediate_result (text, text)

execute a query and write its results to local result file

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_id text
$2 IN query text

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: create_reference_table (regclass)

create a distributed reference table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: create_time_partitions (regclass, interval, timestamp with time zone, timestamp with time zone)

create time partitions for the given range

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN partition_interval interval
$3 IN end_at timestamp with time zone
$4 IN start_from timestamp with time zone now()

Function return type: boolean

Function: distributed_tables_colocated (regclass, regclass)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table1 regclass
$2 IN table2 regclass

Function return type: boolean

Procedure: drop_old_time_partitions (regclass, timestamp with time zone)

drop old partitions of a time-partitioned table

Procedure arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN older_than timestamp with time zone

Function: dump_global_wait_edges()

returns a global list of blocked transactions originating from this node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_pid integer
$2 OUT waiting_node_id integer
$3 OUT waiting_transaction_num bigint
$4 OUT waiting_transaction_stamp timestamp with time zone
$5 OUT blocking_pid integer
$6 OUT blocking_node_id integer
$7 OUT blocking_transaction_num bigint
$8 OUT blocking_transaction_stamp timestamp with time zone
$9 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: dump_local_wait_edges()

returns all local lock wait chains, that start from distributed transactions

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT waiting_pid integer
$2 OUT waiting_node_id integer
$3 OUT waiting_transaction_num bigint
$4 OUT waiting_transaction_stamp timestamp with time zone
$5 OUT blocking_pid integer
$6 OUT blocking_node_id integer
$7 OUT blocking_transaction_num bigint
$8 OUT blocking_transaction_stamp timestamp with time zone
$9 OUT blocking_transaction_waiting boolean

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: fetch_intermediate_results (text[], text, integer)

fetch array of intermediate results from a remote node. returns number of bytes read.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_ids text[]
$2 IN node_name text
$3 IN node_port integer

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: fix_all_partition_shard_index_names()

fix index names on partition shards of all tables

Function return type: SETOF regclass

Function attributes: ROWS 1000

Function: fix_partition_shard_index_names (regclass)

fix index names on partition shards of given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: fix_pre_citus10_partitioned_table_constraint_names()

fix constraint names on all partition shards

Function return type: SETOF regclass

Function attributes: ROWS 1000

Function: fix_pre_citus10_partitioned_table_constraint_names (regclass)

fix constraint names on partition shards

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_all_active_transactions()

returns transaction information for all Citus initiated transactions

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT datid oid
$2 OUT process_id integer
$3 OUT initiator_node_identifier integer
$4 OUT worker_query boolean
$5 OUT transaction_number bigint
$6 OUT transaction_stamp timestamp with time zone
$7 OUT global_pid bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: get_colocated_shard_array (bigint)

returns the array of colocated shards of the given shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint

Function return type: bigint[]

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_colocated_table_array (regclass)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN regclass

Function return type: regclass[]

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_current_transaction_id()

returns the current backend data including distributed transaction id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT database_id oid
$2 OUT process_id integer
$3 OUT initiator_node_identifier integer
$4 OUT transaction_number bigint
$5 OUT transaction_stamp timestamp with time zone

Function return type: record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: get_global_active_transactions()

returns transaction information for all Citus initiated transactions from each node of the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT datid oid
$2 OUT process_id integer
$3 OUT initiator_node_identifier integer
$4 OUT worker_query boolean
$5 OUT transaction_number bigint
$6 OUT transaction_stamp timestamp with time zone
$7 OUT global_pid bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: get_missing_time_partition_ranges (regclass, interval, timestamp with time zone, timestamp with time zone)

get missing partitions ranges for table within the range using the given interval

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN partition_interval interval
$3 IN to_value timestamp with time zone
$4 IN from_value timestamp with time zone now()
$5 TABLE partition_name text
$6 TABLE range_from_value text
$7 TABLE range_to_value text

Function return type: TABLE(partition_name text, range_from_value text, range_to_value text)

Function attributes: ROWS 1000

Function: get_nodeid_for_groupid (integer)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN groupidinput integer

Function return type: integer

Function: get_rebalance_progress()

provides progress information about the ongoing rebalance operations

Function return type: TABLE(sessionid integer, table_name regclass, shardid bigint, shard_size bigint, sourcename text, sourceport integer, targetname text, targetport integer, progress bigint, source_shard_size bigint, target_shard_size bigint, operation_type text, source_lsn pg_lsn, target_lsn pg_lsn, status text)

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: get_rebalance_table_shards_plan (regclass, real, integer, bigint[], boolean, name, real)

returns the list of shard placement moves to be done on a rebalance operation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass NULL::regclass
$2 IN threshold real NULL::real
$3 IN max_shard_moves integer 1000000
$4 IN excluded_shard_list bigint[] '{}'::bigint[]
$5 IN drain_only boolean false
$6 IN rebalance_strategy name NULL::name
$7 IN improvement_threshold real NULL::real
$8 TABLE table_name regclass
$9 TABLE shardid bigint
$10 TABLE shard_size bigint
$11 TABLE sourcename text
$12 TABLE sourceport integer
$13 TABLE targetname text
$14 TABLE targetport integer

Function return type: TABLE(table_name regclass, shardid bigint, shard_size bigint, sourcename text, sourceport integer, targetname text, targetport integer)

Function attributes: COST 1, ROWS 1000

Function: get_shard_id_for_distribution_column (regclass, "any")

return shard id which belongs to given table and contains given value

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN distribution_value "any" NULL::unknown

Function return type: bigint

Function attributes: COST 1

Function: isolate_tenant_to_new_shard (regclass, "any", text, citus.shard_transfer_mode)

isolate a tenant to its own shard and return the new shard id

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN tenant_id "any"
$3 IN cascade_option text ''::text
$4 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: json_cat_agg (json)

concatenate input jsons into a single json

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN json

Function return type: json

Function attributes: IMMUTABLE, COST 1

Function: jsonb_cat_agg (jsonb)

concatenate input jsonbs into a single jsonb

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN jsonb

Function return type: jsonb

Function attributes: IMMUTABLE, COST 1

Function: lock_relation_if_exists (text, text)

used internally to locks relation in the lock_mode if the relation exists without throwing errors; consider using LOCK * IN * MODE instead

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text
$2 IN lock_mode text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: lock_shard_metadata (integer, bigint[])

lock shard metadata to prevent writes during metadata changes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN lock_mode integer
$2 IN shard_id bigint[]

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: lock_shard_resources (integer, bigint[])

lock shard resource to serialise non-commutative writes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN lock_mode integer
$2 IN shard_id bigint[]

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_activate_node (text, integer)

activate a node which is in the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_add_inactive_node (text, integer, integer, noderole, name)

prepare node by adding it to pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_add_node (text, integer, integer, noderole, name)

add node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN groupid integer '-1'::integer
$4 IN noderole noderole 'primary'::noderole
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_add_secondary_node (text, integer, text, integer, name)

add a secondary node to the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN primaryname text
$4 IN primaryport integer
$5 IN nodecluster name 'default'::name

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_copy_shard_placement (bigint, text, integer, text, integer, boolean, citus.shard_transfer_mode)

copy a shard from the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN do_repair boolean true
$7 IN transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_create_empty_shard (text)

create an empty shard and shard placements for the table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_disable_node (text, integer)

removes node from the cluster temporarily

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_drain_node (text, integer, citus.shard_transfer_mode, name)

mark a node to be drained of data and actually drain it as well

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode
$4 IN rebalance_strategy name NULL::name

Function return type: void

Function attributes: COST 1

Function: master_get_active_worker_nodes()

fetch set of active worker nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 OUT node_name text
$2 OUT node_port bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 100

Function: master_get_new_placementid()

fetch unique placementid

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_get_new_shardid()

fetch unique shardId

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_get_table_ddl_events (text)

fetch set of ddl statements for the table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: SETOF text

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 100

Function: master_move_shard_placement (bigint, text, integer, text, integer, citus.shard_transfer_mode)

move a shard from a the source node to the destination node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint
$2 IN source_node_name text
$3 IN source_node_port integer
$4 IN target_node_name text
$5 IN target_node_port integer
$6 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_remove_distributed_table_metadata_from_workers (regclass, text, text)

drops the table and removes all the metadata belonging the distributed table in the worker nodes with metadata.

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN schema_name text
$3 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_remove_node (text, integer)

remove node from the cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_remove_partition_metadata (regclass, text, text)

deletes the partition metadata of a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN logicalrelid regclass
$2 IN schema_name text
$3 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_run_on_worker (text[], integer[], text[], boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN worker_name text[]
$2 IN port integer[]
$3 IN command text[]
$4 IN parallel boolean
$5 OUT node_name text
$6 OUT node_port integer
$7 OUT success boolean
$8 OUT result text

Function return type: SETOF record

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: master_set_node_property (text, integer, text, boolean)

set a property of a node in pg_dist_node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN property text
$4 IN value boolean

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_unmark_object_distributed (oid, oid, integer)

remove an object address from citus.pg_dist_object once the object has been deleted

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN classid oid
$2 IN objid oid
$3 IN objsubid integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_update_node (integer, text, integer, boolean, integer)

change the location of a node. when force => true it will wait lock_cooldown ms before killing competing locks

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN node_id integer
$2 IN new_node_name text
$3 IN new_node_port integer
$4 IN force boolean false
$5 IN lock_cooldown integer 10000

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_update_shard_statistics (bigint)

updates shard statistics and returns the updated shard size

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_id bigint

Function return type: bigint

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: master_update_table_statistics (regclass)

updates shard statistics of the given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: notify_constraint_dropped()

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: pg_cancel_backend (bigint)

cancels a Citus query which might be on any node in the Citus cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint

Function return type: boolean

Function attributes: COST 1

Function: pg_terminate_backend (bigint, bigint)

terminates a Citus query which might be on any node in the Citus cluster

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN global_pid bigint
$2 IN timeout bigint 0

Function return type: boolean

Function attributes: COST 1

Function: poolinfo_valid (text)

returns whether a poolinfo is valid

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: read_intermediate_result (text, citus_copy_format)

read a file and return it as a set of records

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_id text
$2 IN format citus_copy_format 'csv'::citus_copy_format

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1, ROWS 1000

Function: read_intermediate_results (text[], citus_copy_format)

read a set files and return them as a set of records

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_ids text[]
$2 IN format citus_copy_format 'csv'::citus_copy_format

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, PARALLEL SAFE, COST 1, ROWS 1000

Function: rebalance_table_shards (regclass, real, integer, bigint[], citus.shard_transfer_mode, boolean, name)

rebalance the shards of the given table across the worker nodes (including colocated shards of other tables)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass NULL::regclass
$2 IN threshold real NULL::real
$3 IN max_shard_moves integer 1000000
$4 IN excluded_shard_list bigint[] '{}'::bigint[]
$5 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode
$6 IN drain_only boolean false
$7 IN rebalance_strategy name NULL::name

Function return type: void

Function attributes: COST 1

Function: recover_prepared_transactions()

recover prepared transactions started by this node

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: relation_is_a_known_shard (regclass)

returns true if the given relation is a known shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN regclass

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: remove_local_tables_from_metadata()

undistribute citus local tables that are not chained with any reference tables via foreign keys

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: replicate_reference_tables (citus.shard_transfer_mode)

replicate reference tables to all nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: replicate_table_shards (regclass, integer, integer, bigint[], citus.shard_transfer_mode)

replicates under replicated shards of the the given table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass
$2 IN shard_replication_factor integer (current_setting('citus.shard_replication_factor'::text))::integer
$3 IN max_shard_copies integer 1000000
$4 IN excluded_shard_list bigint[] '{}'::bigint[]
$5 IN shard_transfer_mode citus.shard_transfer_mode 'auto'::citus.shard_transfer_mode

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: role_exists (name)

returns whether a role exists

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN name

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: run_command_on_all_nodes (text, boolean, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text
$2 IN parallel boolean true
$3 IN give_warning_for_connection_errors boolean false
$4 OUT nodeid integer
$5 OUT success boolean
$6 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_colocated_placements (regclass, regclass, text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name1 regclass
$2 IN table_name2 regclass
$3 IN command text
$4 IN parallel boolean true
$5 OUT nodename text
$6 OUT nodeport integer
$7 OUT shardid1 bigint
$8 OUT shardid2 bigint
$9 OUT success boolean
$10 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_coordinator (text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text
$2 IN give_warning_for_connection_errors boolean false
$3 OUT nodeid integer
$4 OUT success boolean
$5 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_placements (regclass, text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN command text
$3 IN parallel boolean true
$4 OUT nodename text
$5 OUT nodeport integer
$6 OUT shardid bigint
$7 OUT success boolean
$8 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_shards (regclass, text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN command text
$3 IN parallel boolean true
$4 OUT shardid bigint
$5 OUT success boolean
$6 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: run_command_on_workers (text, boolean)

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN command text
$2 IN parallel boolean true
$3 OUT nodename text
$4 OUT nodeport integer
$5 OUT success boolean
$6 OUT result text

Function return type: SETOF record

Function attributes: ROWS 1000

Function: shard_name (regclass, bigint)

returns schema-qualified, shard-extended identifier of object name

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN object_name regclass
$2 IN shard_id bigint

Function return type: text

Function attributes: STABLE, RETURNS NULL ON NULL INPUT, COST 1

Function: start_metadata_sync_to_all_nodes()

sync metadata to all active primary nodes

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: start_metadata_sync_to_node (text, integer)

sync metadata to node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: stop_metadata_sync_to_node (text, integer, boolean)

stop metadata sync to node

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN nodename text
$2 IN nodeport integer
$3 IN clear_metadata boolean true

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: time_partition_range (regclass)

returns the start and end of partition boundaries

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 OUT lower_bound text
$3 OUT upper_bound text

Function return type: record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: truncate_local_data_after_distributing_table (regclass)

truncates local records of a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN function_name regclass

Function return type: void

Function attributes: COST 1

Function: undistribute_table (regclass, boolean)

undistributes a distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN cascade_via_foreign_keys boolean false

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: update_distributed_table_colocation (regclass, text)

updates colocation of a table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN colocate_with text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_inter_shard_ddl_command (bigint, text, bigint, text, text)

executes inter shard ddl command

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN referencing_shard bigint
$2 IN referencing_schema_name text
$3 IN referenced_shard bigint
$4 IN referenced_schema_name text
$5 IN command text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_sequence_command (text)

create a sequence which products globally unique values

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_sequence_command (text, regtype)

create a sequence which produces globally unique values

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN create_sequence_command text
$2 IN sequence_type_id regtype 'bigint'::regtype

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_apply_shard_ddl_command (bigint, text)

extend ddl command with shardId and apply on database

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint
$2 IN text

Function return type: void

Function: worker_apply_shard_ddl_command (bigint, text, text)

extend ddl command with shardId and apply on database

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN bigint
$2 IN text
$3 IN text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_change_sequence_dependency (regclass, regclass, regclass)

changes sequence's dependency from source table to target table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN sequence regclass
$2 IN source_table regclass
$3 IN target_table regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_copy_table_to_node (regclass, integer)

Perform copy of a shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN source_table regclass
$2 IN target_node_id integer

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_create_or_alter_role (text, text, text)

runs the create role query, if the role doesn't exists, runs the alter role query if it does

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN role_name text
$2 IN create_role_utility_query text
$3 IN alter_role_utility_query text

Function return type: boolean

Function attributes: COST 1

Function: worker_create_or_replace_object (text)

takes a sql CREATE statement, before executing the create it will check if an object with that name already exists and safely replaces that named object with the new object

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN statement text

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_create_or_replace_object (text[])

takes an array of sql statements, before executing these it will check if the object already exists in that exact state otherwise replaces that named object with the new object

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN statements text[]

Function return type: boolean

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_create_truncate_trigger (regclass)

create truncate trigger for distributed table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_drop_distributed_table (text)

drop the distributed table and its reference from metadata tables

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_drop_sequence_dependency (text)

drop the Citus tables sequence dependency

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_drop_shell_table (text)

drop the distributed table only without the metadata

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_fix_partition_shard_index_names (regclass, text, text)

fix the name of the index on given partition shard that is child of given parent_index

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN parent_shard_index regclass
$2 IN partition_shard text
$3 IN new_partition_shard_index_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_fix_pre_citus10_partitioned_table_constraint_names (regclass, bigint, text)

fix constraint names on partition shards on worker nodes

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN table_name regclass
$2 IN shardid bigint
$3 IN constraint_name text

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_hash ("any")

calculate hashed value and return it

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN value "any"

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_last_saved_explain_analyze()

Returns the saved explain analyze output for the last run query

Function return type: TABLE(explain_analyze_output text, execution_duration double precision)

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: worker_nextval (regclass)

calculates nextval() for column defaults of type int or smallint

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN sequence regclass

Function return type: integer

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_partial_agg (oid, anyelement)

support aggregate for implementing partial aggregation on workers

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN oid
$2 IN anyelement

Function return type: cstring

Function attributes: IMMUTABLE, COST 1

Function: worker_partial_agg_ffunc (internal)

finalizer for worker_partial_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal

Function return type: cstring

Function attributes: PARALLEL SAFE, COST 1

Function: worker_partial_agg_sfunc (internal, oid, anyelement)

transition function for worker_partial_agg

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN internal
$2 IN oid
$3 IN anyelement

Function return type: internal

Function attributes: PARALLEL SAFE, COST 1

Function: worker_partition_query_result (text, text, integer, citus.distribution_type, text[], text[], boolean, boolean, boolean)

execute a query and partitions its results in set of local result files

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN result_prefix text
$2 IN query text
$3 IN partition_column_index integer
$4 IN partition_method citus.distribution_type
$5 IN partition_min_values text[]
$6 IN partition_max_values text[]
$7 IN binary_copy boolean
$8 IN allow_null_partition_column boolean false
$9 IN generate_empty_results boolean false
$10 OUT partition_index integer
$11 OUT rows_written bigint
$12 OUT bytes_written bigint

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: worker_partitioned_relation_size (regclass)

Calculates and returns the size of a partitioned relation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: bigint

Function: worker_partitioned_relation_total_size (regclass)

Calculates and returns the total size of a partitioned relation

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: bigint

Function: worker_partitioned_table_size (regclass)

Calculates and returns the size of a partitioned table

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN relation regclass

Function return type: bigint

Function: worker_record_sequence_dependency (regclass, regclass, name)

record the fact that the sequence depends on the table in pg_depend

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN seq_name regclass
$2 IN table_name regclass
$3 IN column_name name

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_save_query_explain_analyze (text, jsonb)

Executes and returns results of query while saving its EXPLAIN ANALYZE to be fetched later

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN query text
$2 IN options jsonb

Function return type: SETOF record

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Function: worker_split_copy (bigint, text, split_copy_info[])

Perform split copy for shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN source_shard_id bigint
$2 IN distribution_column text
$3 IN splitcopyinfos split_copy_info[]

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_split_shard_release_dsm()

Releases shared memory segment allocated by non-blocking split workflow

Function return type: void

Function attributes: RETURNS NULL ON NULL INPUT, COST 1

Function: worker_split_shard_replication_setup (split_shard_info[], bigint)

Replication setup for splitting a shard

Function arguments:

Arg. # Arg. mode Argument name Argument type Default expression
$1 IN splitshardinfo split_shard_info[]
$2 IN operation_id bigint

Function return type: SETOF replication_slot_info

Function attributes: RETURNS NULL ON NULL INPUT, COST 1, ROWS 1000

Types

The following extra types have been defined besides the implicit composite types of the tables and views in this extension.

####Type: distribution_type

####Type: noderole

####Type: shard_transfer_mode

####Type: citus_copy_format

Composite type: split_copy_info

CREATE TYPE split_copy_info AS (
  destination_shard_id bigint,
  destination_shard_min_value text,
  destination_shard_max_value text,
  destination_shard_node_id integer
);

Composite type: split_shard_info

Stores split child shard information

CREATE TYPE split_shard_info AS (
  source_shard_id bigint,
  distribution_column text,
  child_shard_id bigint,
  shard_min_value text,
  shard_max_value text,
  node_id integer
);

Composite type: replication_slot_info

Replication slot information to be used for subscriptions during non blocking shard split

CREATE TYPE replication_slot_info AS (
  node_id integer,
  slot_owner text,
  slot_name text
);

####Type: citus_job_status

####Type: citus_task_status

####Type: cluster_clock

combination of (logical, counter): 42 bits + 22 bits Time: 229.016 ms

I ran diff 11.1.md 11.2.md > "difference between 11.1 and 11.2.diff" to generate the difference between the 2 generated markdown files.

4,5c4,5
< pg_extension_version: 11.1-1
< pg_readme_generated_at: 2023-01-30 17:35:52.80893+03
---
> pg_extension_version: 11.2-1
> pg_readme_generated_at: 2023-01-30 17:15:41.943399+03
23c23,29
< There are 16 tables that directly belong to the `citus` extension.
---
> There are 17 tables that directly belong to the `citus` extension.
> 
> #### Table: `tbl`
> 
> The `tbl` table has 1 attributes:
> 
> 1. `tbl.a` `my_schema.my_type`
988a995,1011
> #### Function: `citus_copy_shard_placement (bigint, integer, integer, citus.shard_transfer_mode)`
> 
> copy a shard from the source node to the destination node
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` | `shard_id`                                                        | `bigint`                                                             |  |
> |   `$2` |       `IN` | `source_node_id`                                                  | `integer`                                                            |  |
> |   `$3` |       `IN` | `target_node_id`                                                  | `integer`                                                            |  |
> |   `$4` |       `IN` | `transfer_mode`                                                   | `citus.shard_transfer_mode`                                          | `'auto'::citus.shard_transfer_mode` |
> 
> Function return type: `void`
> 
> Function attributes: `RETURNS NULL ON NULL INPUT`, COST 1
> 
1202a1226,1241
> #### Function: `citus_get_node_clock()`
> 
> Returns monotonically increasing timestamp with logical clock value as close to epoch value (in milli seconds) as possible, and a counter for ticks(maximum of 4 million) within the logical clock
> 
> Function return type: `cluster_clock`
> 
> Function attributes: `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `citus_get_transaction_clock()`
> 
> Returns a transaction timestamp logical clock
> 
> Function return type: `cluster_clock`
> 
> Function attributes: `RETURNS NULL ON NULL INPUT`, COST 1
> 
1292a1332,1348
> #### Function: `citus_internal_add_placement_metadata (bigint, bigint, integer, bigint)`
> 
> Inserts into pg_dist_shard_placement with user checks
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` | `shard_id`                                                        | `bigint`                                                             |  |
> |   `$2` |       `IN` | `shard_length`                                                    | `bigint`                                                             |  |
> |   `$3` |       `IN` | `group_id`                                                        | `integer`                                                            |  |
> |   `$4` |       `IN` | `placement_id`                                                    | `bigint`                                                             |  |
> 
> Function return type: `void`
> 
> Function attributes: `RETURNS NULL ON NULL INPUT`, COST 1
> 
1328a1385,1398
> #### Function: `citus_internal_adjust_local_clock_to_remote (cluster_clock)`
> 
> Internal UDF used to adjust the local clock to the maximum of nodes in the cluster
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `void`
> 
> Function attributes: `STABLE`, `RETURNS NULL ON NULL INPUT`, `PARALLEL SAFE`, COST 1
> 
1449a1520,1534
> #### Function: `citus_is_clock_after (cluster_clock, cluster_clock)`
> 
> Accepts logical clock timestamps of two causally related events and returns true if the argument1 happened before argument2
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` | `clock_one`                                                       | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` | `clock_two`                                                       | `cluster_clock`                                                      |  |
> 
> Function return type: `boolean`
> 
> Function attributes: `STABLE`, `RETURNS NULL ON NULL INPUT`, `PARALLEL SAFE`, COST 1
> 
1482a1568,1593
> #### Function: `citus_job_list()`
> 
> Function return type: `TABLE(job_id bigint, state citus_job_status, job_type name, description text, started_at timestamp with time zone, finished_at timestamp with time zone)`
> 
> Function attributes: ROWS 1000
> 
> #### Function: `citus_job_status (bigint, boolean)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` | `job_id`                                                          | `bigint`                                                             |  |
> |   `$2` |       `IN` | `raw`                                                             | `boolean`                                                            | `false` |
> |   `$3` |    `TABLE` | `job_id`                                                          | `bigint`                                                             |  |
> |   `$4` |    `TABLE` | `state`                                                           | `citus_job_status`                                                   |  |
> |   `$5` |    `TABLE` | `job_type`                                                        | `name`                                                               |  |
> |   `$6` |    `TABLE` | `description`                                                     | `text`                                                               |  |
> |   `$7` |    `TABLE` | `started_at`                                                      | `timestamp with time zone`                                           |  |
> |   `$8` |    `TABLE` | `finished_at`                                                     | `timestamp with time zone`                                           |  |
> |   `$9` |    `TABLE` | `details`                                                         | `jsonb`                                                              |  |
> 
> Function return type: `TABLE(job_id bigint, state citus_job_status, job_type name, description text, started_at timestamp with time zone, finished_at timestamp with time zone, details jsonb)`
> 
> Function attributes: `RETURNS NULL ON NULL INPUT`, ROWS 1000
> 
1584a1696,1712
> #### Function: `citus_move_shard_placement (bigint, integer, integer, citus.shard_transfer_mode)`
> 
> move a shard from the source node to the destination node
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` | `shard_id`                                                        | `bigint`                                                             |  |
> |   `$2` |       `IN` | `source_node_id`                                                  | `integer`                                                            |  |
> |   `$3` |       `IN` | `target_node_id`                                                  | `integer`                                                            |  |
> |   `$4` |       `IN` | `transfer_mode`                                                   | `citus.shard_transfer_mode`                                          | `'auto'::citus.shard_transfer_mode` |
> 
> Function return type: `void`
> 
> Function attributes: `RETURNS NULL ON NULL INPUT`, COST 1
> 
1714a1843,1861
> #### Function: `citus_rebalance_status (boolean)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` | `raw`                                                             | `boolean`                                                            | `false` |
> |   `$2` |    `TABLE` | `job_id`                                                          | `bigint`                                                             |  |
> |   `$3` |    `TABLE` | `state`                                                           | `citus_job_status`                                                   |  |
> |   `$4` |    `TABLE` | `job_type`                                                        | `name`                                                               |  |
> |   `$5` |    `TABLE` | `description`                                                     | `text`                                                               |  |
> |   `$6` |    `TABLE` | `started_at`                                                      | `timestamp with time zone`                                           |  |
> |   `$7` |    `TABLE` | `finished_at`                                                     | `timestamp with time zone`                                           |  |
> |   `$8` |    `TABLE` | `details`                                                         | `jsonb`                                                              |  |
> 
> Function return type: `TABLE(job_id bigint, state citus_job_status, job_type name, description text, started_at timestamp with time zone, finished_at timestamp with time zone, details jsonb)`
> 
> Function attributes: `RETURNS NULL ON NULL INPUT`, ROWS 1000
> 
2042a2190,2204
> #### Function: `citus_task_wait (bigint, citus_task_status)`
> 
> blocks till the task identified by taskid is at the specified status, or reached a terminal status. Only waits for terminal status when no desired_status was specified. The return value indicates if the desired status was reached or not. When no desired status was specified it will assume any terminal status was desired
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` | `taskid`                                                          | `bigint`                                                             |  |
> |   `$2` |       `IN` | `desired_status`                                                  | `citus_task_status`                                                  | `NULL::citus_task_status` |
> 
> Function return type: `void`
> 
> Function attributes: COST 1
> 
2163a2326,2476
> #### Function: `cluster_clock_cmp (cluster_clock, cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `integer`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_eq (cluster_clock, cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `boolean`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_ge (cluster_clock, cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `boolean`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_gt (cluster_clock, cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `boolean`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_in (cstring)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cstring`                                                            |  |
> 
> Function return type: `cluster_clock`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_le (cluster_clock, cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `boolean`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_logical (cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `bigint`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_lt (cluster_clock, cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `boolean`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_ne (cluster_clock, cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> |   `$2` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `boolean`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_out (cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `cstring`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_recv (internal)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `internal`                                                           |  |
> 
> Function return type: `cluster_clock`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
> #### Function: `cluster_clock_send (cluster_clock)`
> 
> Function arguments:
> 
> | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
> | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
> |   `$1` |       `IN` |                                                                   | `cluster_clock`                                                      |  |
> 
> Function return type: `bytea`
> 
> Function attributes: `IMMUTABLE`, `RETURNS NULL ON NULL INPUT`, COST 1
> 
2585c2898
< Function return type: `TABLE(sessionid integer, table_name regclass, shardid bigint, shard_size bigint, sourcename text, sourceport integer, targetname text, targetport integer, progress bigint, source_shard_size bigint, target_shard_size bigint, operation_type text)`
---
> Function return type: `TABLE(sessionid integer, table_name regclass, shardid bigint, shard_size bigint, sourcename text, sourceport integer, targetname text, targetport integer, progress bigint, source_shard_size bigint, target_shard_size bigint, operation_type text, source_lsn pg_lsn, target_lsn pg_lsn, status text)`
3461,3477d3773
< #### Function: `worker_append_table_to_shard (text, text, text, integer)`
< 
< append a regular table's contents to the shard
< 
< Function arguments:
< 
< | Arg. # | Arg. mode  | Argument name                                                     | Argument type                                                        | Default expression  |
< | ------ | ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------- |
< |   `$1` |       `IN` |                                                                   | `text`                                                               |  |
< |   `$2` |       `IN` |                                                                   | `text`                                                               |  |
< |   `$3` |       `IN` |                                                                   | `text`                                                               |  |
< |   `$4` |       `IN` |                                                                   | `integer`                                                            |  |
< 
< Function return type: `void`
< 
< Function attributes: `RETURNS NULL ON NULL INPUT`, COST 1
< 
3914c4210
< #### Function: `worker_split_shard_replication_setup (split_shard_info[])`
---
> #### Function: `worker_split_shard_replication_setup (split_shard_info[], bigint)`
3922a4219
> |   `$2` |       `IN` | `operation_id`                                                    | `bigint`                                                             |  |
3980a4278,4282
> 
> ####Type: `cluster_clock`
> 
> combination of (logical, counter): 42 bits + 22 bits
> Time: 229.016 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment