Merge pull request #4573 from citusdata/rename-create_citus_local_table

Rename create_citus_local_table to citus_add_local_table_to_metadata
pull/4590/head^2
Onur Tirtir 2021-01-27 17:45:46 +03:00 committed by GitHub
commit a18d4288e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 344 additions and 319 deletions

View File

@ -405,7 +405,7 @@ ExecuteCascadeOperationForRelationIdList(List *relationIdList,
break;
}
case CASCADE_FKEY_CREATE_CITUS_LOCAL_TABLE:
case CASCADE_FKEY_ADD_LOCAL_TABLE_TO_METADATA:
{
if (!IsCitusTable(relationId))
{

View File

@ -1,12 +1,17 @@
/*-------------------------------------------------------------------------
*
* create_citus_local_table.c
* citus_add_local_table_to_metadata.c
*
* This file contains functions to create citus local tables.
* This file contains functions to add local table to citus metadata.
*
* A citus local table is composed of a shell relation to wrap the
* A local table added to metadata is composed of a shell relation to wrap the
* the regular postgres relation as its coordinator local shard.
*
* As we want to hide "citus local table" concept from users, we renamed
* udf and re-branded that concept as "local tables added to metadata".
* Note that we might still call this local table concept as "citus local" in
* many places of the code base.
*
* Copyright (c) Citus Data, Inc.
*
*-------------------------------------------------------------------------
@ -70,17 +75,18 @@ static void InsertMetadataForCitusLocalTable(Oid citusLocalTableId, uint64 shard
static void FinalizeCitusLocalTableCreation(Oid relationId);
PG_FUNCTION_INFO_V1(citus_add_local_table_to_metadata);
PG_FUNCTION_INFO_V1(create_citus_local_table);
PG_FUNCTION_INFO_V1(remove_local_tables_from_metadata);
/*
* create_citus_local_table creates a citus local table from the table with
* citus_add_local_table_to_metadata creates a citus local table from the table with
* relationId by executing the internal method CreateCitusLocalTable.
* (See CreateCitusLocalTable function's comment.)
*/
Datum
create_citus_local_table(PG_FUNCTION_ARGS)
citus_add_local_table_to_metadata(PG_FUNCTION_ARGS)
{
CheckCitusVersion(ERROR);
@ -109,6 +115,23 @@ create_citus_local_table(PG_FUNCTION_ARGS)
}
/*
* create_citus_local_table is a wrapper function for old name of
* of citus_add_local_table_to_metadata.
*
* The only reason for having this udf in citus binary is to make
* multi_extension test happy as it uses this udf when testing the
* downgrade scenario from 9.5 to 9.4.
*/
Datum
create_citus_local_table(PG_FUNCTION_ARGS)
{
ereport(NOTICE, (errmsg("create_citus_local_table is deprecated in favour of "
"citus_add_local_table_to_metadata")));
return citus_add_local_table_to_metadata(fcinfo);
}
/*
* remove_local_tables_from_metadata undistributes citus local
* tables that are not chained with any reference tables via foreign keys.
@ -148,7 +171,7 @@ CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys)
EnsureCoordinator();
EnsureTableOwner(relationId);
/* enable create_citus_local_table on an empty node */
/* enable citus_add_local_table_to_metadata on an empty node */
InsertCoordinatorIfClusterEmpty();
/*
@ -189,7 +212,7 @@ CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys)
* on the relations.
*/
CascadeOperationForConnectedRelations(relationId, lockMode,
CASCADE_FKEY_CREATE_CITUS_LOCAL_TABLE);
CASCADE_FKEY_ADD_LOCAL_TABLE_TO_METADATA);
/*
* We converted every foreign key connected table in our subgraph
@ -211,7 +234,7 @@ CreateCitusLocalTable(Oid relationId, bool cascadeViaForeignKeys)
errhint("Use cascade_via_foreign_keys option to add "
"all the relations involved in a foreign key "
"relationship with %s to citus metadata by "
"executing SELECT create_citus_local_table($$%s$$, "
"executing SELECT citus_add_local_table_to_metadata($$%s$$, "
"cascade_via_foreign_keys=>true)",
qualifiedRelationName, qualifiedRelationName)));
}
@ -296,7 +319,7 @@ ErrorIfUnsupportedCreateCitusLocalTable(Relation relation)
* EnsureTableNotDistributed already errors out if the given relation implies
* a citus table. However, as we don't mark the relation as citus table, i.e we
* do not use the relation with relationId as the shell relation, parallel
* create_citus_local_table executions would not error out for that relation.
* citus_add_local_table_to_metadata executions would not error out for that relation.
* Hence we need to error out for shard relations too.
*/
ErrorIfRelationIsAKnownShard(relationId);

View File

@ -436,7 +436,7 @@ ErrorOutForFKeyBetweenPostgresAndCitusLocalTable(Oid localTableId)
errmsg("cannot create foreign key constraint as \"%s\" is "
"a postgres local table", localTableName),
errhint("first add local table to citus metadata "
"by using SELECT create_citus_local_table('%s') "
"by using SELECT citus_add_local_table_to_metadata('%s') "
"and execute the ALTER TABLE command to create the "
"foreign key to local table", localTableName)));
}

View File

@ -789,7 +789,7 @@ ShouldUndistributeCitusLocalTables(void)
{
/*
* If foreign keys between reference tables and local tables are
* disabled, then user might be using create_citus_local_table for
* disabled, then user might be using citus_add_local_table_to_metadata for
* their own purposes. In that case, we should not undistribute
* citus local tables.
*/

View File

@ -23,7 +23,7 @@ DROP FUNCTION pg_catalog.alter_distributed_table(regclass, text, int, text, bool
DROP FUNCTION pg_catalog.alter_table_set_access_method(regclass, text);
DROP FUNCTION pg_catalog.citus_total_relation_size(regclass,boolean);
DROP FUNCTION pg_catalog.undistribute_table(regclass,boolean);
DROP FUNCTION pg_catalog.create_citus_local_table(regclass,boolean);
DROP FUNCTION pg_catalog.citus_add_local_table_to_metadata(regclass,boolean);
DROP FUNCTION pg_catalog.citus_add_node(text, integer, integer, noderole, name);
DROP FUNCTION pg_catalog.citus_activate_node(text, integer);
DROP FUNCTION pg_catalog.citus_add_inactive_node(text, integer, integer, noderole, name);

View File

@ -1,7 +1,7 @@
DROP FUNCTION pg_catalog.create_citus_local_table(regclass);
CREATE OR REPLACE FUNCTION pg_catalog.create_citus_local_table(table_name regclass, cascade_via_foreign_keys boolean default false)
CREATE OR REPLACE FUNCTION pg_catalog.citus_add_local_table_to_metadata(table_name regclass, cascade_via_foreign_keys boolean default false)
RETURNS void
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$create_citus_local_table$$;
COMMENT ON FUNCTION pg_catalog.create_citus_local_table(table_name regclass, cascade_via_foreign_keys boolean)
AS 'MODULE_PATHNAME', $$citus_add_local_table_to_metadata$$;
COMMENT ON FUNCTION pg_catalog.citus_add_local_table_to_metadata(table_name regclass, cascade_via_foreign_keys boolean)
IS 'create a citus local table';

View File

@ -1,7 +1,7 @@
DROP FUNCTION pg_catalog.create_citus_local_table(regclass);
CREATE OR REPLACE FUNCTION pg_catalog.create_citus_local_table(table_name regclass, cascade_via_foreign_keys boolean default false)
CREATE OR REPLACE FUNCTION pg_catalog.citus_add_local_table_to_metadata(table_name regclass, cascade_via_foreign_keys boolean default false)
RETURNS void
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$create_citus_local_table$$;
COMMENT ON FUNCTION pg_catalog.create_citus_local_table(table_name regclass, cascade_via_foreign_keys boolean)
AS 'MODULE_PATHNAME', $$citus_add_local_table_to_metadata$$;
COMMENT ON FUNCTION pg_catalog.citus_add_local_table_to_metadata(table_name regclass, cascade_via_foreign_keys boolean)
IS 'create a citus local table';

View File

@ -476,7 +476,7 @@ typedef enum CascadeOperationType
CASCADE_FKEY_UNDISTRIBUTE_TABLE = 1 << 1,
/* execute CreateCitusLocalTable on each relation */
CASCADE_FKEY_CREATE_CITUS_LOCAL_TABLE = 1 << 2,
CASCADE_FKEY_ADD_LOCAL_TABLE_TO_METADATA = 1 << 2,
} CascadeOperationType;
extern void CascadeOperationForConnectedRelations(Oid relationId, LOCKMODE relLockMode,

View File

@ -353,8 +353,8 @@ SELECT create_reference_table('table_type_ref');
(1 row)
CREATE TABLE table_type_citus_local(a INT);
SELECT create_citus_local_table('table_type_citus_local');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('table_type_citus_local');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -13,8 +13,8 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
-- show that DROP CONSTRAINT cascades to undistributing citus_local_table
CREATE TABLE citus_local_table(l1 int);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -3,8 +3,8 @@ SET search_path TO citus_local_dist_joins;
SET client_min_messages to ERROR;
SELECT master_add_node('localhost', :master_port, groupId => 0) AS coordinator_nodeid \gset
CREATE TABLE citus_local(key int, value text);
SELECT create_citus_local_table('citus_local');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -369,8 +369,8 @@ ERROR: relation "no_such_relation" does not exist
-- create test tables and some foreign key relationships between them to see
-- that triggers are properly handled when ddl cascades to referencing table
CREATE TABLE another_citus_local_table (value int unique);
SELECT create_citus_local_table('another_citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('another_citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -19,8 +19,8 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
RESET client_min_messages;
CREATE TABLE citus_local_table_1 (a int);
-- this should work as coordinator is added to pg_dist_node
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -39,7 +39,7 @@ SELECT 1 FROM master_remove_node('localhost', :master_port);
CREATE TABLE citus_local_table_1 (a int primary key);
-- this should fail as coordinator is removed from pg_dist_node
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
ERROR: could not find the coordinator node in metadata as it is not added as a worker
-- let coordinator have citus local tables again for next tests
set client_min_messages to ERROR;
@ -51,8 +51,8 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
RESET client_min_messages;
-- creating citus local table having no data initially would work
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -60,8 +60,8 @@ SELECT create_citus_local_table('citus_local_table_1');
-- creating citus local table having data in it would also work
CREATE TABLE citus_local_table_2(a int primary key);
INSERT INTO citus_local_table_2 VALUES(1);
SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -79,8 +79,8 @@ NOTICE: executing the command locally: DROP TABLE IF EXISTS citus_local_tables_
-- .. for an initially empty table
CREATE TABLE citus_local_table_1(a int);
CREATE INDEX citus_local_table_1_idx ON citus_local_table_1(a);
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -89,8 +89,8 @@ SELECT create_citus_local_table('citus_local_table_1');
CREATE TABLE citus_local_table_2(a int);
INSERT INTO citus_local_table_2 VALUES(1);
CREATE INDEX citus_local_table_2_idx ON citus_local_table_2(a);
SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -103,25 +103,25 @@ SELECT create_distributed_table('distributed_table', 'a');
(1 row)
-- cannot create citus local table from an existing citus table
SELECT create_citus_local_table('distributed_table');
SELECT citus_add_local_table_to_metadata('distributed_table');
ERROR: table "distributed_table" is already distributed
-- partitioned table tests --
CREATE TABLE partitioned_table(a int, b int) PARTITION BY RANGE (a);
CREATE TABLE partitioned_table_1 PARTITION OF partitioned_table FOR VALUES FROM (0) TO (10);
CREATE TABLE partitioned_table_2 PARTITION OF partitioned_table FOR VALUES FROM (10) TO (20);
-- cannot create partitioned citus local tables
SELECT create_citus_local_table('partitioned_table');
SELECT citus_add_local_table_to_metadata('partitioned_table');
ERROR: cannot add local table "partitioned_table" to metadata, only regular tables and foreign tables can be added to citus metadata
BEGIN;
CREATE TABLE citus_local_table PARTITION OF partitioned_table FOR VALUES FROM (20) TO (30);
-- cannot create citus local table as a partition of a local table
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
ERROR: cannot add local table "citus_local_table" to metadata, local tables added to metadata cannot be partition of other tables
ROLLBACK;
BEGIN;
CREATE TABLE citus_local_table (a int, b int);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -139,8 +139,8 @@ BEGIN;
(1 row)
CREATE TABLE citus_local_table (a int, b int);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -153,14 +153,14 @@ ROLLBACK;
CREATE TABLE parent_table (a int, b text);
CREATE TABLE child_table () INHERITS (parent_table);
-- both of below should error out
SELECT create_citus_local_table('parent_table');
SELECT citus_add_local_table_to_metadata('parent_table');
ERROR: cannot add local table "parent_table" to metadata, local tables added to metadata cannot be involved in inheritance relationships
SELECT create_citus_local_table('child_table');
SELECT citus_add_local_table_to_metadata('child_table');
ERROR: cannot add local table "child_table" to metadata, local tables added to metadata cannot be involved in inheritance relationships
-- show that we support UNLOGGED tables --
CREATE UNLOGGED TABLE unlogged_table (a int primary key);
SELECT create_citus_local_table('unlogged_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('unlogged_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -178,8 +178,8 @@ BEGIN;
CREATE TRIGGER insert_trigger
AFTER INSERT ON citus_local_table_3
FOR EACH STATEMENT EXECUTE FUNCTION update_value();
SELECT create_citus_local_table('citus_local_table_3');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -205,15 +205,15 @@ NOTICE: not propagating CREATE ROLE/USER commands to worker nodes
CREATE POLICY table_policy ON citus_local_table_3 TO table_users
USING (table_user = current_user);
-- this should error out
SELECT create_citus_local_table('citus_local_table_3');
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
ERROR: policies on distributed tables are only supported in Citus Enterprise
ROLLBACK;
-- show that we properly handle sequences on citus local tables --
BEGIN;
CREATE SEQUENCE col3_seq;
CREATE TABLE citus_local_table_3 (col1 serial, col2 int, col3 int DEFAULT nextval('col3_seq'));
SELECT create_citus_local_table('citus_local_table_3');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -250,11 +250,11 @@ CREATE FOREIGN TABLE foreign_table (
) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true');
-- observe that we do not create fdw server for shell table, both shard relation
-- & shell relation points to the same same server object
SELECT create_citus_local_table('foreign_table');
SELECT citus_add_local_table_to_metadata('foreign_table');
NOTICE: foreign-data wrapper "fake_fdw" does not have an extension defined
NOTICE: server "fake_fdw_server" already exists, skipping
NOTICE: foreign-data wrapper "fake_fdw" does not have an extension defined
create_citus_local_table
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -267,15 +267,15 @@ NOTICE: executing the command locally: DROP TABLE IF EXISTS citus_local_tables_
NOTICE: executing the command locally: DROP TABLE IF EXISTS citus_local_tables_test_schema.citus_local_table_1_xxxxx CASCADE
-- create test tables
CREATE TABLE citus_local_table_1 (a int primary key);
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
CREATE TABLE citus_local_table_2 (a int primary key);
SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -350,13 +350,13 @@ CREATE TABLE local_table_2 (a int primary key references local_table_1(a));
CREATE TABLE local_table_3 (a int primary key, b int references local_table_3(a));
-- below two should fail as we do not allow foreign keys between
-- postgres local tables and citus local tables
SELECT create_citus_local_table('local_table_1');
SELECT citus_add_local_table_to_metadata('local_table_1');
ERROR: relation citus_local_tables_test_schema.local_table_1 is involved in a foreign key relationship with another table
SELECT create_citus_local_table('local_table_2');
SELECT citus_add_local_table_to_metadata('local_table_2');
ERROR: relation citus_local_tables_test_schema.local_table_2 is involved in a foreign key relationship with another table
-- below should work as we allow initial self references in citus local tables
SELECT create_citus_local_table('local_table_3');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_3');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -368,8 +368,8 @@ CREATE SCHEMA "CiTUS!LocalTables";
-- create table with weird names
CREATE TABLE "CiTUS!LocalTables"."LocalTabLE.1!?!"(id int, "TeNANt_Id" int);
-- should work
SELECT create_citus_local_table('"CiTUS!LocalTables"."LocalTabLE.1!?!"');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('"CiTUS!LocalTables"."LocalTabLE.1!?!"');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -391,22 +391,22 @@ CREATE TABLE "LocalTabLE.1!?!"(
price numeric CHECK (price > 0),
serial_data bigserial, UNIQUE (id, price),
EXCLUDE USING GIST (name WITH =));
-- create some objects before create_citus_local_table
-- create some objects before citus_add_local_table_to_metadata
CREATE INDEX "my!Index1" ON "LocalTabLE.1!?!"(id) WITH ( fillfactor = 80 ) WHERE id > 10;
CREATE UNIQUE INDEX uniqueIndex ON "LocalTabLE.1!?!" (id);
-- ingest some data before create_citus_local_table
-- ingest some data before citus_add_local_table_to_metadata
INSERT INTO "LocalTabLE.1!?!" VALUES (1, 1, (1, row_to_json(row(1,1)))::local_type, row_to_json(row(1,1), true)),
(2, 1, (2, row_to_json(row(2,2)))::local_type, row_to_json(row(2,2), 'false'));
-- create a replica identity before create_citus_local_table
-- create a replica identity before citus_add_local_table_to_metadata
ALTER TABLE "LocalTabLE.1!?!" REPLICA IDENTITY USING INDEX uniqueIndex;
-- this shouldn't give any syntax errors
SELECT create_citus_local_table('"LocalTabLE.1!?!"');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('"LocalTabLE.1!?!"');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
-- create some objects after create_citus_local_table
-- create some objects after citus_add_local_table_to_metadata
CREATE INDEX "my!Index2" ON "LocalTabLE.1!?!"(id) WITH ( fillfactor = 90 ) WHERE id < 20;
NOTICE: executing the command locally: CREATE INDEX "my!Index2_1504036" ON "CiTUS!LocalTables"."LocalTabLE.1!?!_1504036" USING btree (id ) WITH (fillfactor = '90' )WHERE (id < 20)
CREATE UNIQUE INDEX uniqueIndex2 ON "LocalTabLE.1!?!"(id);
@ -570,8 +570,8 @@ NOTICE: executing the command locally: DROP TABLE IF EXISTS citus_local_tables_
NOTICE: executing the command locally: DROP TABLE IF EXISTS citus_local_tables_test_schema.citus_local_table_1_xxxxx CASCADE
-- test some other udf's with citus local tables
CREATE TABLE citus_local_table_4(a int);
SELECT create_citus_local_table('citus_local_table_4');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_4');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -729,18 +729,18 @@ FROM (SELECT tableName FROM pg_catalog.pg_tables WHERE tablename LIKE 'citus_loc
(1 row)
-- cannot create a citus local table from a catalog table
SELECT create_citus_local_table('pg_class');
SELECT citus_add_local_table_to_metadata('pg_class');
ERROR: cannot create a citus table from a catalog table
CREATE TABLE referencing_table(a int);
SELECT create_citus_local_table('referencing_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('referencing_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
CREATE TABLE referenced_table(a int UNIQUE);
SELECT create_citus_local_table('referenced_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('referenced_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -18,8 +18,8 @@ RESET client_min_messages;
-- triggers --
---------------------------------------------------------------------
CREATE TABLE citus_local_table (value int);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -90,8 +90,8 @@ FOR EACH STATEMENT EXECUTE FUNCTION another_dummy_function();
-- create some test tables before next three sections
-- and define some foreign keys between them
CREATE TABLE citus_local_table_1(l1 int);
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -106,8 +106,8 @@ SELECT create_reference_table('reference_table_1');
ALTER TABLE citus_local_table_1 ADD CONSTRAINT fkey_local_to_ref FOREIGN KEY(l1) REFERENCES reference_table_1(r1) ON DELETE CASCADE;
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1508001, 'citus_local_tables_mx', 1508002, 'citus_local_tables_mx', 'ALTER TABLE citus_local_table_1 ADD CONSTRAINT fkey_local_to_ref FOREIGN KEY(l1) REFERENCES reference_table_1(r1) ON DELETE CASCADE;')
CREATE TABLE citus_local_table_2(l1 int primary key);
SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -122,15 +122,15 @@ SELECT create_reference_table('reference_table_2');
ALTER TABLE reference_table_2 ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(r1) REFERENCES citus_local_table_2(l1) ON DELETE RESTRICT;
NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1508004, 'citus_local_tables_mx', 1508003, 'citus_local_tables_mx', 'ALTER TABLE reference_table_2 ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(r1) REFERENCES citus_local_table_2(l1) ON DELETE RESTRICT;')
CREATE TABLE citus_local_table_3(l1 int);
SELECT create_citus_local_table('citus_local_table_3');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
CREATE TABLE citus_local_table_4(l1 int primary key);
SELECT create_citus_local_table('citus_local_table_4');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_4');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -140,8 +140,8 @@ NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_comm
-- check stats creation
CREATE TABLE citus_local_table_stats(a int, b int);
CREATE STATISTICS stx1 ON a, b FROM citus_local_table_stats;
SELECT create_citus_local_table('citus_local_table_stats');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_stats');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -221,7 +221,7 @@ ERROR: operation is not allowed on this node
-- check stats creation
CREATE TABLE citus_local_table_stats2(a int, b int);
CREATE STATISTICS stx8 ON a, b FROM citus_local_table_stats2;
SELECT create_citus_local_table('citus_local_table_stats2');
SELECT citus_add_local_table_to_metadata('citus_local_table_stats2');
ERROR: operation is not allowed on this node
CREATE STATISTICS stx9 ON a, b FROM citus_local_table_stats2;
DROP STATISTICS stx8;

View File

@ -837,8 +837,8 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
(1 row)
CREATE TABLE table_option_citus_local (a int, b text) USING columnar;
SELECT create_citus_local_table('table_option_citus_local');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('table_option_citus_local');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -1023,8 +1023,8 @@ SELECT alter_columnar_table_set('table_option_citus_local_2',
(1 row)
SELECT create_citus_local_table('table_option_citus_local_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('table_option_citus_local_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -1,8 +1,8 @@
\set VERBOSITY terse
SET citus.next_shard_id TO 1516000;
SET citus.shard_replication_factor TO 1;
CREATE SCHEMA create_citus_local_table_cascade;
SET search_path TO create_citus_local_table_cascade;
CREATE SCHEMA citus_add_local_table_to_metadata_cascade;
SET search_path TO citus_add_local_table_to_metadata_cascade;
SET client_min_messages to ERROR;
-- ensure that coordinator is added to pg_dist_node
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
@ -29,18 +29,18 @@ ALTER TABLE local_table_1 ADD CONSTRAINT fkey_4 FOREIGN KEY (col_1) REFERENCES l
ALTER TABLE local_table_4 ADD CONSTRAINT fkey_5 FOREIGN KEY (col_1) REFERENCES local_table_3(col_1);
ALTER TABLE local_table_4 ADD CONSTRAINT fkey_6 FOREIGN KEY (col_1) REFERENCES local_table_4(col_1);
-- show that all of below fails as we didn't provide cascade_via_foreign_keys=true
SELECT create_citus_local_table('local_table_1');
ERROR: relation create_citus_local_table_cascade.local_table_1 is involved in a foreign key relationship with another table
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>false);
ERROR: relation create_citus_local_table_cascade.local_table_4 is involved in a foreign key relationship with another table
SELECT citus_add_local_table_to_metadata('local_table_1');
ERROR: relation citus_add_local_table_to_metadata_cascade.local_table_1 is involved in a foreign key relationship with another table
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>false);
ERROR: relation citus_add_local_table_to_metadata_cascade.local_table_4 is involved in a foreign key relationship with another table
-- In each of below two transaction blocks, show that we preserve foreign keys.
-- Also show that we converted all local_table_xxx tables in current schema
-- to citus local tables after create_citus_local_table (cascade).
-- to citus local tables after citus_add_local_table_to_metadata (cascade).
-- So in each transaction, both selects should return true.
BEGIN;
SELECT conname, conrelid::regclass::text, confrelid::regclass::text
FROM pg_constraint
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='create_citus_local_table_cascade') AND
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='citus_add_local_table_to_metadata_cascade') AND
conname ~ '^fkey\_\d+$'
ORDER BY 1,2,3;
conname | conrelid | confrelid
@ -53,8 +53,8 @@ BEGIN;
fkey_6 | local_table_4 | local_table_4
(6 rows)
SELECT create_citus_local_table('local_table_1', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_1', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -68,7 +68,7 @@ BEGIN;
SELECT conname, conrelid::regclass::text, confrelid::regclass::text
FROM pg_constraint
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='create_citus_local_table_cascade') AND
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='citus_add_local_table_to_metadata_cascade') AND
conname ~ '^fkey\_\d+$'
ORDER BY 1,2,3;
conname | conrelid | confrelid
@ -83,7 +83,7 @@ BEGIN;
SELECT COUNT(*)=4 FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade';
schemaname='citus_add_local_table_to_metadata_cascade';
?column?
---------------------------------------------------------------------
t
@ -91,14 +91,14 @@ BEGIN;
ROLLBACK;
BEGIN;
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
SELECT COUNT(*)=6 FROM pg_constraint
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='create_citus_local_table_cascade') AND
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='citus_add_local_table_to_metadata_cascade') AND
conname ~ '^fkey\_\d+$';
?column?
---------------------------------------------------------------------
@ -107,7 +107,7 @@ BEGIN;
SELECT COUNT(*)=4 FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade';
schemaname='citus_add_local_table_to_metadata_cascade';
?column?
---------------------------------------------------------------------
t
@ -117,17 +117,17 @@ ROLLBACK;
BEGIN;
CREATE TABLE partitioned_table (col_1 INT REFERENCES local_table_1 (col_1)) PARTITION BY RANGE (col_1);
-- now that we introduced a partitioned table into our foreign key subgraph,
-- create_citus_local_table(cascade_via_foreign_keys) would fail for
-- partitioned_table as create_citus_local_table doesn't support partitioned tables
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
-- citus_add_local_table_to_metadata(cascade_via_foreign_keys) would fail for
-- partitioned_table as citus_add_local_table_to_metadata doesn't support partitioned tables
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
ERROR: cannot add local table "partitioned_table" to metadata, only regular tables and foreign tables can be added to citus metadata
ROLLBACK;
BEGIN;
DROP TABLE local_table_2;
-- show that create_citus_local_table(cascade_via_foreign_keys) works fine after
-- show that citus_add_local_table_to_metadata(cascade_via_foreign_keys) works fine after
-- dropping one of the relations from foreign key graph
SELECT create_citus_local_table('local_table_1', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_1', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -138,8 +138,8 @@ BEGIN;
ALTER TABLE local_table_1 DROP CONSTRAINT local_table_1_col_1_key CASCADE;
-- now that local_table_2 does not have any foreign keys, cascade_via_foreign_keys=true
-- is not needed but show that it still works fine
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -147,7 +147,7 @@ BEGIN;
-- show citus tables in current schema
SELECT tablename FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade'
schemaname='citus_add_local_table_to_metadata_cascade'
ORDER BY 1;
tablename
---------------------------------------------------------------------
@ -164,8 +164,8 @@ BEGIN;
-- foreign key relationships with other tables but a self
-- referencing foreign key, cascade_via_foreign_keys=true
-- is not needed but show that it still works fine
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -173,7 +173,7 @@ BEGIN;
-- show citus tables in current schema
SELECT tablename FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade'
schemaname='citus_add_local_table_to_metadata_cascade'
ORDER BY 1;
tablename
---------------------------------------------------------------------
@ -194,10 +194,10 @@ BEGIN;
---------------------------------------------------------------------
(0 rows)
-- succeeds as create_citus_local_table would also prefer parallel
-- succeeds as citus_add_local_table_to_metadata would also prefer parallel
-- execution like above select
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -206,19 +206,19 @@ ROLLBACK;
BEGIN;
set citus.multi_shard_modify_mode to 'sequential';
-- sequetial execution also works fine
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
ROLLBACK;
-- test behaviour when outside of transaction block
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
-- cleanup at exit
DROP SCHEMA create_citus_local_table_cascade CASCADE;
DROP SCHEMA citus_add_local_table_to_metadata_cascade CASCADE;

View File

@ -21,8 +21,8 @@ ALTER TABLE citus_local_table_1 ADD CONSTRAINT fkey_3 FOREIGN KEY (col_1) REFERE
ALTER TABLE citus_local_table_1 ADD CONSTRAINT fkey_4 FOREIGN KEY (col_1) REFERENCES citus_local_table_4(col_1);
ALTER TABLE citus_local_table_4 ADD CONSTRAINT fkey_5 FOREIGN KEY (col_1) REFERENCES citus_local_table_3(col_1);
ALTER TABLE citus_local_table_4 ADD CONSTRAINT fkey_6 FOREIGN KEY (col_1) REFERENCES citus_local_table_4(col_1);
SELECT create_citus_local_table('citus_local_table_1', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -158,8 +158,8 @@ ERROR: table "citus_local_table_2" is already distributed
ROLLBACK;
-- test with a standalone table
CREATE TABLE citus_local_table_5 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_5');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_5');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -293,8 +293,8 @@ BEGIN;
ROLLBACK;
CREATE TABLE citus_local_table_6 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_6');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_6');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -3,11 +3,11 @@ Parsed test spec with 2 sessions
starting permutation: s1-begin s2-begin s1-create-citus-local-table-1 s2-create-citus-local-table-1 s1-commit s2-commit
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
step s1-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
step s2-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1'); <waiting ...>
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-1: <... completed>
error in steps s1-commit s2-create-citus-local-table-1: ERROR: relation "citus_local_table_1_xxxxxxx" is a shard relation
@ -19,11 +19,11 @@ master_remove_node
starting permutation: s1-begin s2-begin s1-create-citus-local-table-3 s2-create-citus-local-table-3 s1-commit s2-commit
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-3: SELECT create_citus_local_table('another_schema.citus_local_table_3');
create_citus_local_table
step s1-create-citus-local-table-3: SELECT citus_add_local_table_to_metadata('another_schema.citus_local_table_3');
citus_add_local_table_to_metadata
step s2-create-citus-local-table-3: SELECT create_citus_local_table('another_schema.citus_local_table_3'); <waiting ...>
step s2-create-citus-local-table-3: SELECT citus_add_local_table_to_metadata('another_schema.citus_local_table_3'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-3: <... completed>
error in steps s1-commit s2-create-citus-local-table-3: ERROR: relation "citus_local_table_3_xxxxxxx" is a shard relation
@ -35,14 +35,14 @@ master_remove_node
starting permutation: s1-begin s2-begin s1-create-citus-local-table-1 s2-create-citus-local-table-1 s1-rollback s2-commit
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
step s1-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
step s2-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1'); <waiting ...>
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-rollback: ROLLBACK;
step s2-create-citus-local-table-1: <... completed>
create_citus_local_table
citus_add_local_table_to_metadata
step s2-commit: COMMIT;
@ -53,8 +53,8 @@ master_remove_node
starting permutation: s1-begin s2-begin s1-create-citus-local-table-1 s2-select s1-commit s2-commit
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
step s1-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
step s2-select: SELECT * FROM citus_local_table_1; <waiting ...>
@ -70,8 +70,8 @@ master_remove_node
starting permutation: s1-begin s2-begin s1-create-citus-local-table-1 s2-update s1-commit s2-commit
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
step s1-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
step s2-update: UPDATE citus_local_table_1 SET a=1 WHERE a=2; <waiting ...>
@ -85,8 +85,8 @@ master_remove_node
starting permutation: s1-begin s2-begin s1-create-citus-local-table-1 s2-truncate s1-commit s2-commit
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
step s1-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
step s2-truncate: TRUNCATE citus_local_table_1; <waiting ...>
@ -98,14 +98,14 @@ master_remove_node
starting permutation: s2-create-citus-local-table-2 s1-begin s2-begin s1-create-citus-local-table-1 s2-fkey-to-another s1-commit s2-commit
step s2-create-citus-local-table-2: SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
step s2-create-citus-local-table-2: SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
step s1-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
step s2-fkey-to-another: ALTER TABLE citus_local_table_1 ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(a) REFERENCES citus_local_table_2(a); <waiting ...>
@ -119,8 +119,8 @@ master_remove_node
starting permutation: s1-begin s2-begin s1-create-citus-local-table-1 s2-remove-coordinator s1-commit s2-commit
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
step s1-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
step s2-remove-coordinator: SELECT master_remove_node('localhost', 57636); <waiting ...>
@ -136,7 +136,7 @@ starting permutation: s1-begin s2-begin s1-drop-table s2-create-citus-local-tabl
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-drop-table: DROP TABLE citus_local_table_1;
step s2-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1'); <waiting ...>
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-1: <... completed>
error in steps s1-commit s2-create-citus-local-table-1: ERROR: cannot add local table to metadata, relation does not exist
@ -149,10 +149,10 @@ starting permutation: s1-begin s2-begin s1-delete s2-create-citus-local-table-1
step s1-begin: BEGIN;
step s2-begin: BEGIN;
step s1-delete: DELETE FROM citus_local_table_1 WHERE a=2;
step s2-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1'); <waiting ...>
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-1: <... completed>
create_citus_local_table
citus_add_local_table_to_metadata
step s2-commit: COMMIT;
@ -166,10 +166,10 @@ step s2-begin: BEGIN;
step s1-select: SELECT * FROM citus_local_table_1;
a
step s2-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1'); <waiting ...>
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-1: <... completed>
create_citus_local_table
citus_add_local_table_to_metadata
step s2-commit: COMMIT;
@ -184,7 +184,7 @@ step s1-remove-coordinator: SELECT master_remove_node('localhost', 57636);
master_remove_node
step s2-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1'); <waiting ...>
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-1: <... completed>
error in steps s1-commit s2-create-citus-local-table-1: ERROR: could not find the coordinator node in metadata as it is not added as a worker
@ -203,10 +203,10 @@ step s1-add-coordinator: SELECT 1 FROM master_add_node('localhost', 57636, 0);
?column?
1
step s2-create-citus-local-table-1: SELECT create_citus_local_table('citus_local_table_1'); <waiting ...>
step s2-create-citus-local-table-1: SELECT citus_add_local_table_to_metadata('citus_local_table_1'); <waiting ...>
step s1-commit: COMMIT;
step s2-create-citus-local-table-1: <... completed>
create_citus_local_table
citus_add_local_table_to_metadata
step s2-commit: COMMIT;

View File

@ -29,8 +29,8 @@ SELECT create_reference_table('reference_table');
CREATE VIEW view_on_ref AS SELECT * FROM reference_table;
CREATE TABLE citus_local_table(a int);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -395,6 +395,7 @@ BEGIN;
CREATE TABLE citus_local_table (a int);
SELECT create_citus_local_table('citus_local_table');
NOTICE: create_citus_local_table is deprecated in favour of citus_add_local_table_to_metadata
create_citus_local_table
---------------------------------------------------------------------
@ -469,6 +470,7 @@ SELECT * FROM print_extension_changes();
| function alter_table_set_access_method(regclass,text)
| function citus_activate_node(text,integer)
| function citus_add_inactive_node(text,integer,integer,noderole,name)
| function citus_add_local_table_to_metadata(regclass,boolean)
| function citus_add_node(text,integer,integer,noderole,name)
| function citus_add_secondary_node(text,integer,text,integer,name)
| function citus_conninfo_cache_invalidate()
@ -494,7 +496,6 @@ SELECT * FROM print_extension_changes();
| function citus_update_shard_statistics(bigint)
| function citus_update_table_statistics(regclass)
| function columnar.columnar_handler(internal)
| function create_citus_local_table(regclass,boolean)
| function notify_constraint_dropped()
| function remove_local_tables_from_metadata()
| function time_partition_range(regclass)

View File

@ -395,6 +395,7 @@ BEGIN;
CREATE TABLE citus_local_table (a int);
SELECT create_citus_local_table('citus_local_table');
NOTICE: create_citus_local_table is deprecated in favour of citus_add_local_table_to_metadata
create_citus_local_table
---------------------------------------------------------------------
@ -466,6 +467,7 @@ SELECT * FROM print_extension_changes();
| function alter_table_set_access_method(regclass,text)
| function citus_activate_node(text,integer)
| function citus_add_inactive_node(text,integer,integer,noderole,name)
| function citus_add_local_table_to_metadata(regclass,boolean)
| function citus_add_node(text,integer,integer,noderole,name)
| function citus_add_secondary_node(text,integer,text,integer,name)
| function citus_conninfo_cache_invalidate()
@ -490,7 +492,6 @@ SELECT * FROM print_extension_changes();
| function citus_update_node(integer,text,integer,boolean,integer)
| function citus_update_shard_statistics(bigint)
| function citus_update_table_statistics(regclass)
| function create_citus_local_table(regclass,boolean)
| function notify_constraint_dropped()
| function remove_local_tables_from_metadata()
| function time_partition_range(regclass)

View File

@ -20,8 +20,8 @@ SELECT create_reference_table('reference_table');
(1 row)
CREATE TABLE citus_local_table (a int, b int, z bigserial);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -60,7 +60,7 @@ CREATE TYPE order_side_mx AS ENUM ('buy', 'sell');
\c - - - :worker_1_port
-- show that we do not support creating citus local tables from mx workers for now
CREATE TABLE citus_local_table(a int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
ERROR: operation is not allowed on this node
HINT: Connect to the coordinator and run it again.
-- create schema to test schema support

View File

@ -71,8 +71,8 @@ BEGIN
RETURN a*a;
END; $$ LANGUAGE PLPGSQL STABLE;
CREATE TABLE citus_local_table(a int, b int DEFAULT square(10));
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -16,8 +16,8 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
RESET client_min_messages;
-- create test tables
CREATE TABLE citus_local_table(l1 int);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -138,8 +138,8 @@ SELECT 1 FROM master_remove_node('localhost', :worker_2_port);
-- create test tables
CREATE TABLE citus_local_table(l1 int primary key);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -223,14 +223,14 @@ NOTICE: drop cascades to constraint fkey_ref_to_local_1506007 on table ref_citu
BEGIN;
CREATE TABLE citus_local_table_1(a int, b int, unique (a,b));
CREATE TABLE citus_local_table_2(a int, b int, unique (a,b));
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -40,8 +40,8 @@ SELECT rebalance_table_shards();
-- test that calling rebalance_table_shards without specifying relation
-- wouldn't move shard of the citus local table.
CREATE TABLE citus_local_table(a int, b int);
SELECT create_citus_local_table('citus_local_table');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -55,8 +55,8 @@ SELECT master_remove_node(nodename, nodeport) FROM pg_dist_node WHERE groupid =
(1 row)
CREATE TABLE loc(x int, y int);
SELECT create_citus_local_table('loc');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('loc');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -290,8 +290,8 @@ NOTICE: Renaming the new table to single_node.upsert_test
(1 row)
-- create citus local table
select create_citus_local_table('upsert_test');
create_citus_local_table
select citus_add_local_table_to_metadata('upsert_test');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -1145,8 +1145,8 @@ SELECT create_distributed_table('distributed_table_1', 'col_1');
(1 row)
CREATE TABLE citus_local_table_1 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -1201,8 +1201,8 @@ CREATE TABLE local_table_3 (col_1 INT UNIQUE);
ALTER TABLE local_table_2 ADD CONSTRAINT fkey_6 FOREIGN KEY (col_1) REFERENCES local_table_1(col_1);
ALTER TABLE local_table_3 ADD CONSTRAINT fkey_7 FOREIGN KEY (col_1) REFERENCES local_table_1(col_1);
ALTER TABLE local_table_1 ADD CONSTRAINT fkey_8 FOREIGN KEY (col_1) REFERENCES local_table_1(col_1);
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -80,14 +80,14 @@ SELECT create_distributed_table('distributed_table_3', 'col_1');
CREATE TABLE citus_local_table_1 (col_1 INT UNIQUE);
CREATE TABLE citus_local_table_2 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -550,14 +550,14 @@ ROLLBACK;
CREATE SCHEMA "bad!schemaName";
CREATE TABLE "bad!schemaName"."LocalTabLE.1!?!"(col_1 INT UNIQUE);
CREATE TABLE "bad!schemaName"."LocalTabLE.2!?!"(col_1 INT UNIQUE);
SELECT create_citus_local_table('"bad!schemaName"."LocalTabLE.1!?!"');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('"bad!schemaName"."LocalTabLE.1!?!"');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
SELECT create_citus_local_table('"bad!schemaName"."LocalTabLE.2!?!"');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('"bad!schemaName"."LocalTabLE.2!?!"');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -40,15 +40,15 @@ SELECT create_distributed_table('distributed_table_1', 'col_1');
(1 row)
CREATE TABLE citus_local_table_1 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_1');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
CREATE TABLE citus_local_table_2 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_2');
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
@ -85,10 +85,10 @@ $$);
(localhost,57638,t,0)
(2 rows)
-- drop parititoned table as create_citus_local_table doesn't support partitioned tables
-- drop parititoned table as citus_add_local_table_to_metadata doesn't support partitioned tables
DROP TABLE partitioned_table_1;
SELECT create_citus_local_table('citus_local_table_1', cascade_via_foreign_keys=>true);
create_citus_local_table
SELECT citus_add_local_table_to_metadata('citus_local_table_1', cascade_via_foreign_keys=>true);
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)

View File

@ -33,6 +33,7 @@ ORDER BY 1;
function check_distributed_deadlocks()
function citus_activate_node(text,integer)
function citus_add_inactive_node(text,integer,integer,noderole,name)
function citus_add_local_table_to_metadata(regclass,boolean)
function citus_add_node(text,integer,integer,noderole,name)
function citus_add_rebalance_strategy(name,regproc,regproc,regproc,real,real)
function citus_add_secondary_node(text,integer,text,integer,name)
@ -103,7 +104,6 @@ ORDER BY 1;
function coord_combine_agg(oid,cstring,anyelement)
function coord_combine_agg_ffunc(internal,oid,cstring,anyelement)
function coord_combine_agg_sfunc(internal,oid,cstring,anyelement)
function create_citus_local_table(regclass,boolean)
function create_distributed_function(regprocedure,text,text)
function create_distributed_table(regclass,text,citus.distribution_type,text)
function create_intermediate_result(text,text)

View File

@ -30,6 +30,7 @@ ORDER BY 1;
function check_distributed_deadlocks()
function citus_activate_node(text,integer)
function citus_add_inactive_node(text,integer,integer,noderole,name)
function citus_add_local_table_to_metadata(regclass,boolean)
function citus_add_node(text,integer,integer,noderole,name)
function citus_add_rebalance_strategy(name,regproc,regproc,regproc,real,real)
function citus_add_secondary_node(text,integer,text,integer,name)
@ -99,7 +100,6 @@ ORDER BY 1;
function coord_combine_agg(oid,cstring,anyelement)
function coord_combine_agg_ffunc(internal,oid,cstring,anyelement)
function coord_combine_agg_sfunc(internal,oid,cstring,anyelement)
function create_citus_local_table(regclass,boolean)
function create_distributed_function(regprocedure,text,text)
function create_distributed_table(regclass,text,citus.distribution_type,text)
function create_intermediate_result(text,text)

View File

@ -19,8 +19,8 @@ teardown
session "s1"
step "s1-begin" { BEGIN; }
step "s1-create-citus-local-table-1" { SELECT create_citus_local_table('citus_local_table_1'); }
step "s1-create-citus-local-table-3" { SELECT create_citus_local_table('another_schema.citus_local_table_3'); }
step "s1-create-citus-local-table-1" { SELECT citus_add_local_table_to_metadata('citus_local_table_1'); }
step "s1-create-citus-local-table-3" { SELECT citus_add_local_table_to_metadata('another_schema.citus_local_table_3'); }
step "s1-drop-table" { DROP TABLE citus_local_table_1; }
step "s1-delete" { DELETE FROM citus_local_table_1 WHERE a=2; }
step "s1-select" { SELECT * FROM citus_local_table_1; }
@ -32,9 +32,9 @@ step "s1-rollback" { ROLLBACK; }
session "s2"
step "s2-begin" { BEGIN; }
step "s2-create-citus-local-table-1" { SELECT create_citus_local_table('citus_local_table_1'); }
step "s2-create-citus-local-table-2" { SELECT create_citus_local_table('citus_local_table_2'); }
step "s2-create-citus-local-table-3" { SELECT create_citus_local_table('another_schema.citus_local_table_3'); }
step "s2-create-citus-local-table-1" { SELECT citus_add_local_table_to_metadata('citus_local_table_1'); }
step "s2-create-citus-local-table-2" { SELECT citus_add_local_table_to_metadata('citus_local_table_2'); }
step "s2-create-citus-local-table-3" { SELECT citus_add_local_table_to_metadata('another_schema.citus_local_table_3'); }
step "s2-select" { SELECT * FROM citus_local_table_1; }
step "s2-update" { UPDATE citus_local_table_1 SET a=1 WHERE a=2; }
step "s2-truncate" { TRUNCATE citus_local_table_1; }
@ -43,7 +43,7 @@ step "s2-remove-coordinator" { SELECT master_remove_node('localhost', 57636); }
step "s2-commit" { COMMIT; }
// create_citus_local_table vs command/query //
// citus_add_local_table_to_metadata vs command/query //
// Second session should error out as the table becomes a citus local table after the first session commits ..
permutation "s1-begin" "s2-begin" "s1-create-citus-local-table-1" "s2-create-citus-local-table-1" "s1-commit" "s2-commit"
@ -61,14 +61,14 @@ permutation "s2-create-citus-local-table-2" "s1-begin" "s2-begin" "s1-create-cit
permutation "s1-begin" "s2-begin" "s1-create-citus-local-table-1" "s2-remove-coordinator" "s1-commit" "s2-commit"
// command/query vs create_citus_local_table //
// command/query vs citus_add_local_table_to_metadata //
// create_citus_local_table_1 should first block and then error out as the first session drops the table
// citus_add_local_table_to_metadata_1 should first block and then error out as the first session drops the table
permutation "s1-begin" "s2-begin" "s1-drop-table" "s2-create-citus-local-table-1" "s1-commit" "s2-commit"
// Any modifying queries, DML commands and SELECT will block
permutation "s1-begin" "s2-begin" "s1-delete" "s2-create-citus-local-table-1" "s1-commit" "s2-commit"
permutation "s1-begin" "s2-begin" "s1-select" "s2-create-citus-local-table-1" "s1-commit" "s2-commit"
// create_citus_local_table should block on master_remove_node and then fail
// citus_add_local_table_to_metadata should block on master_remove_node and then fail
permutation "s1-begin" "s2-begin" "s1-remove-coordinator" "s2-create-citus-local-table-1" "s1-commit" "s2-commit"
// create_citus_local_table should block on master_add_node and then succeed
// citus_add_local_table_to_metadata should block on master_add_node and then succeed
permutation "s1-remove-coordinator" "s1-begin" "s2-begin" "s1-add-coordinator" "s2-create-citus-local-table-1" "s1-commit" "s2-commit"

View File

@ -118,7 +118,7 @@ SELECT create_distributed_table('table_type_dist', 'a');
CREATE TABLE table_type_ref (a INT);
SELECT create_reference_table('table_type_ref');
CREATE TABLE table_type_citus_local(a INT);
SELECT create_citus_local_table('table_type_citus_local');
SELECT citus_add_local_table_to_metadata('table_type_citus_local');
CREATE TABLE table_type_pg_local (a INT);
SELECT table_name, citus_table_type, distribution_column, shard_count, access_method FROM public.citus_tables WHERE table_name::text LIKE 'table\_type%' ORDER BY 1;

View File

@ -10,7 +10,7 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
-- show that DROP CONSTRAINT cascades to undistributing citus_local_table
CREATE TABLE citus_local_table(l1 int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
CREATE TABLE reference_table(r1 int primary key);
SELECT create_reference_table('reference_table');
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_local_to_ref FOREIGN KEY(l1) REFERENCES reference_table(r1) ON DELETE CASCADE;

View File

@ -6,7 +6,7 @@ SELECT master_add_node('localhost', :master_port, groupId => 0) AS coordinator_n
CREATE TABLE citus_local(key int, value text);
SELECT create_citus_local_table('citus_local');
SELECT citus_add_local_table_to_metadata('citus_local');
CREATE TABLE postgres_table (key int, value text, value_2 jsonb);
CREATE TABLE reference_table (key int, value text, value_2 jsonb);

View File

@ -253,7 +253,7 @@ DROP TRIGGER no_such_trigger ON no_such_relation;
-- create test tables and some foreign key relationships between them to see
-- that triggers are properly handled when ddl cascades to referencing table
CREATE TABLE another_citus_local_table (value int unique);
SELECT create_citus_local_table('another_citus_local_table');
SELECT citus_add_local_table_to_metadata('another_citus_local_table');
ALTER TABLE another_citus_local_table ADD CONSTRAINT fkey_self FOREIGN KEY(value) REFERENCES another_citus_local_table(value);
ALTER TABLE citus_local_table ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(value) REFERENCES another_citus_local_table(value) ON UPDATE CASCADE;

View File

@ -20,7 +20,7 @@ RESET client_min_messages;
CREATE TABLE citus_local_table_1 (a int);
-- this should work as coordinator is added to pg_dist_node
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
-- try to remove coordinator and observe failure as there exist a citus local table
SELECT 1 FROM master_remove_node('localhost', :master_port);
@ -33,7 +33,7 @@ SELECT 1 FROM master_remove_node('localhost', :master_port);
CREATE TABLE citus_local_table_1 (a int primary key);
-- this should fail as coordinator is removed from pg_dist_node
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
-- let coordinator have citus local tables again for next tests
set client_min_messages to ERROR;
@ -41,13 +41,13 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
RESET client_min_messages;
-- creating citus local table having no data initially would work
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
-- creating citus local table having data in it would also work
CREATE TABLE citus_local_table_2(a int primary key);
INSERT INTO citus_local_table_2 VALUES(1);
SELECT create_citus_local_table('citus_local_table_2');
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
-- also create indexes on them
CREATE INDEX citus_local_table_1_idx ON citus_local_table_1(a);
@ -61,19 +61,19 @@ DROP TABLE citus_local_table_1, citus_local_table_2;
-- .. for an initially empty table
CREATE TABLE citus_local_table_1(a int);
CREATE INDEX citus_local_table_1_idx ON citus_local_table_1(a);
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
-- .. and for another table having data in it before creating citus local table
CREATE TABLE citus_local_table_2(a int);
INSERT INTO citus_local_table_2 VALUES(1);
CREATE INDEX citus_local_table_2_idx ON citus_local_table_2(a);
SELECT create_citus_local_table('citus_local_table_2');
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
CREATE TABLE distributed_table (a int);
SELECT create_distributed_table('distributed_table', 'a');
-- cannot create citus local table from an existing citus table
SELECT create_citus_local_table('distributed_table');
SELECT citus_add_local_table_to_metadata('distributed_table');
-- partitioned table tests --
@ -82,19 +82,19 @@ CREATE TABLE partitioned_table_1 PARTITION OF partitioned_table FOR VALUES FROM
CREATE TABLE partitioned_table_2 PARTITION OF partitioned_table FOR VALUES FROM (10) TO (20);
-- cannot create partitioned citus local tables
SELECT create_citus_local_table('partitioned_table');
SELECT citus_add_local_table_to_metadata('partitioned_table');
BEGIN;
CREATE TABLE citus_local_table PARTITION OF partitioned_table FOR VALUES FROM (20) TO (30);
-- cannot create citus local table as a partition of a local table
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
ROLLBACK;
BEGIN;
CREATE TABLE citus_local_table (a int, b int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
-- cannot create citus local table as a partition of a local table
-- via ALTER TABLE commands as well
@ -105,7 +105,7 @@ BEGIN;
SELECT create_distributed_table('partitioned_table', 'a');
CREATE TABLE citus_local_table (a int, b int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
-- cannot attach citus local table to a partitioned distributed table
ALTER TABLE partitioned_table ATTACH PARTITION citus_local_table FOR VALUES FROM (20) TO (30);
@ -117,13 +117,13 @@ CREATE TABLE parent_table (a int, b text);
CREATE TABLE child_table () INHERITS (parent_table);
-- both of below should error out
SELECT create_citus_local_table('parent_table');
SELECT create_citus_local_table('child_table');
SELECT citus_add_local_table_to_metadata('parent_table');
SELECT citus_add_local_table_to_metadata('child_table');
-- show that we support UNLOGGED tables --
CREATE UNLOGGED TABLE unlogged_table (a int primary key);
SELECT create_citus_local_table('unlogged_table');
SELECT citus_add_local_table_to_metadata('unlogged_table');
-- show that we allow triggers --
@ -143,7 +143,7 @@ BEGIN;
AFTER INSERT ON citus_local_table_3
FOR EACH STATEMENT EXECUTE FUNCTION update_value();
SELECT create_citus_local_table('citus_local_table_3');
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
INSERT INTO citus_local_table_3 VALUES (1);
@ -163,7 +163,7 @@ BEGIN;
USING (table_user = current_user);
-- this should error out
SELECT create_citus_local_table('citus_local_table_3');
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
ROLLBACK;
-- show that we properly handle sequences on citus local tables --
@ -172,7 +172,7 @@ BEGIN;
CREATE SEQUENCE col3_seq;
CREATE TABLE citus_local_table_3 (col1 serial, col2 int, col3 int DEFAULT nextval('col3_seq'));
SELECT create_citus_local_table('citus_local_table_3');
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
-- print column default expressions
-- we should only see shell relation below
@ -199,7 +199,7 @@ CREATE FOREIGN TABLE foreign_table (
-- observe that we do not create fdw server for shell table, both shard relation
-- & shell relation points to the same same server object
SELECT create_citus_local_table('foreign_table');
SELECT citus_add_local_table_to_metadata('foreign_table');
DROP FOREIGN TABLE foreign_table;
@ -208,10 +208,10 @@ DROP TABLE citus_local_table_1, citus_local_table_2, distributed_table;
-- create test tables
CREATE TABLE citus_local_table_1 (a int primary key);
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
CREATE TABLE citus_local_table_2 (a int primary key);
SELECT create_citus_local_table('citus_local_table_2');
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
CREATE TABLE local_table (a int primary key);
@ -254,11 +254,11 @@ CREATE TABLE local_table_3 (a int primary key, b int references local_table_3(a)
-- below two should fail as we do not allow foreign keys between
-- postgres local tables and citus local tables
SELECT create_citus_local_table('local_table_1');
SELECT create_citus_local_table('local_table_2');
SELECT citus_add_local_table_to_metadata('local_table_1');
SELECT citus_add_local_table_to_metadata('local_table_2');
-- below should work as we allow initial self references in citus local tables
SELECT create_citus_local_table('local_table_3');
SELECT citus_add_local_table_to_metadata('local_table_3');
------------------------------------------------------------------
----- tests for object names that should be escaped properly -----
@ -270,7 +270,7 @@ CREATE SCHEMA "CiTUS!LocalTables";
CREATE TABLE "CiTUS!LocalTables"."LocalTabLE.1!?!"(id int, "TeNANt_Id" int);
-- should work
SELECT create_citus_local_table('"CiTUS!LocalTables"."LocalTabLE.1!?!"');
SELECT citus_add_local_table_to_metadata('"CiTUS!LocalTables"."LocalTabLE.1!?!"');
-- drop the table before creating it when the search path is set
SET search_path to "CiTUS!LocalTables" ;
@ -292,21 +292,21 @@ CREATE TABLE "LocalTabLE.1!?!"(
serial_data bigserial, UNIQUE (id, price),
EXCLUDE USING GIST (name WITH =));
-- create some objects before create_citus_local_table
-- create some objects before citus_add_local_table_to_metadata
CREATE INDEX "my!Index1" ON "LocalTabLE.1!?!"(id) WITH ( fillfactor = 80 ) WHERE id > 10;
CREATE UNIQUE INDEX uniqueIndex ON "LocalTabLE.1!?!" (id);
-- ingest some data before create_citus_local_table
-- ingest some data before citus_add_local_table_to_metadata
INSERT INTO "LocalTabLE.1!?!" VALUES (1, 1, (1, row_to_json(row(1,1)))::local_type, row_to_json(row(1,1), true)),
(2, 1, (2, row_to_json(row(2,2)))::local_type, row_to_json(row(2,2), 'false'));
-- create a replica identity before create_citus_local_table
-- create a replica identity before citus_add_local_table_to_metadata
ALTER TABLE "LocalTabLE.1!?!" REPLICA IDENTITY USING INDEX uniqueIndex;
-- this shouldn't give any syntax errors
SELECT create_citus_local_table('"LocalTabLE.1!?!"');
SELECT citus_add_local_table_to_metadata('"LocalTabLE.1!?!"');
-- create some objects after create_citus_local_table
-- create some objects after citus_add_local_table_to_metadata
CREATE INDEX "my!Index2" ON "LocalTabLE.1!?!"(id) WITH ( fillfactor = 90 ) WHERE id < 20;
CREATE UNIQUE INDEX uniqueIndex2 ON "LocalTabLE.1!?!"(id);
@ -408,7 +408,7 @@ DROP TABLE citus_local_table_1, citus_local_table_2, distributed_table, local_ta
-- test some other udf's with citus local tables
CREATE TABLE citus_local_table_4(a int);
SELECT create_citus_local_table('citus_local_table_4');
SELECT citus_add_local_table_to_metadata('citus_local_table_4');
-- should work --
@ -481,13 +481,13 @@ SELECT citus_table_is_visible(tableName::regclass::oid), relation_is_a_known_sha
FROM (SELECT tableName FROM pg_catalog.pg_tables WHERE tablename LIKE 'citus_local_table_4_%') as tableName;
-- cannot create a citus local table from a catalog table
SELECT create_citus_local_table('pg_class');
SELECT citus_add_local_table_to_metadata('pg_class');
CREATE TABLE referencing_table(a int);
SELECT create_citus_local_table('referencing_table');
SELECT citus_add_local_table_to_metadata('referencing_table');
CREATE TABLE referenced_table(a int UNIQUE);
SELECT create_citus_local_table('referenced_table');
SELECT citus_add_local_table_to_metadata('referenced_table');
ALTER TABLE referencing_table ADD CONSTRAINT fkey_cl_to_cl FOREIGN KEY (a) REFERENCES referenced_table(a);

View File

@ -18,7 +18,7 @@ RESET client_min_messages;
--------------
CREATE TABLE citus_local_table (value int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
-- first stop metadata sync to worker_1
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
@ -71,30 +71,30 @@ FOR EACH STATEMENT EXECUTE FUNCTION another_dummy_function();
-- and define some foreign keys between them
CREATE TABLE citus_local_table_1(l1 int);
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
CREATE TABLE reference_table_1(r1 int primary key);
SELECT create_reference_table('reference_table_1');
ALTER TABLE citus_local_table_1 ADD CONSTRAINT fkey_local_to_ref FOREIGN KEY(l1) REFERENCES reference_table_1(r1) ON DELETE CASCADE;
CREATE TABLE citus_local_table_2(l1 int primary key);
SELECT create_citus_local_table('citus_local_table_2');
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
CREATE TABLE reference_table_2(r1 int);
SELECT create_reference_table('reference_table_2');
ALTER TABLE reference_table_2 ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(r1) REFERENCES citus_local_table_2(l1) ON DELETE RESTRICT;
CREATE TABLE citus_local_table_3(l1 int);
SELECT create_citus_local_table('citus_local_table_3');
SELECT citus_add_local_table_to_metadata('citus_local_table_3');
CREATE TABLE citus_local_table_4(l1 int primary key);
SELECT create_citus_local_table('citus_local_table_4');
SELECT citus_add_local_table_to_metadata('citus_local_table_4');
ALTER TABLE citus_local_table_3 ADD CONSTRAINT fkey_local_to_local FOREIGN KEY(l1) REFERENCES citus_local_table_4(l1) ON UPDATE SET NULL;
-- check stats creation
CREATE TABLE citus_local_table_stats(a int, b int);
CREATE STATISTICS stx1 ON a, b FROM citus_local_table_stats;
SELECT create_citus_local_table('citus_local_table_stats');
SELECT citus_add_local_table_to_metadata('citus_local_table_stats');
CREATE STATISTICS stx2 ON a, b FROM citus_local_table_stats;
CREATE STATISTICS stx3 ON a, b FROM citus_local_table_stats;
CREATE STATISTICS stx4 ON a, b FROM citus_local_table_stats;
@ -158,7 +158,7 @@ ALTER TABLE citus_local_table_3 ADD CONSTRAINT fkey_local_to_local_2 FOREIGN KEY
-- check stats creation
CREATE TABLE citus_local_table_stats2(a int, b int);
CREATE STATISTICS stx8 ON a, b FROM citus_local_table_stats2;
SELECT create_citus_local_table('citus_local_table_stats2');
SELECT citus_add_local_table_to_metadata('citus_local_table_stats2');
CREATE STATISTICS stx9 ON a, b FROM citus_local_table_stats2;
DROP STATISTICS stx8;
DROP STATISTICS stx4;

View File

@ -307,7 +307,7 @@ SET citus.shard_replication_factor TO 1;
-- test options on a citus local table
SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0);
CREATE TABLE table_option_citus_local (a int, b text) USING columnar;
SELECT create_citus_local_table('table_option_citus_local');
SELECT citus_add_local_table_to_metadata('table_option_citus_local');
-- setting: compression
-- get baseline for setting
@ -388,7 +388,7 @@ SELECT alter_columnar_table_set('table_option_citus_local_2',
stripe_row_count => 1000,
compression => 'pglz',
compression_level => 9);
SELECT create_citus_local_table('table_option_citus_local_2');
SELECT citus_add_local_table_to_metadata('table_option_citus_local_2');
-- verify settings on placements
SELECT run_command_on_placements('table_option_citus_local_2',$cmd$

View File

@ -3,8 +3,8 @@
SET citus.next_shard_id TO 1516000;
SET citus.shard_replication_factor TO 1;
CREATE SCHEMA create_citus_local_table_cascade;
SET search_path TO create_citus_local_table_cascade;
CREATE SCHEMA citus_add_local_table_to_metadata_cascade;
SET search_path TO citus_add_local_table_to_metadata_cascade;
SET client_min_messages to ERROR;
@ -31,62 +31,62 @@ ALTER TABLE local_table_4 ADD CONSTRAINT fkey_5 FOREIGN KEY (col_1) REFERENCES l
ALTER TABLE local_table_4 ADD CONSTRAINT fkey_6 FOREIGN KEY (col_1) REFERENCES local_table_4(col_1);
-- show that all of below fails as we didn't provide cascade_via_foreign_keys=true
SELECT create_citus_local_table('local_table_1');
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>false);
SELECT citus_add_local_table_to_metadata('local_table_1');
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>false);
-- In each of below two transaction blocks, show that we preserve foreign keys.
-- Also show that we converted all local_table_xxx tables in current schema
-- to citus local tables after create_citus_local_table (cascade).
-- to citus local tables after citus_add_local_table_to_metadata (cascade).
-- So in each transaction, both selects should return true.
BEGIN;
SELECT conname, conrelid::regclass::text, confrelid::regclass::text
FROM pg_constraint
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='create_citus_local_table_cascade') AND
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='citus_add_local_table_to_metadata_cascade') AND
conname ~ '^fkey\_\d+$'
ORDER BY 1,2,3;
SELECT create_citus_local_table('local_table_1', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_1', cascade_via_foreign_keys=>true);
-- show that we do parallel execution
show citus.multi_shard_modify_mode;
SELECT conname, conrelid::regclass::text, confrelid::regclass::text
FROM pg_constraint
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='create_citus_local_table_cascade') AND
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='citus_add_local_table_to_metadata_cascade') AND
conname ~ '^fkey\_\d+$'
ORDER BY 1,2,3;
SELECT COUNT(*)=4 FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade';
schemaname='citus_add_local_table_to_metadata_cascade';
ROLLBACK;
BEGIN;
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
SELECT COUNT(*)=6 FROM pg_constraint
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='create_citus_local_table_cascade') AND
WHERE connamespace = (SELECT oid FROM pg_namespace WHERE nspname='citus_add_local_table_to_metadata_cascade') AND
conname ~ '^fkey\_\d+$';
SELECT COUNT(*)=4 FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade';
schemaname='citus_add_local_table_to_metadata_cascade';
ROLLBACK;
BEGIN;
CREATE TABLE partitioned_table (col_1 INT REFERENCES local_table_1 (col_1)) PARTITION BY RANGE (col_1);
-- now that we introduced a partitioned table into our foreign key subgraph,
-- create_citus_local_table(cascade_via_foreign_keys) would fail for
-- partitioned_table as create_citus_local_table doesn't support partitioned tables
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
-- citus_add_local_table_to_metadata(cascade_via_foreign_keys) would fail for
-- partitioned_table as citus_add_local_table_to_metadata doesn't support partitioned tables
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
ROLLBACK;
BEGIN;
DROP TABLE local_table_2;
-- show that create_citus_local_table(cascade_via_foreign_keys) works fine after
-- show that citus_add_local_table_to_metadata(cascade_via_foreign_keys) works fine after
-- dropping one of the relations from foreign key graph
SELECT create_citus_local_table('local_table_1', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_1', cascade_via_foreign_keys=>true);
ROLLBACK;
BEGIN;
@ -95,12 +95,12 @@ BEGIN;
-- now that local_table_2 does not have any foreign keys, cascade_via_foreign_keys=true
-- is not needed but show that it still works fine
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
-- show citus tables in current schema
SELECT tablename FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade'
schemaname='citus_add_local_table_to_metadata_cascade'
ORDER BY 1;
ROLLBACK;
@ -115,12 +115,12 @@ BEGIN;
-- foreign key relationships with other tables but a self
-- referencing foreign key, cascade_via_foreign_keys=true
-- is not needed but show that it still works fine
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
-- show citus tables in current schema
SELECT tablename FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='create_citus_local_table_cascade'
schemaname='citus_add_local_table_to_metadata_cascade'
ORDER BY 1;
ROLLBACK;
@ -129,19 +129,19 @@ SELECT create_distributed_Table('distributed_table', 'col');
BEGIN;
SELECT * FROM distributed_table;
-- succeeds as create_citus_local_table would also prefer parallel
-- succeeds as citus_add_local_table_to_metadata would also prefer parallel
-- execution like above select
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
ROLLBACK;
BEGIN;
set citus.multi_shard_modify_mode to 'sequential';
-- sequetial execution also works fine
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
ROLLBACK;
-- test behaviour when outside of transaction block
SELECT create_citus_local_table('local_table_4', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_4', cascade_via_foreign_keys=>true);
-- cleanup at exit
DROP SCHEMA create_citus_local_table_cascade CASCADE;
DROP SCHEMA citus_add_local_table_to_metadata_cascade CASCADE;

View File

@ -22,7 +22,7 @@ ALTER TABLE citus_local_table_1 ADD CONSTRAINT fkey_4 FOREIGN KEY (col_1) REFERE
ALTER TABLE citus_local_table_4 ADD CONSTRAINT fkey_5 FOREIGN KEY (col_1) REFERENCES citus_local_table_3(col_1);
ALTER TABLE citus_local_table_4 ADD CONSTRAINT fkey_6 FOREIGN KEY (col_1) REFERENCES citus_local_table_4(col_1);
SELECT create_citus_local_table('citus_local_table_1', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('citus_local_table_1', cascade_via_foreign_keys=>true);
CREATE TABLE reference_table_1(col_1 INT UNIQUE, col_2 INT UNIQUE);
CREATE TABLE reference_table_2(col_1 INT UNIQUE, col_2 INT UNIQUE);
@ -99,7 +99,7 @@ ROLLBACK;
-- test with a standalone table
CREATE TABLE citus_local_table_5 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_5');
SELECT citus_add_local_table_to_metadata('citus_local_table_5');
BEGIN;
SELECT create_distributed_table('citus_local_table_5', 'col_1');
@ -158,7 +158,7 @@ BEGIN;
ROLLBACK;
CREATE TABLE citus_local_table_6 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_6');
SELECT citus_add_local_table_to_metadata('citus_local_table_6');
BEGIN;
ALTER TABLE citus_local_table_5 ADD CONSTRAINT fkey_12 FOREIGN KEY (col_1) REFERENCES citus_local_table_6(col_1);

View File

@ -27,7 +27,7 @@ SELECT create_reference_table('reference_table');
CREATE VIEW view_on_ref AS SELECT * FROM reference_table;
CREATE TABLE citus_local_table(a int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
CREATE VIEW view_on_citus_local AS SELECT * FROM citus_local_table;

View File

@ -9,7 +9,7 @@ CREATE TABLE reference_table (a int, b int, z bigserial);
SELECT create_reference_table('reference_table');
CREATE TABLE citus_local_table (a int, b int, z bigserial);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
CREATE TABLE local (a int, b int);

View File

@ -61,7 +61,7 @@ CREATE TYPE order_side_mx AS ENUM ('buy', 'sell');
-- show that we do not support creating citus local tables from mx workers for now
CREATE TABLE citus_local_table(a int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
-- create schema to test schema support
CREATE SCHEMA citus_mx_test_schema_join_1;

View File

@ -39,7 +39,7 @@ BEGIN
END; $$ LANGUAGE PLPGSQL STABLE;
CREATE TABLE citus_local_table(a int, b int DEFAULT square(10));
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
INSERT INTO citus_local_table VALUES (10), (11);
INSERT INTO citus_local_table (a) VALUES (12), (13);

View File

@ -15,7 +15,7 @@ RESET client_min_messages;
-- create test tables
CREATE TABLE citus_local_table(l1 int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
CREATE TABLE reference_table(r1 int primary key);
SELECT create_reference_table('reference_table');
@ -89,7 +89,7 @@ SELECT 1 FROM master_remove_node('localhost', :worker_2_port);
-- create test tables
CREATE TABLE citus_local_table(l1 int primary key);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
CREATE TABLE reference_table(r1 int);
SELECT create_reference_table('reference_table');
@ -143,8 +143,8 @@ DROP TABLE citus_local_table CASCADE;
BEGIN;
CREATE TABLE citus_local_table_1(a int, b int, unique (a,b));
CREATE TABLE citus_local_table_2(a int, b int, unique (a,b));
SELECT create_citus_local_table('citus_local_table_1');
SELECT create_citus_local_table('citus_local_table_2');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
-- show that we properly handle multi column foreign keys
ALTER TABLE citus_local_table_1 ADD CONSTRAINT multi_fkey FOREIGN KEY (a, b) REFERENCES citus_local_table_2(a, b);

View File

@ -18,7 +18,7 @@ SELECT rebalance_table_shards();
-- test that calling rebalance_table_shards without specifying relation
-- wouldn't move shard of the citus local table.
CREATE TABLE citus_local_table(a int, b int);
SELECT create_citus_local_table('citus_local_table');
SELECT citus_add_local_table_to_metadata('citus_local_table');
INSERT INTO citus_local_table VALUES (1, 2);
SELECT rebalance_table_shards();

View File

@ -34,7 +34,7 @@ DROP TABLE ref;
SELECT master_remove_node(nodename, nodeport) FROM pg_dist_node WHERE groupid = 0;
CREATE TABLE loc(x int, y int);
SELECT create_citus_local_table('loc');
SELECT citus_add_local_table_to_metadata('loc');
SELECT groupid, nodename, nodeport, isactive, shouldhaveshards, hasmetadata, metadatasynced FROM pg_dist_node;
@ -131,7 +131,7 @@ COMMIT;
-- to test citus local tables
select undistribute_table('upsert_test');
-- create citus local table
select create_citus_local_table('upsert_test');
select citus_add_local_table_to_metadata('upsert_test');
-- test the constraint with local execution
INSERT INTO upsert_test (part_key, other_col) VALUES (1, 1) ON CONFLICT ON CONSTRAINT upsert_test_part_key_key DO NOTHING RETURNING *;
@ -629,7 +629,7 @@ CREATE TABLE distributed_table_1 (col_1 INT UNIQUE);
SELECT create_distributed_table('distributed_table_1', 'col_1');
CREATE TABLE citus_local_table_1 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
CREATE TABLE partitioned_table_1 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
CREATE TABLE partitioned_table_1_100_200 PARTITION OF partitioned_table_1 FOR VALUES FROM (100) TO (200);
@ -652,7 +652,7 @@ ALTER TABLE local_table_2 ADD CONSTRAINT fkey_6 FOREIGN KEY (col_1) REFERENCES l
ALTER TABLE local_table_3 ADD CONSTRAINT fkey_7 FOREIGN KEY (col_1) REFERENCES local_table_1(col_1);
ALTER TABLE local_table_1 ADD CONSTRAINT fkey_8 FOREIGN KEY (col_1) REFERENCES local_table_1(col_1);
SELECT create_citus_local_table('local_table_2', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('local_table_2', cascade_via_foreign_keys=>true);
CREATE PROCEDURE call_delegation(x int) LANGUAGE plpgsql AS $$
BEGIN

View File

@ -41,8 +41,8 @@ SELECT create_distributed_table('distributed_table_3', 'col_1');
CREATE TABLE citus_local_table_1 (col_1 INT UNIQUE);
CREATE TABLE citus_local_table_2 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_1');
SELECT create_citus_local_table('citus_local_table_2');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
-- --- ---
-- | | | |
@ -372,8 +372,8 @@ CREATE SCHEMA "bad!schemaName";
CREATE TABLE "bad!schemaName"."LocalTabLE.1!?!"(col_1 INT UNIQUE);
CREATE TABLE "bad!schemaName"."LocalTabLE.2!?!"(col_1 INT UNIQUE);
SELECT create_citus_local_table('"bad!schemaName"."LocalTabLE.1!?!"');
SELECT create_citus_local_table('"bad!schemaName"."LocalTabLE.2!?!"');
SELECT citus_add_local_table_to_metadata('"bad!schemaName"."LocalTabLE.1!?!"');
SELECT citus_add_local_table_to_metadata('"bad!schemaName"."LocalTabLE.2!?!"');
ALTER TABLE "bad!schemaName"."LocalTabLE.1!?!" ADD CONSTRAINT "bad!constraintName" FOREIGN KEY (col_1) REFERENCES "bad!schemaName"."LocalTabLE.2!?!"(col_1);

View File

@ -23,10 +23,10 @@ CREATE TABLE distributed_table_1 (col_1 INT UNIQUE);
SELECT create_distributed_table('distributed_table_1', 'col_1');
CREATE TABLE citus_local_table_1 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_1');
SELECT citus_add_local_table_to_metadata('citus_local_table_1');
CREATE TABLE citus_local_table_2 (col_1 INT UNIQUE);
SELECT create_citus_local_table('citus_local_table_2');
SELECT citus_add_local_table_to_metadata('citus_local_table_2');
CREATE TABLE partitioned_table_1 (col_1 INT UNIQUE, col_2 INT) PARTITION BY RANGE (col_1);
CREATE TABLE partitioned_table_1_100_200 PARTITION OF partitioned_table_1 FOR VALUES FROM (100) TO (200);
@ -48,9 +48,9 @@ $$
SELECT count(*) FROM pg_catalog.pg_tables WHERE schemaname='undistribute_table_cascade_mx'
$$);
-- drop parititoned table as create_citus_local_table doesn't support partitioned tables
-- drop parititoned table as citus_add_local_table_to_metadata doesn't support partitioned tables
DROP TABLE partitioned_table_1;
SELECT create_citus_local_table('citus_local_table_1', cascade_via_foreign_keys=>true);
SELECT citus_add_local_table_to_metadata('citus_local_table_1', cascade_via_foreign_keys=>true);
-- both workers should print 4 as we converted all tables except
-- partitioned table in this schema to a citus local table