citus/src/backend/distributed/commands
Philip Dubé 78767c9a7d
Fix create_distributed_table on a table using GENERATED ALWAYS AS
If the generated column does not come at the end of the column list,
columnNameList doesn't line up with the column indexes. Seek past

CREATE TABLE test_table (
    test_id int PRIMARY KEY,
    gen_n int GENERATED ALWAYS AS (1) STORED,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
SELECT create_distributed_table('test_table', 'test_id');

Would raise ERROR: cannot cast 23 to 1184

(cherry picked from commit 34f241af16)
2020-05-12 16:02:23 +03:00
..
README.md Fix misc typos 2019-05-23 17:23:27 -07:00
call.c Feedback 2019-09-24 17:31:09 +00:00
cluster.c Description: Refactor code that handles DDL commands from one file into a module 2018-11-14 13:36:27 +01:00
create_distributed_table.c Change citus truncate trigger to AFTER and add more upgrade tests (#3070) 2019-10-07 16:43:04 +02:00
dependencies.c Sync metadata to worker nodes after create_distributed_function 2019-09-23 18:30:53 +02:00
drop_distributed_table.c Make sure to prevent unauthorized users to drop tables in Citus MX 2018-11-15 18:07:03 +03:00
extension.c Description: Refactor code that handles DDL commands from one file into a module 2018-11-14 13:36:27 +01:00
foreign_constraint.c Fix up includes with pg12 changes 2019-08-22 18:56:21 +00:00
function.c Disallow distributed functions with distribution arguments unless replication_model is streaming 2019-11-11 14:52:57 +01:00
grant.c Description: Refactor code that handles DDL commands from one file into a module 2018-11-14 13:36:27 +01:00
index.c PG_VERSION_NUM > 110000 should be PG_VERSION_NUM >= 110000 2019-09-30 23:37:43 +00:00
multi_copy.c Fix create_distributed_table on a table using GENERATED ALWAYS AS 2020-05-12 16:02:23 +03:00
policy.c Description: Refactor code that handles DDL commands from one file into a module 2018-11-14 13:36:27 +01:00
rename.c Propagate more ALTER FOREIGN TABLE to workers 2019-05-24 12:54:05 -07:00
schema.c PG_VERSION_NUM > 110000 should be PG_VERSION_NUM >= 110000 2019-09-30 23:37:43 +00:00
sequence.c Fix up includes with pg12 changes 2019-08-22 18:56:21 +00:00
subscription.c Fix up includes with pg12 changes 2019-08-22 18:56:21 +00:00
table.c Distribute Types to worker nodes (#2893) 2019-09-13 17:46:07 +02:00
transmit.c Implement FileCompat to abstract pg12 requiring API consumer to track file offsets 2019-08-22 18:57:47 +00:00
truncate.c ActivePrimaryNodeList: add lockMode parameter 2019-09-13 17:44:56 +00:00
type.c Fix enum add value order and pg12 (#3082) 2019-10-07 17:16:19 +02:00
utility_hook.c PG_VERSION_NUM > 110000 should be PG_VERSION_NUM >= 110000 2019-09-30 23:37:43 +00:00
vacuum.c Update commands/vacuum.c with pg12 changes 2019-08-22 18:56:54 +00:00
variableset.c Fix Assert() in ProcessVariableSetStmt() 2019-07-05 14:11:22 -07:00

README.md

Commands

The commands module is modeled after backend/commands from the postgres repository and contains the logic for Citus on how to run these commands on distributed objects. Even though the structure of the directory has some resemblence to its postgres relative, files here are somewhat more fine-grained. This is due to the nature of citus commands that are heavily focused on distributed tables. Instead of having all commands in tablecmds.c they are often moved to files that are named after the command.

File Description
create_distributed_table.c Implementation of UDF's for creating distributed tables
drop_distributed_table.c Implementation for dropping metadata for partitions of distributed tables
extension.c Implementation of CREATE EXTENSION commands for citus specific checks
foreign_constraint.c Implementation of helper functions for foreign key constraints
grant.c Placeholder for code granting users access to relations, implemented as enterprise feature
index.c Implementation of commands specific to indices on distributed tables
multi_copy.c Implementation of COPY command. There are multiple different copy modes which are described in detail below
policy.c Implementation of CREATE\ALTER POLICY commands.
rename.c Implementation of ALTER ... RENAME ... commands. It implements the renaming of applicable objects, otherwise provides the user with a warning
schema.c
sequence.c Implementation of CREATE/ALTER SEQUENCE commands. Primarily checks correctness of sequence statements as they are not propagated to the worker nodes
table.c
transmit.c Implementation of COPY commands with format transmit set in the options. This format is used to transfer files from one node to another node
truncate.c Implementation of TRUNCATE commands on distributed tables
utility_hook.c This is the entry point from postgres into the commands module of citus. It contains the implementation that gets registered in postgres' ProcessUtility_hook callback to extends the functionality of the original ProcessUtility. This code is used to route the incomming commands to their respective implementation in Citus
vacuum.c Implementation of VACUUM commands on distributed tables

COPY

The copy command is overloaded for a couple of use-cases specific to citus. The syntax of the command stays the same, however the implementation might slightly differ from the stock implementation. The overloading is mostly done via extra options that Citus uses to indicate how to operate the copy. The options used are described below.

FORMAT transmit

Implemented in transmit.c

TODO: to be written by someone with enough knowledge to write how, when and why it is used.

FORMAT result

Implemented in multi_copy.c

TODO: to be written by someone with enough knowledge to write how, when and why it is used.

MASTER_HOST host

Implemented in multi_copy.c

Triggered by the MASTER_HOST option being set on the copy command. Also accepts MASTER_PORT

TODO: to be written by someone with enough knowledge to write how, when and why it is used.