From 433062e5d2104f40c89f279e25d457df0014d638 Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Wed, 20 Jan 2021 19:30:20 +0300 Subject: [PATCH] Add fkeys between citus local and reference tables in some tests (#4546) --- .../expected/citus_local_table_triggers.out | 163 +++++----- .../expected/citus_local_tables_queries.out | 280 +++++++++--------- .../citus_local_tables_queries_mx.out | 54 ++-- .../expected/undistribute_table_cascade.out | 7 +- .../sql/citus_local_table_triggers.sql | 47 ++- .../sql/citus_local_tables_queries.sql | 18 +- .../sql/citus_local_tables_queries_mx.sql | 18 +- .../sql/undistribute_table_cascade.sql | 7 +- 8 files changed, 316 insertions(+), 278 deletions(-) diff --git a/src/test/regress/expected/citus_local_table_triggers.out b/src/test/regress/expected/citus_local_table_triggers.out index b85442e0b..beb44213e 100644 --- a/src/test/regress/expected/citus_local_table_triggers.out +++ b/src/test/regress/expected/citus_local_table_triggers.out @@ -14,13 +14,20 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0); (1 row) RESET client_min_messages; -CREATE TABLE citus_local_table (value int); -SELECT create_citus_local_table('citus_local_table'); - create_citus_local_table +CREATE TABLE dummy_reference_table(a int unique, b int); +INSERT INTO dummy_reference_table SELECT i FROM generate_series(-1, 5) i; +INSERT INTO dummy_reference_table VALUES (99),(100),(599),(600); +SELECT create_reference_table('dummy_reference_table'); +NOTICE: Copying data from local table... +NOTICE: copying the data has completed + create_reference_table --------------------------------------------------------------------- (1 row) +CREATE TABLE citus_local_table (value int); +ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (value) REFERENCES dummy_reference_table(a); +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507001, 'citus_local_table_triggers', 1507000, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);') --------------------------------------------------------------------- -- DELETE trigger -- --------------------------------------------------------------------- @@ -41,13 +48,13 @@ BEGIN; CREATE TRIGGER insert_42_trigger AFTER DELETE ON citus_local_table FOR EACH ROW EXECUTE FUNCTION insert_42(); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER insert_42_trigger +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER insert_42_trigger AFTER DELETE ON citus_local_table FOR EACH ROW EXECUTE FUNCTION insert_42();') -- select should print two rows with "42" as delete from citus_local_table will -- insert 42 per deleted row DELETE FROM citus_local_table; -NOTICE: executing the command locally: DELETE FROM citus_local_table_triggers.citus_local_table_1507000 citus_local_table +NOTICE: executing the command locally: DELETE FROM citus_local_table_triggers.citus_local_table_1507001 citus_local_table SELECT * FROM distributed_table; value --------------------------------------------------------------------- @@ -60,7 +67,7 @@ ROLLBACK; BEGIN; CREATE TABLE reference_table(value int); SELECT create_reference_table('reference_table'); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507005, 'citus_local_table_triggers', 'CREATE TABLE citus_local_table_triggers.reference_table (value integer)');SELECT worker_apply_shard_ddl_command (1507005, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table_triggers.reference_table OWNER TO postgres') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507006, 'citus_local_table_triggers', 'CREATE TABLE citus_local_table_triggers.reference_table (value integer) ');SELECT worker_apply_shard_ddl_command (1507006, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table_triggers.reference_table OWNER TO postgres') create_reference_table --------------------------------------------------------------------- @@ -79,10 +86,10 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1 -- are executed only for once. -- select should print a row with "100" as truncate from citus_local_table will insert 100 TRUNCATE citus_local_table; -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507005 (value) VALUES (100) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507006 (value) VALUES (100) NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.citus_local_table_xxxxx CASCADE SELECT * FROM reference_table; -NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507005 reference_table +NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507006 reference_table value --------------------------------------------------------------------- 100 @@ -103,7 +110,7 @@ BEGIN; CREATE TRIGGER increment_value_trigger AFTER INSERT ON citus_local_table FOR EACH ROW EXECUTE FUNCTION increment_value(); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER increment_value_trigger +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER increment_value_trigger AFTER INSERT ON citus_local_table FOR EACH ROW EXECUTE FUNCTION increment_value();') -- insert initial data to the table that increment_value_trigger will execute for @@ -111,7 +118,7 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1 -- select should print a row with "2" as insert into citus_local_table will -- increment all rows per inserted row INSERT INTO citus_local_table VALUES(0), (1); -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507000 AS citus_table_alias (value) VALUES (0), (1) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507001 AS citus_table_alias (value) VALUES (0), (1) SELECT * FROM local_table; value --------------------------------------------------------------------- @@ -133,14 +140,14 @@ BEGIN; CREATE TRIGGER error_for_5_trigger BEFORE UPDATE OF value ON citus_local_table FOR EACH ROW EXECUTE FUNCTION error_for_5(); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER error_for_5_trigger +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER error_for_5_trigger BEFORE UPDATE OF value ON citus_local_table FOR EACH ROW EXECUTE FUNCTION error_for_5();') -- below update will error out as trigger raises exception INSERT INTO citus_local_table VALUES (5); -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507000 (value) VALUES (5) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507001 (value) VALUES (5) UPDATE citus_local_table SET value=value*2 WHERE value=5; -NOTICE: executing the command locally: UPDATE citus_local_table_triggers.citus_local_table_1507000 citus_local_table SET value = (value OPERATOR(pg_catalog.*) 2) WHERE (value OPERATOR(pg_catalog.=) 5) +NOTICE: executing the command locally: UPDATE citus_local_table_triggers.citus_local_table_1507001 citus_local_table SET value = (value OPERATOR(pg_catalog.*) 2) WHERE (value OPERATOR(pg_catalog.=) 5) ERROR: cannot update update for value=5 ROLLBACK; --------------------------------------------------------------------- @@ -165,14 +172,11 @@ BEGIN; CREATE TRIGGER initial_truncate_trigger AFTER TRUNCATE ON "interesting!schema"."citus_local!_table" FOR EACH STATEMENT EXECUTE FUNCTION dummy_function(); - SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"'); - create_citus_local_table ---------------------------------------------------------------------- - -(1 row) - + ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a); +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507007, 'interesting!schema', 1507000, 'citus_local_table_triggers', 'ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);') -- we shouldn't see truncate trigger on shard relation as we drop it - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- initial_truncate_trigger | "interesting!schema"."citus_local!_table" | O @@ -181,23 +185,19 @@ BEGIN; ROLLBACK; CREATE TABLE "interesting!schema"."citus_local!_table"(value int); -SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"'); - create_citus_local_table ---------------------------------------------------------------------- - -(1 row) - +ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a); +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507008, 'interesting!schema', 1507000, 'citus_local_table_triggers', 'ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a);') CREATE TRIGGER "trigger\'name" BEFORE INSERT ON "interesting!schema"."citus_local!_table" FOR EACH STATEMENT EXECUTE FUNCTION dummy_function(); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'CREATE TRIGGER "trigger\\''name" +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'CREATE TRIGGER "trigger\\''name" BEFORE INSERT ON "interesting!schema"."citus_local!_table" FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();') BEGIN; CREATE EXTENSION seg; -- ALTER TRIGGER DEPENDS ON ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" DEPENDS ON EXTENSION seg; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" DEPENDS ON EXTENSION seg;') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" DEPENDS ON EXTENSION seg;') -- show that triggers on both shell relation and shard relation are depending on seg SELECT tgname FROM pg_depend, pg_trigger, pg_extension WHERE deptype = 'x' and classid='pg_trigger'::regclass and @@ -206,12 +206,13 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1 tgname --------------------------------------------------------------------- trigger\'name - trigger\'name_1507007 + trigger\'name_1507008 (2 rows) DROP EXTENSION seg; -- show that dropping extension drops the triggers automatically - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O @@ -220,102 +221,110 @@ NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1 ROLLBACK; -- ALTER TRIGGER RENAME ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\'name22"; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\\''name22";') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TRIGGER "trigger\\''name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\\''name22";') -- show that triggers on both shell relation and shard relation are renamed -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- trigger\'name22 | "interesting!schema"."citus_local!_table" | O - trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O + trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O (3 rows) -- ALTER TABLE DISABLE trigger ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\'name22"; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\\''name22";') -SELECT * FROM citus_local_table_triggers; +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\\''name22";') +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- trigger\'name22 | "interesting!schema"."citus_local!_table" | D - trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | D + trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | D truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O (3 rows) -- ALTER TABLE ENABLE trigger ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\'name22"; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\\''name22";') -SELECT * FROM citus_local_table_triggers; +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\\''name22";') +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- trigger\'name22 | "interesting!schema"."citus_local!_table" | O - trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O + trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O (3 rows) CREATE TRIGGER another_trigger AFTER DELETE ON "interesting!schema"."citus_local!_table" FOR EACH STATEMENT EXECUTE FUNCTION dummy_function(); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'CREATE TRIGGER another_trigger +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'CREATE TRIGGER another_trigger AFTER DELETE ON "interesting!schema"."citus_local!_table" FOR EACH STATEMENT EXECUTE FUNCTION dummy_function();') ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER;') -- show that all triggers except the internal ones are disabled -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- another_trigger | "interesting!schema"."citus_local!_table" | D - another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | D + another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | D trigger\'name22 | "interesting!schema"."citus_local!_table" | D - trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | D + trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | D truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O (5 rows) ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER;') -- show that all triggers except the internal ones are enabled again -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- another_trigger | "interesting!schema"."citus_local!_table" | O - another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | O + another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | O trigger\'name22 | "interesting!schema"."citus_local!_table" | O - trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O + trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O (5 rows) ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL;') -- show that all triggers including internal triggers are disabled -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- another_trigger | "interesting!schema"."citus_local!_table" | D - another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | D + another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | D trigger\'name22 | "interesting!schema"."citus_local!_table" | D - trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | D + trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | D truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | D (5 rows) ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;') -- show that all triggers including internal triggers are enabled again -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- another_trigger | "interesting!schema"."citus_local!_table" | O - another_trigger_1507007 | "interesting!schema"."citus_local!_table_1507007" | O + another_trigger_1507008 | "interesting!schema"."citus_local!_table_1507008" | O trigger\'name22 | "interesting!schema"."citus_local!_table" | O - trigger\'name22_1507007 | "interesting!schema"."citus_local!_table_1507007" | O + trigger\'name22_1507008 | "interesting!schema"."citus_local!_table_1507008" | O truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O (5 rows) DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table"; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table";') DROP TRIGGER "trigger\'name22" ON "interesting!schema"."citus_local!_table"; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', E'DROP TRIGGER "trigger\\''name22" ON "interesting!schema"."citus_local!_table";') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', E'DROP TRIGGER "trigger\\''name22" ON "interesting!schema"."citus_local!_table";') -- show that drop trigger works as expected -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- truncate_trigger_xxxxxxx | "interesting!schema"."citus_local!_table" | O @@ -327,7 +336,8 @@ BEGIN; FOR EACH STATEMENT EXECUTE FUNCTION dummy_function(); ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "another_trigger\'name"; -- show that our truncate trigger is disabled .. - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- another_trigger\'name | "interesting!schema"."citus_local!_table" | D @@ -335,9 +345,10 @@ BEGIN; (2 rows) ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507007, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'interesting!schema', 'ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL;') -- .. and now it is enabled back - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; tgname | tgrelid | tgenabled --------------------------------------------------------------------- another_trigger\'name | "interesting!schema"."citus_local!_table" | O @@ -365,9 +376,9 @@ SELECT create_citus_local_table('another_citus_local_table'); (1 row) ALTER TABLE another_citus_local_table ADD CONSTRAINT fkey_self FOREIGN KEY(value) REFERENCES another_citus_local_table(value); -NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507008, 'citus_local_table_triggers', 1507008, 'citus_local_table_triggers', 'ALTER TABLE another_citus_local_table ADD CONSTRAINT fkey_self FOREIGN KEY(value) REFERENCES another_citus_local_table(value);') +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507009, 'citus_local_table_triggers', 1507009, 'citus_local_table_triggers', '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; -NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507000, 'citus_local_table_triggers', 1507008, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(value) REFERENCES another_citus_local_table(value) ON UPDATE CASCADE;') +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1507001, 'citus_local_table_triggers', 1507009, 'citus_local_table_triggers', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_c_to_c FOREIGN KEY(value) REFERENCES another_citus_local_table(value) ON UPDATE CASCADE;') CREATE TABLE reference_table(value int); SELECT create_reference_table('reference_table'); create_reference_table @@ -390,14 +401,14 @@ BEGIN; FOR EACH STATEMENT EXECUTE FUNCTION insert_100(); TRUNCATE another_citus_local_table CASCADE; NOTICE: truncate cascades to table "citus_local_table" -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100) NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.another_citus_local_table_xxxxx CASCADE NOTICE: truncate cascades to table "citus_local_table_xxxxx" -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100) NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_triggers.citus_local_table_xxxxx CASCADE -- we should see two rows with "100" SELECT * FROM reference_table; -NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507009 reference_table +NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507010 reference_table value --------------------------------------------------------------------- 100 @@ -408,28 +419,28 @@ ROLLBACK; BEGIN; -- update should actually update something to test ON UPDATE CASCADE logic INSERT INTO another_citus_local_table VALUES (600); -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.another_citus_local_table_1507008 (value) VALUES (600) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.another_citus_local_table_1507009 (value) VALUES (600) INSERT INTO citus_local_table VALUES (600); -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507000 (value) VALUES (600) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.citus_local_table_1507001 (value) VALUES (600) CREATE TRIGGER insert_100_trigger AFTER UPDATE ON another_citus_local_table FOR EACH STATEMENT EXECUTE FUNCTION insert_100(); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507008, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507009, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger AFTER UPDATE ON another_citus_local_table FOR EACH STATEMENT EXECUTE FUNCTION insert_100();') CREATE TRIGGER insert_100_trigger AFTER UPDATE ON citus_local_table FOR EACH STATEMENT EXECUTE FUNCTION insert_100(); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507000, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1507001, 'citus_local_table_triggers', 'CREATE TRIGGER insert_100_trigger AFTER UPDATE ON citus_local_table FOR EACH STATEMENT EXECUTE FUNCTION insert_100();') UPDATE another_citus_local_table SET value=value-1;; -NOTICE: executing the command locally: UPDATE citus_local_table_triggers.another_citus_local_table_1507008 another_citus_local_table SET value = (value OPERATOR(pg_catalog.-) 1) -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100) -NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507009 (value) VALUES (100) +NOTICE: executing the command locally: UPDATE citus_local_table_triggers.another_citus_local_table_1507009 another_citus_local_table SET value = (value OPERATOR(pg_catalog.-) 1) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100) +NOTICE: executing the command locally: INSERT INTO citus_local_table_triggers.reference_table_1507010 (value) VALUES (100) -- we should see two rows with "100" SELECT * FROM reference_table; -NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507009 reference_table +NOTICE: executing the command locally: SELECT value FROM citus_local_table_triggers.reference_table_1507010 reference_table value --------------------------------------------------------------------- 100 @@ -439,4 +450,4 @@ NOTICE: executing the command locally: SELECT value FROM citus_local_table_trig ROLLBACK; -- cleanup at exit DROP SCHEMA citus_local_table_triggers, "interesting!schema" CASCADE; -NOTICE: drop cascades to 11 other objects +NOTICE: drop cascades to 13 other objects diff --git a/src/test/regress/expected/citus_local_tables_queries.out b/src/test/regress/expected/citus_local_tables_queries.out index 34f254912..581e7437f 100644 --- a/src/test/regress/expected/citus_local_tables_queries.out +++ b/src/test/regress/expected/citus_local_tables_queries.out @@ -14,20 +14,19 @@ SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0); (1 row) RESET client_min_messages; +CREATE TABLE dummy_reference_table(a int unique, b int); +SELECT create_reference_table('dummy_reference_table'); + create_reference_table +--------------------------------------------------------------------- + +(1 row) + CREATE TABLE citus_local_table(a int, b int); -SELECT create_citus_local_table('citus_local_table'); - create_citus_local_table ---------------------------------------------------------------------- - -(1 row) - +ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509001, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);') CREATE TABLE citus_local_table_2(a int, b int); -SELECT create_citus_local_table('citus_local_table_2'); - create_citus_local_table ---------------------------------------------------------------------- - -(1 row) - +ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509002, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);') CREATE TABLE reference_table(a int, b int); SELECT create_reference_table('reference_table'); create_reference_table @@ -53,8 +52,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$ BEGIN SET client_min_messages to ERROR; - TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table; + TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2; + INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i; INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i; @@ -75,14 +75,14 @@ SELECT clear_and_init_test_tables(); -- join between citus local tables and reference tables would succeed SELECT count(*) FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a; -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.reference_table_1509002 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.reference_table_1509003 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) count --------------------------------------------------------------------- 6 (1 row) SELECT * FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a ORDER BY 1,2,3,4 FOR UPDATE; -NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.reference_table_1509002 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table +NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.reference_table_1509003 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table a | b | a | b --------------------------------------------------------------------- 0 | 0 | 0 | 0 @@ -97,7 +97,7 @@ NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_ WITH cte_1 AS (SELECT * FROM citus_local_table, reference_table WHERE citus_local_table.a = reference_table.a ORDER BY 1,2,3,4 FOR UPDATE) SELECT count(*) FROM cte_1; -NOTICE: executing the command locally: WITH cte_1 AS (SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.reference_table_1509002 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table) SELECT count(*) AS count FROM cte_1 cte_1(a, b, a_1, b_1) +NOTICE: executing the command locally: WITH cte_1 AS (SELECT citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.reference_table_1509003 reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) ORDER BY citus_local_table.a, citus_local_table.b, reference_table.a, reference_table.b FOR UPDATE OF citus_local_table FOR UPDATE OF reference_table) SELECT count(*) AS count FROM cte_1 cte_1(a, b, a_1, b_1) count --------------------------------------------------------------------- 6 @@ -112,7 +112,7 @@ cte_distributed_table AS (SELECT * FROM distributed_table) SELECT count(*) FROM cte_distributed_table, cte_citus_local_table, cte_postgres_local_table WHERE cte_citus_local_table.a = 1 AND cte_distributed_table.a = 1; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 @@ -126,7 +126,7 @@ SELECT count(*) FROM ( SELECT * FROM (SELECT * FROM citus_local_table) as subquery_inner ) as subquery_top; -NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.a, subquery_inner.b FROM (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table) subquery_inner) subquery_top +NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.a, subquery_inner.b FROM (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table) subquery_inner) subquery_top count --------------------------------------------------------------------- 6 @@ -143,7 +143,7 @@ SELECT count(*) FROM ( SELECT * FROM (SELECT count(*) FROM citus_local_table, postgres_local_table) as subquery_inner ) as subquery_top; -NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.count FROM (SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.postgres_local_table) subquery_inner) subquery_top +NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.count FROM (SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.postgres_local_table) subquery_inner) subquery_top count --------------------------------------------------------------------- 1 @@ -154,7 +154,7 @@ SELECT count(*) FROM ( SELECT *, random() FROM (SELECT *, random() FROM citus_local_table, distributed_table) as subquery_inner ) as subquery_top; -NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true +NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true count --------------------------------------------------------------------- 36 @@ -167,7 +167,7 @@ SELECT count(*) FROM FROM ( WITH cte_1 AS (SELECT *, random() FROM citus_local_table, distributed_table) SELECT * FROM cte_1) as subquery_inner ) as subquery_top; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.a, subquery_inner.b, subquery_inner.a_1 AS a, subquery_inner.b_1 AS b, subquery_inner.random, random() AS random FROM (SELECT cte_1.a, cte_1.b, cte_1.a_1 AS a, cte_1.b_1 AS b, cte_1.random FROM (SELECT intermediate_result.a, intermediate_result.b, intermediate_result.a_1 AS a, intermediate_result.b_1 AS b, intermediate_result.random FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer, a_1 integer, b_1 integer, random double precision)) cte_1(a, b, a_1, b_1, random)) subquery_inner(a, b, a_1, b_1, random)) subquery_top(a, b, a_1, b_1, random, random_1) count --------------------------------------------------------------------- @@ -182,7 +182,7 @@ SELECT count(*) FROM WITH cte_1 AS (SELECT *, random() FROM citus_local_table), cte_2 AS (SELECT * FROM distributed_table) SELECT count(*) FROM cte_1, cte_2 ) as subquery_inner ) as subquery_top; -NOTICE: executing the command locally: SELECT a, b, random() AS random FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b, random() AS random FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT subquery_inner.count, random() AS random FROM (SELECT intermediate_result.count FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) subquery_inner) subquery_top count --------------------------------------------------------------------- @@ -199,42 +199,42 @@ SELECT clear_and_init_test_tables(); PREPARE citus_local_only AS SELECT count(*) FROM citus_local_table; -- execute 6 times, local tables without params EXECUTE citus_local_only; -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 (1 row) EXECUTE citus_local_only; -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 (1 row) EXECUTE citus_local_only; -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 (1 row) EXECUTE citus_local_only; -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 (1 row) EXECUTE citus_local_only; -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 (1 row) EXECUTE citus_local_only; -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 @@ -243,42 +243,42 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_loca -- execute 6 times, with param PREPARE citus_local_only_p(int) AS SELECT count(*) FROM citus_local_table WHERE a = $1; EXECUTE citus_local_only_p(1); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE citus_local_only_p(1); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE citus_local_only_p(1); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE citus_local_only_p(1); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE citus_local_only_p(1); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE citus_local_only_p(1); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 @@ -287,14 +287,14 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_loca -- do not evalute the function -- show the logs EXECUTE citus_local_only_p(random()); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE citus_local_only_p(random()); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) $1) count --------------------------------------------------------------------- 1 @@ -310,49 +310,49 @@ PREPARE mixed_query(int, int, int) AS cte_mixes AS (SELECT * FROM cte_distributed_table, cte_citus_local_table, cte_postgres_local_table) SELECT count(*) FROM cte_mixes; EXECUTE mixed_query(1,2,3); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE mixed_query(1,2,3); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE mixed_query(1,2,3); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE mixed_query(1,2,3); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE mixed_query(1,2,3); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE mixed_query(1,2,3); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) count --------------------------------------------------------------------- 1 (1 row) EXECUTE mixed_query(1,2,3); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) 1) count --------------------------------------------------------------------- 1 @@ -366,7 +366,7 @@ SELECT clear_and_init_test_tables(); -- anonymous columns WITH a AS (SELECT a, '' FROM citus_local_table GROUP BY a) SELECT a.a FROM a ORDER BY 1 LIMIT 5; -NOTICE: executing the command locally: SELECT a FROM (SELECT citus_local_table.a, ''::text FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table GROUP BY citus_local_table.a) a(a, "?column?") ORDER BY a LIMIT 5 +NOTICE: executing the command locally: SELECT a FROM (SELECT citus_local_table.a, ''::text FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table GROUP BY citus_local_table.a) a(a, "?column?") ORDER BY a LIMIT 5 a --------------------------------------------------------------------- 0 @@ -377,7 +377,7 @@ NOTICE: executing the command locally: SELECT a FROM (SELECT citus_local_table. (5 rows) WITH a AS (SELECT b, '' FROM citus_local_table WHERE a = 1) SELECT * FROM a, a b ORDER BY 1 LIMIT 5; -NOTICE: executing the command locally: WITH a AS (SELECT citus_local_table.b, ''::text FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) 1)) SELECT a.b, a."?column?", b.b, b."?column?" FROM a a(b, "?column?"), a b(b, "?column?") ORDER BY a.b LIMIT 5 +NOTICE: executing the command locally: WITH a AS (SELECT citus_local_table.b, ''::text FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) 1)) SELECT a.b, a."?column?", b.b, b."?column?" FROM a a(b, "?column?"), a b(b, "?column?") ORDER BY a.b LIMIT 5 b | ?column? | b | ?column? --------------------------------------------------------------------- 1 | | 1 | @@ -388,7 +388,7 @@ SELECT * FROM citus_local_table, postgres_local_table WHERE citus_local_table.a - postgres_local_table.a = 0 ORDER BY 1,2,3,4 LIMIT 10; -NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.-) postgres_local_table.a) OPERATOR(pg_catalog.=) 0) ORDER BY citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b LIMIT 10 +NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.-) postgres_local_table.a) OPERATOR(pg_catalog.=) 0) ORDER BY citus_local_table.a, citus_local_table.b, postgres_local_table.a, postgres_local_table.b LIMIT 10 a | b | a | b --------------------------------------------------------------------- 0 | 0 | 0 | 0 @@ -401,7 +401,7 @@ NOTICE: executing the command locally: SELECT citus_local_table.a, citus_local_ -- set operations should just work SELECT * FROM citus_local_table UNION SELECT * FROM postgres_local_table UNION SELECT * FROM distributed_table ORDER BY 1,2; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table NOTICE: executing the command locally: SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) UNION SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) UNION SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer) ORDER BY 1, 2 a | b --------------------------------------------------------------------- @@ -414,7 +414,7 @@ NOTICE: executing the command locally: SELECT intermediate_result.a, intermedia (6 rows) (SELECT * FROM citus_local_table ORDER BY 1,2 LIMIT 5) INTERSECT (SELECT i, i FROM generate_series(0, 100) i) ORDER BY 1, 2; -NOTICE: executing the command locally: (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY citus_local_table.a, citus_local_table.b LIMIT 5) INTERSECT SELECT i.i, i.i FROM generate_series(0, 100) i(i) ORDER BY 1, 2 +NOTICE: executing the command locally: (SELECT citus_local_table.a, citus_local_table.b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY citus_local_table.a, citus_local_table.b LIMIT 5) INTERSECT SELECT i.i, i.i FROM generate_series(0, 100) i(i) ORDER BY 1, 2 a | b --------------------------------------------------------------------- 0 | 0 @@ -426,28 +426,28 @@ NOTICE: executing the command locally: (SELECT citus_local_table.a, citus_local -- should just work as recursive planner kicks in SELECT count(*) FROM distributed_table WHERE a IN (SELECT a FROM citus_local_table); -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table count --------------------------------------------------------------------- 6 (1 row) SELECT count(*) FROM citus_local_table WHERE a IN (SELECT a FROM distributed_table); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) count --------------------------------------------------------------------- 6 (1 row) SELECT count(*) FROM reference_table WHERE a IN (SELECT a FROM citus_local_table); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.reference_table_1509002 reference_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT citus_local_table.a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table)) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.reference_table_1509003 reference_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT citus_local_table.a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table)) count --------------------------------------------------------------------- 6 (1 row) SELECT count(*) FROM citus_local_table WHERE a IN (SELECT a FROM reference_table); -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT reference_table.a FROM citus_local_table_queries.reference_table_1509002 reference_table)) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT reference_table.a FROM citus_local_table_queries.reference_table_1509003 reference_table)) count --------------------------------------------------------------------- 6 @@ -458,8 +458,8 @@ SELECT count(*) FROM citus_local_table WHERE a IN (SELECT a FROM distributed_table WHERE a IN (SELECT b FROM citus_local_table WHERE b IN (SELECT b FROM postgres_local_table))); -NOTICE: executing the command locally: SELECT b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(b integer))) -NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) +NOTICE: executing the command locally: SELECT b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(b integer))) +NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) count --------------------------------------------------------------------- 6 @@ -467,7 +467,7 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM citus_loca -- local outer joins SELECT count(*) FROM citus_local_table LEFT JOIN reference_table ON (true); -NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509000 citus_local_table LEFT JOIN citus_local_table_queries.reference_table_1509002 reference_table ON (true)) +NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509001 citus_local_table LEFT JOIN citus_local_table_queries.reference_table_1509003 reference_table ON (true)) count --------------------------------------------------------------------- 36 @@ -477,7 +477,7 @@ SELECT count(*) FROM reference_table LEFT JOIN citus_local_table ON (true) LEFT JOIN postgres_local_table ON (true) LEFT JOIN reference_table r2 ON (true); -NOTICE: executing the command locally: SELECT count(*) AS count FROM (((citus_local_table_queries.reference_table_1509002 reference_table LEFT JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) LEFT JOIN citus_local_table_queries.postgres_local_table ON (true)) LEFT JOIN citus_local_table_queries.reference_table_1509002 r2 ON (true)) +NOTICE: executing the command locally: SELECT count(*) AS count FROM (((citus_local_table_queries.reference_table_1509003 reference_table LEFT JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) LEFT JOIN citus_local_table_queries.postgres_local_table ON (true)) LEFT JOIN citus_local_table_queries.reference_table_1509003 r2 ON (true)) count --------------------------------------------------------------------- 1296 @@ -500,7 +500,7 @@ ORDER BY 1, 2 LIMIT 1; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (b OPERATOR(pg_catalog.=) 1) +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (b OPERATOR(pg_catalog.=) 1) a | b --------------------------------------------------------------------- 1 | 1 @@ -519,7 +519,7 @@ ORDER BY 1 ,2 LIMIT 1; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) ORDER BY a, b LIMIT 1 +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (b OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) ORDER BY a, b LIMIT 1 a | b --------------------------------------------------------------------- 1 | 1 @@ -527,7 +527,7 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri -- join between citus local tables and distributed tables would fail SELECT count(*) FROM citus_local_table, distributed_table; -NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true +NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true count --------------------------------------------------------------------- 36 @@ -539,7 +539,7 @@ ERROR: could not run distributed query with FOR UPDATE/SHARE commands SELECT count(citus_local_table.b), count(postgres_local_table.a) FROM citus_local_table, postgres_local_table WHERE citus_local_table.a = postgres_local_table.b; -NOTICE: executing the command locally: SELECT count(citus_local_table.b) AS count, count(postgres_local_table.a) AS count FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table, citus_local_table_queries.postgres_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) postgres_local_table.b) +NOTICE: executing the command locally: SELECT count(citus_local_table.b) AS count, count(postgres_local_table.a) AS count FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table, citus_local_table_queries.postgres_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) postgres_local_table.b) count | count --------------------------------------------------------------------- 6 | 6 @@ -547,7 +547,7 @@ NOTICE: executing the command locally: SELECT count(citus_local_table.b) AS cou -- select for update is just OK SELECT * FROM citus_local_table ORDER BY 1,2 FOR UPDATE; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b FOR UPDATE OF citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b FOR UPDATE OF citus_local_table a | b --------------------------------------------------------------------- 0 | 0 @@ -570,32 +570,32 @@ SELECT clear_and_init_test_tables(); INSERT INTO citus_local_table SELECT * from reference_table; -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.reference_table_1509002 reference_table +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.reference_table_1509003 reference_table INSERT INTO reference_table SELECT * from citus_local_table; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table NOTICE: executing the copy locally for shard xxxxx INSERT INTO citus_local_table SELECT * from distributed_table; NOTICE: executing the copy locally for shard xxxxx INSERT INTO distributed_table SELECT * from citus_local_table; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table INSERT INTO citus_local_table SELECT * from citus_local_table_2; -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2 +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2 INSERT INTO citus_local_table SELECT * from citus_local_table_2 ORDER BY 1,2 LIMIT 10; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2 ORDER BY a, b LIMIT 10 +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2 ORDER BY a, b LIMIT 10 NOTICE: executing the copy locally for shard xxxxx INSERT INTO citus_local_table SELECT * from postgres_local_table; NOTICE: executing the copy locally for shard xxxxx INSERT INTO postgres_local_table SELECT * from citus_local_table; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table -- INSERT SELECT with local joins are OK SELECT clear_and_init_test_tables(); clear_and_init_test_tables @@ -606,16 +606,16 @@ SELECT clear_and_init_test_tables(); INSERT INTO citus_local_table SELECT reference_table.* FROM reference_table JOIN citus_local_table ON (true); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) INSERT INTO reference_table SELECT reference_table.* FROM reference_table JOIN citus_local_table ON (true); -NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) +NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) NOTICE: executing the copy locally for shard xxxxx INSERT INTO reference_table SELECT reference_table.* FROM reference_table, postgres_local_table JOIN citus_local_table ON (true); -NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509002 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) +NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509003 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) NOTICE: executing the copy locally for shard xxxxx SELECT clear_and_init_test_tables(); clear_and_init_test_tables @@ -626,15 +626,15 @@ SELECT clear_and_init_test_tables(); INSERT INTO distributed_table SELECT reference_table.* FROM reference_table JOIN citus_local_table ON (true); -NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) +NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) INSERT INTO distributed_table SELECT reference_table.* FROM reference_table, postgres_local_table JOIN citus_local_table ON (true); -NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509002 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) +NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM citus_local_table_queries.reference_table_1509003 reference_table, (citus_local_table_queries.postgres_local_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) INSERT INTO postgres_local_table SELECT reference_table.* FROM reference_table JOIN citus_local_table ON (true); -NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509002 reference_table JOIN citus_local_table_queries.citus_local_table_1509000 citus_local_table ON (true)) +NOTICE: executing the command locally: SELECT reference_table.a, reference_table.b FROM (citus_local_table_queries.reference_table_1509003 reference_table JOIN citus_local_table_queries.citus_local_table_1509001 citus_local_table ON (true)) -- INSERT SELECT that joins reference and distributed tables is also OK SELECT clear_and_init_test_tables(); clear_and_init_test_tables @@ -654,17 +654,17 @@ NOTICE: executing the copy locally for shard xxxxx INSERT INTO citus_local_table SELECT distributed_table.* FROM distributed_table JOIN citus_local_table ON (true); -NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true +NOTICE: executing the command locally: SELECT NULL::integer AS "dummy-1" FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true NOTICE: executing the copy locally for shard xxxxx -- .. but when wrapped into a CTE, join works fine INSERT INTO citus_local_table SELECT distributed_table.* FROM distributed_table JOIN (WITH cte AS (SELECT * FROM citus_local_table) SELECT * FROM cte) as foo ON (true); -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table NOTICE: executing the copy locally for shard xxxxx -- multi row insert is OK INSERT INTO citus_local_table VALUES (1, 2), (3, 4); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a, b) VALUES (1,2), (3,4) +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a, b) VALUES (1,2), (3,4) --------------------------------------------------------------------- ----- DELETE / UPDATE ----- --------------------------------------------------------------------- @@ -679,83 +679,83 @@ SELECT clear_and_init_test_tables(); DELETE FROM citus_local_table USING postgres_local_table WHERE citus_local_table.b = postgres_local_table.b; -NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table USING citus_local_table_queries.postgres_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b) +NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table USING citus_local_table_queries.postgres_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b) UPDATE citus_local_table SET b = 5 FROM postgres_local_table WHERE citus_local_table.a = 3 AND citus_local_table.b = postgres_local_table.b; -NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 5 FROM citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)) +NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 5 FROM citus_local_table_queries.postgres_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)) DELETE FROM postgres_local_table USING citus_local_table WHERE citus_local_table.b = postgres_local_table.b; -NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.postgres_local_table USING citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b) +NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.postgres_local_table USING citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b) UPDATE postgres_local_table SET b = 5 FROM citus_local_table WHERE citus_local_table.a = 3 AND citus_local_table.b = postgres_local_table.b; -NOTICE: executing the command locally: UPDATE citus_local_table_queries.postgres_local_table SET b = 5 FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)) +NOTICE: executing the command locally: UPDATE citus_local_table_queries.postgres_local_table SET b = 5 FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE ((citus_local_table.a OPERATOR(pg_catalog.=) 3) AND (citus_local_table.b OPERATOR(pg_catalog.=) postgres_local_table.b)) -- no direct joins supported UPDATE distributed_table SET b = 6 FROM citus_local_table WHERE citus_local_table.a = distributed_table.a; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true UPDATE reference_table SET b = 6 FROM citus_local_table WHERE citus_local_table.a = reference_table.a; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true -NOTICE: executing the command locally: UPDATE citus_local_table_queries.reference_table_1509002 reference_table SET b = 6 FROM (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true +NOTICE: executing the command locally: UPDATE citus_local_table_queries.reference_table_1509003 reference_table SET b = 6 FROM (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) -- should not work, add HINT use CTEs UPDATE citus_local_table SET b = 6 FROM distributed_table WHERE citus_local_table.a = distributed_table.a; -NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 6 FROM (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a) +NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 6 FROM (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a) -- should work, add HINT use CTEs UPDATE citus_local_table SET b = 6 FROM reference_table WHERE citus_local_table.a = reference_table.a; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509002 reference_table WHERE true -NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 6 FROM (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509003 reference_table WHERE true +NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 6 FROM (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) -- should not work, add HINT use CTEs DELETE FROM distributed_table USING citus_local_table WHERE citus_local_table.a = distributed_table.a; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true -- should not work, add HINT use CTEs DELETE FROM citus_local_table USING distributed_table WHERE citus_local_table.a = distributed_table.a; -NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table USING (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a) +NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table USING (SELECT distributed_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) distributed_table_1) distributed_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table.a) DELETE FROM reference_table USING citus_local_table WHERE citus_local_table.a = reference_table.a; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true -NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.reference_table_1509002 reference_table USING (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true +NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.reference_table_1509003 reference_table USING (SELECT citus_local_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_1) citus_local_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) -- should work, add HINT use CTEs DELETE FROM citus_local_table USING reference_table WHERE citus_local_table.a = reference_table.a; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509002 reference_table WHERE true -NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table USING (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509003 reference_table WHERE true +NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table USING (SELECT reference_table_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) reference_table_1) reference_table WHERE (citus_local_table.a OPERATOR(pg_catalog.=) reference_table.a) -- just works DELETE FROM citus_local_table WHERE citus_local_table.a IN (SELECT a FROM distributed_table); -NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) +NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) -- just works DELETE FROM citus_local_table WHERE citus_local_table.a IN (SELECT a FROM reference_table); -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509002 reference_table -NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.reference_table_1509003 reference_table +NOTICE: executing the command locally: DELETE FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE (a OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer))) -- just works WITH distributed_table_cte AS (SELECT * FROM distributed_table) UPDATE citus_local_table SET b = 6 FROM distributed_table_cte WHERE citus_local_table.a = distributed_table_cte.a; -NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET b = 6 FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) distributed_table_cte WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table_cte.a) +NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET b = 6 FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) distributed_table_cte WHERE (citus_local_table.a OPERATOR(pg_catalog.=) distributed_table_cte.a) SET citus.log_local_commands to off; -- just works WITH reference_table_cte AS (SELECT * FROM reference_table) @@ -772,7 +772,7 @@ SELECT count(*) FROM citus_local_table JOIN reference_table USING (a); -NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509000 citus_local_table(a, b) JOIN citus_local_table_queries.reference_table_1509002 reference_table(a, b) USING (a)) +NOTICE: executing the command locally: SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_1509001 citus_local_table(a, b) JOIN citus_local_table_queries.reference_table_1509003 reference_table(a, b) USING (a)) -- ok SELECT count(*) FROM mat_view_4; count @@ -795,8 +795,8 @@ JOIN citus_local_table_2 USING (a) JOIN distributed_table USING (a); -- should fail as view contains direct local dist join SELECT count(*) FROM view_2; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table WHERE true -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2 WHERE true +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table WHERE true +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2 WHERE true NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT intermediate_result.count FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) view_2 count --------------------------------------------------------------------- @@ -810,7 +810,7 @@ JOIN reference_table USING (a); -- ok SELECT count(*) FROM view_3; -NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2(a, b) JOIN citus_local_table_queries.reference_table_1509002 reference_table(a, b) USING (a))) view_3 +NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT count(*) AS count FROM (citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2(a, b) JOIN citus_local_table_queries.reference_table_1509003 reference_table(a, b) USING (a))) view_3 count --------------------------------------------------------------------- 1 @@ -818,8 +818,8 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM (SELECT co -- view treated as subquery, so should work SELECT count(*) FROM view_3, distributed_table; -NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2 WHERE true -NOTICE: executing the command locally: SELECT count(*) AS count FROM ((SELECT citus_local_table_2_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_2_1) citus_local_table_2 JOIN citus_local_table_queries.reference_table_1509002 reference_table(a, b) USING (a)) +NOTICE: executing the command locally: SELECT a FROM citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2 WHERE true +NOTICE: executing the command locally: SELECT count(*) AS count FROM ((SELECT citus_local_table_2_1.a, NULL::integer AS b FROM (SELECT intermediate_result.a FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer)) citus_local_table_2_1) citus_local_table_2 JOIN citus_local_table_queries.reference_table_1509003 reference_table(a, b) USING (a)) count --------------------------------------------------------------------- 6 @@ -845,10 +845,10 @@ JOIN (SELECT count(*) as a, count(*) as b USING (a)) subquery7132 USING (b)) subquery7294 USING (a); -NOTICE: executing the command locally: SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.reference_table_1509002 reference_table(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.citus_local_table_2_1509001 citus_local_table_2(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.postgres_local_table JOIN (SELECT count(*) AS a, count(*) AS b FROM citus_local_table_queries.reference_table_1509002 table_4677) subquery5108 USING (a))) subquery7132 USING (b))) subquery7294 USING (a)) +NOTICE: executing the command locally: SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.reference_table_1509003 reference_table(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.citus_local_table_2_1509002 citus_local_table_2(a, b) JOIN (SELECT count(*) AS a, count(*) AS b FROM (citus_local_table_queries.postgres_local_table JOIN (SELECT count(*) AS a, count(*) AS b FROM citus_local_table_queries.reference_table_1509003 table_4677) subquery5108 USING (a))) subquery7132 USING (b))) subquery7294 USING (a)) a | b --------------------------------------------------------------------- - 0 | 0 + 1 | 1 (1 row) -- direct join inside CTE not supported @@ -857,7 +857,7 @@ UPDATE citus_local_table lt SET a = mt.a FROM distributed_table mt WHERE mt.b = lt.b RETURNING lt.b, lt.a ) SELECT * FROM cte JOIN distributed_table mt ON mt.b = cte.b ORDER BY 1,2,3,4; -NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 lt SET a = mt.a FROM (SELECT mt_1.a, mt_1.b FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) mt_1) mt WHERE (mt.b OPERATOR(pg_catalog.=) lt.b) RETURNING lt.b, lt.a +NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 lt SET a = mt.a FROM (SELECT mt_1.a, mt_1.b FROM (SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) mt_1) mt WHERE (mt.b OPERATOR(pg_catalog.=) lt.b) RETURNING lt.b, lt.a b | a | a | b --------------------------------------------------------------------- 0 | 0 | 0 | 0 @@ -875,14 +875,14 @@ FROM (SELECT avg(distributed_table.b) as avg_b FROM distributed_table) as foo WHERE foo.avg_b = citus_local_table.b; -NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509000 citus_local_table SET a = 5 FROM (SELECT intermediate_result.avg_b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(avg_b numeric)) foo WHERE (foo.avg_b OPERATOR(pg_catalog.=) (citus_local_table.b)::numeric) +NOTICE: executing the command locally: UPDATE citus_local_table_queries.citus_local_table_1509001 citus_local_table SET a = 5 FROM (SELECT intermediate_result.avg_b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(avg_b numeric)) foo WHERE (foo.avg_b OPERATOR(pg_catalog.=) (citus_local_table.b)::numeric) -- should work UPDATE distributed_table SET b = avg_a FROM (SELECT avg(citus_local_table.a) as avg_a FROM citus_local_table) as foo WHERE foo.avg_a = distributed_table.a RETURNING distributed_table.*; -NOTICE: executing the command locally: SELECT avg(a) AS avg_a FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT avg(a) AS avg_a FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table a | b --------------------------------------------------------------------- (0 rows) @@ -918,7 +918,7 @@ LIMIT 10; -> Limit -> Sort Sort Key: distributed_table.* - -> Seq Scan on distributed_table_1509003 distributed_table + -> Seq Scan on distributed_table_1509004 distributed_table (14 rows) -- show that we do not pull to coordinator @@ -932,8 +932,8 @@ SELECT * FROM citus_local_table; Tasks Shown: All -> Task Node: host=localhost port=xxxxx dbname=regression - -> Insert on citus_local_table_1509000 citus_table_alias - -> Seq Scan on citus_local_table_1509000 citus_local_table + -> Insert on citus_local_table_1509001 citus_table_alias + -> Seq Scan on citus_local_table_1509001 citus_local_table (7 rows) EXPLAIN (COSTS FALSE) @@ -946,8 +946,8 @@ SELECT reference_table.* FROM reference_table; Tasks Shown: All -> Task Node: host=localhost port=xxxxx dbname=regression - -> Insert on citus_local_table_1509000 citus_table_alias - -> Seq Scan on reference_table_1509002 reference_table + -> Insert on citus_local_table_1509001 citus_table_alias + -> Seq Scan on reference_table_1509003 reference_table (7 rows) EXPLAIN (COSTS FALSE) @@ -963,7 +963,7 @@ SELECT reference_table.* FROM reference_table, postgres_local_table; -> Task Node: host=localhost port=xxxxx dbname=regression -> Nested Loop - -> Seq Scan on reference_table_1509002 reference_table + -> Seq Scan on reference_table_1509003 reference_table -> Materialize -> Seq Scan on postgres_local_table (11 rows) @@ -982,9 +982,9 @@ SELECT reference_table.* FROM reference_table, distributed_table; -> Task Node: host=localhost port=xxxxx dbname=regression -> Nested Loop - -> Seq Scan on distributed_table_1509003 distributed_table + -> Seq Scan on distributed_table_1509004 distributed_table -> Materialize - -> Seq Scan on reference_table_1509002 reference_table + -> Seq Scan on reference_table_1509003 reference_table (11 rows) -- truncate tables & add unique constraints to be able to define foreign keys @@ -992,21 +992,21 @@ TRUNCATE reference_table, citus_local_table, distributed_table; NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.reference_table_xxxxx CASCADE NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.citus_local_table_xxxxx CASCADE ALTER TABLE reference_table ADD CONSTRAINT pkey_ref PRIMARY KEY (a); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509002, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT pkey_ref PRIMARY KEY (a);') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509003, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT pkey_ref PRIMARY KEY (a);') ALTER TABLE citus_local_table ADD CONSTRAINT pkey_c PRIMARY KEY (a); -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table ADD CONSTRAINT pkey_c PRIMARY KEY (a);') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509001, 'citus_local_table_queries', 'ALTER TABLE citus_local_table ADD CONSTRAINT pkey_c PRIMARY KEY (a);') -- define a foreign key chain distributed table -> reference table -> citus local table -- to test sequential execution ALTER TABLE distributed_table ADD CONSTRAINT fkey_dist_to_ref FOREIGN KEY(a) REFERENCES reference_table(a) ON DELETE RESTRICT; ALTER TABLE reference_table ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(a) REFERENCES citus_local_table(a) ON DELETE RESTRICT; -NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509002, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(a) REFERENCES citus_local_table(a) ON DELETE RESTRICT;') +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509003, 'citus_local_table_queries', 1509001, 'citus_local_table_queries', 'ALTER TABLE reference_table ADD CONSTRAINT fkey_ref_to_local FOREIGN KEY(a) REFERENCES citus_local_table(a) ON DELETE RESTRICT;') INSERT INTO citus_local_table VALUES (1); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 (a) VALUES (1) +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 (a) VALUES (1) INSERT INTO reference_table VALUES (1); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509002 (a) VALUES (1) +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509003 (a) VALUES (1) BEGIN; INSERT INTO citus_local_table VALUES (1) ON CONFLICT (a) DO NOTHING; -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING INSERT INTO distributed_table VALUES (1); -- should show sequential as first inserting into citus local table -- would force the xact block to use sequential execution @@ -1042,7 +1042,7 @@ ROLLBACK; ALTER TABLE distributed_table DROP CONSTRAINT fkey_dist_to_ref; BEGIN; INSERT INTO citus_local_table VALUES (1) ON CONFLICT (a) DO NOTHING; -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (1) ON CONFLICT(a) DO NOTHING show citus.multi_shard_modify_mode; citus.multi_shard_modify_mode --------------------------------------------------------------------- @@ -1052,9 +1052,9 @@ NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.ci ROLLBACK; -- remove uniqueness constraint and dependent foreign key constraint for next tests ALTER TABLE reference_table DROP CONSTRAINT fkey_ref_to_local; -NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509002, 'citus_local_table_queries', 1509000, 'citus_local_table_queries', 'ALTER TABLE reference_table DROP CONSTRAINT fkey_ref_to_local;') +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1509003, 'citus_local_table_queries', 1509001, 'citus_local_table_queries', 'ALTER TABLE reference_table DROP CONSTRAINT fkey_ref_to_local;') ALTER TABLE citus_local_table DROP CONSTRAINT pkey_c; -NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509000, 'citus_local_table_queries', 'ALTER TABLE citus_local_table DROP CONSTRAINT pkey_c;') +NOTICE: executing the command locally: SELECT worker_apply_shard_ddl_command (1509001, 'citus_local_table_queries', 'ALTER TABLE citus_local_table DROP CONSTRAINT pkey_c;') COPY citus_local_table(a) FROM PROGRAM 'seq 1'; -- should use local execution BEGIN; @@ -1069,7 +1069,7 @@ COPY citus_local_table TO STDOUT; 1 \N 1 \N COPY (SELECT * FROM citus_local_table) TO STDOUT; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table 1 \N 1 \N 1 \N @@ -1083,7 +1083,7 @@ BEGIN; COMMIT; BEGIN; COPY (SELECT * FROM citus_local_table) TO STDOUT; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table 1 \N 1 \N 1 \N @@ -1095,13 +1095,13 @@ NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries NOTICE: executing the command locally: TRUNCATE TABLE citus_local_table_queries.reference_table_xxxxx CASCADE BEGIN; INSERT INTO citus_local_table VALUES (1), (2); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (1), (2) +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (1), (2) SAVEPOINT sp1; INSERT INTO citus_local_table VALUES (3), (4); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (3), (4) +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (3), (4) ROLLBACK TO SAVEPOINT sp1; SELECT * FROM citus_local_table ORDER BY 1,2; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b a | b --------------------------------------------------------------------- 1 | @@ -1109,12 +1109,12 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri (2 rows) SAVEPOINT sp2; - INSERT INTO citus_local_table VALUES (5), (6); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (5), (6) - INSERT INTO distributed_table VALUES (5), (6); + INSERT INTO citus_local_table VALUES (3), (4); +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (3), (4) + INSERT INTO distributed_table VALUES (3), (4); ROLLBACK TO SAVEPOINT sp2; SELECT * FROM citus_local_table ORDER BY 1,2; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b a | b --------------------------------------------------------------------- 1 | @@ -1127,13 +1127,13 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri (0 rows) SAVEPOINT sp3; - INSERT INTO citus_local_table VALUES (7), (8); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509000 AS citus_table_alias (a) VALUES (7), (8) - INSERT INTO reference_table VALUES (7), (8); -NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509002 AS citus_table_alias (a) VALUES (7), (8) + INSERT INTO citus_local_table VALUES (3), (2); +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.citus_local_table_1509001 AS citus_table_alias (a) VALUES (3), (2) + INSERT INTO reference_table VALUES (3), (2); +NOTICE: executing the command locally: INSERT INTO citus_local_table_queries.reference_table_1509003 AS citus_table_alias (a) VALUES (3), (2) ROLLBACK TO SAVEPOINT sp3; SELECT * FROM citus_local_table ORDER BY 1,2; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509000 citus_local_table ORDER BY a, b +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.citus_local_table_1509001 citus_local_table ORDER BY a, b a | b --------------------------------------------------------------------- 1 | @@ -1141,7 +1141,7 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri (2 rows) SELECT * FROM reference_table ORDER BY 1,2; -NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.reference_table_1509002 reference_table ORDER BY a, b +NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queries.reference_table_1509003 reference_table ORDER BY a, b a | b --------------------------------------------------------------------- (0 rows) @@ -1149,4 +1149,4 @@ NOTICE: executing the command locally: SELECT a, b FROM citus_local_table_queri COMMIT; -- cleanup at exit DROP SCHEMA citus_local_table_queries CASCADE; -NOTICE: drop cascades to 12 other objects +NOTICE: drop cascades to 14 other objects diff --git a/src/test/regress/expected/citus_local_tables_queries_mx.out b/src/test/regress/expected/citus_local_tables_queries_mx.out index ce61c7fdb..6bd2dc227 100644 --- a/src/test/regress/expected/citus_local_tables_queries_mx.out +++ b/src/test/regress/expected/citus_local_tables_queries_mx.out @@ -22,20 +22,19 @@ SELECT start_metadata_sync_to_node('localhost', :worker_1_port); (1 row) SET citus.replication_model TO streaming; +CREATE TABLE dummy_reference_table(a int unique, b int); +SELECT create_reference_table('dummy_reference_table'); + create_reference_table +--------------------------------------------------------------------- + +(1 row) + CREATE TABLE citus_local_table(a int, b int); -SELECT create_citus_local_table('citus_local_table'); - create_citus_local_table ---------------------------------------------------------------------- - -(1 row) - +ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1510001, 'citus_local_table_queries_mx', 1510000, 'citus_local_table_queries_mx', 'ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);') CREATE TABLE citus_local_table_2(a int, b int); -SELECT create_citus_local_table('citus_local_table_2'); - create_citus_local_table ---------------------------------------------------------------------- - -(1 row) - +ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); +NOTICE: executing the command locally: SELECT worker_apply_inter_shard_ddl_command (1510002, 'citus_local_table_queries_mx', 1510000, 'citus_local_table_queries_mx', 'ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a);') CREATE TABLE reference_table(a int, b int); SELECT create_reference_table('reference_table'); create_reference_table @@ -63,8 +62,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$ BEGIN SET client_min_messages to ERROR; - TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table; + TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2; + INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i; INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i; @@ -734,7 +734,7 @@ JOIN (SELECT count(*) as a, count(*) as b USING (a); a | b --------------------------------------------------------------------- - 0 | 0 + 1 | 1 (1 row) -- direct join inside CTE not supported @@ -801,7 +801,7 @@ LIMIT 10; -> Limit -> Sort Sort Key: distributed_table.* - -> Seq Scan on distributed_table_1510003 distributed_table + -> Seq Scan on distributed_table_1510004 distributed_table (14 rows) -- show that we do not pull to coordinator @@ -815,8 +815,8 @@ SELECT * FROM citus_local_table; Tasks Shown: All -> Task Node: host=localhost port=xxxxx dbname=regression - -> Insert on citus_local_table_1510000 citus_table_alias - -> Seq Scan on citus_local_table_1510000 citus_local_table + -> Insert on citus_local_table_1510001 citus_table_alias + -> Seq Scan on citus_local_table_1510001 citus_local_table (7 rows) EXPLAIN (COSTS FALSE) @@ -829,8 +829,8 @@ SELECT reference_table.* FROM reference_table; Tasks Shown: All -> Task Node: host=localhost port=xxxxx dbname=regression - -> Insert on citus_local_table_1510000 citus_table_alias - -> Seq Scan on reference_table_1510002 reference_table + -> Insert on citus_local_table_1510001 citus_table_alias + -> Seq Scan on reference_table_1510003 reference_table (7 rows) EXPLAIN (COSTS FALSE) @@ -846,7 +846,7 @@ SELECT reference_table.* FROM reference_table, postgres_local_table; -> Task Node: host=localhost port=xxxxx dbname=regression -> Nested Loop - -> Seq Scan on reference_table_1510002 reference_table + -> Seq Scan on reference_table_1510003 reference_table -> Materialize -> Seq Scan on postgres_local_table (11 rows) @@ -865,9 +865,9 @@ SELECT reference_table.* FROM reference_table, distributed_table; -> Task Node: host=localhost port=xxxxx dbname=regression -> Nested Loop - -> Seq Scan on distributed_table_1510003 distributed_table + -> Seq Scan on distributed_table_1510004 distributed_table -> Materialize - -> Seq Scan on reference_table_1510002 reference_table + -> Seq Scan on reference_table_1510003 reference_table (11 rows) -- truncate tables & add unique constraints to be able to define foreign keys @@ -983,8 +983,8 @@ BEGIN; (2 rows) SAVEPOINT sp2; - INSERT INTO citus_local_table VALUES (5), (6); - INSERT INTO distributed_table VALUES (5), (6); + INSERT INTO citus_local_table VALUES (3), (4); + INSERT INTO distributed_table VALUES (3), (4); ROLLBACK TO SAVEPOINT sp2; SELECT * FROM citus_local_table ORDER BY 1,2; a | b @@ -999,8 +999,8 @@ BEGIN; (0 rows) SAVEPOINT sp3; - INSERT INTO citus_local_table VALUES (7), (8); - INSERT INTO reference_table VALUES (7), (8); + INSERT INTO citus_local_table VALUES (3), (2); + INSERT INTO reference_table VALUES (3), (2); ROLLBACK TO SAVEPOINT sp3; SELECT * FROM citus_local_table ORDER BY 1,2; a | b @@ -1018,4 +1018,4 @@ COMMIT; \c - - - :master_port -- cleanup at exit DROP SCHEMA citus_local_table_queries_mx CASCADE; -NOTICE: drop cascades to 7 other objects +NOTICE: drop cascades to 9 other objects diff --git a/src/test/regress/expected/undistribute_table_cascade.out b/src/test/regress/expected/undistribute_table_cascade.out index 75c736324..3bfd63bb9 100644 --- a/src/test/regress/expected/undistribute_table_cascade.out +++ b/src/test/regress/expected/undistribute_table_cascade.out @@ -527,10 +527,11 @@ BEGIN; ROLLBACK; BEGIN; + ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_5; ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_7; - -- since now citus_local_table_2 has no foreign keys, show that + -- since now reference_table_2 has no foreign keys, show that -- cascade_via_foreign_keys option still works fine - SELECT undistribute_table('citus_local_table_2', cascade_via_foreign_keys=>true); + SELECT undistribute_table('reference_table_2', cascade_via_foreign_keys=>true); undistribute_table --------------------------------------------------------------------- @@ -539,7 +540,7 @@ BEGIN; SELECT COUNT(*)=0 FROM pg_dist_partition, pg_tables WHERE tablename=logicalrelid::regclass::text AND schemaname='undistribute_table_cascade' AND - tablename='citus_local_table_2'; + tablename='reference_table_2'; ?column? --------------------------------------------------------------------- t diff --git a/src/test/regress/sql/citus_local_table_triggers.sql b/src/test/regress/sql/citus_local_table_triggers.sql index 05f1a8149..efb63ebd5 100644 --- a/src/test/regress/sql/citus_local_table_triggers.sql +++ b/src/test/regress/sql/citus_local_table_triggers.sql @@ -13,8 +13,13 @@ SET client_min_messages to ERROR; SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0); RESET client_min_messages; +CREATE TABLE dummy_reference_table(a int unique, b int); +INSERT INTO dummy_reference_table SELECT i FROM generate_series(-1, 5) i; +INSERT INTO dummy_reference_table VALUES (99),(100),(599),(600); +SELECT create_reference_table('dummy_reference_table'); + CREATE TABLE citus_local_table (value int); -SELECT create_citus_local_table('citus_local_table'); +ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (value) REFERENCES dummy_reference_table(a); -------------------- -- DELETE trigger -- @@ -141,14 +146,15 @@ BEGIN; AFTER TRUNCATE ON "interesting!schema"."citus_local!_table" FOR EACH STATEMENT EXECUTE FUNCTION dummy_function(); - SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"'); + ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a); -- we shouldn't see truncate trigger on shard relation as we drop it - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; ROLLBACK; CREATE TABLE "interesting!schema"."citus_local!_table"(value int); -SELECT create_citus_local_table('"interesting!schema"."citus_local!_table"'); +ALTER TABLE "interesting!schema"."citus_local!_table" ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (value) REFERENCES dummy_reference_table(a); CREATE TRIGGER "trigger\'name" BEFORE INSERT ON "interesting!schema"."citus_local!_table" @@ -168,21 +174,25 @@ BEGIN; DROP EXTENSION seg; -- show that dropping extension drops the triggers automatically - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; ROLLBACK; -- ALTER TRIGGER RENAME ALTER TRIGGER "trigger\'name" ON "interesting!schema"."citus_local!_table" RENAME TO "trigger\'name22"; -- show that triggers on both shell relation and shard relation are renamed -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; -- ALTER TABLE DISABLE trigger ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "trigger\'name22"; -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; -- ALTER TABLE ENABLE trigger ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER "trigger\'name22"; -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; CREATE TRIGGER another_trigger AFTER DELETE ON "interesting!schema"."citus_local!_table" @@ -190,24 +200,29 @@ FOR EACH STATEMENT EXECUTE FUNCTION dummy_function(); ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER USER; -- show that all triggers except the internal ones are disabled -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER USER; -- show that all triggers except the internal ones are enabled again -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER ALL; -- show that all triggers including internal triggers are disabled -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL; -- show that all triggers including internal triggers are enabled again -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; DROP TRIGGER another_trigger ON "interesting!schema"."citus_local!_table"; DROP TRIGGER "trigger\'name22" ON "interesting!schema"."citus_local!_table"; -- show that drop trigger works as expected -SELECT * FROM citus_local_table_triggers; +SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; BEGIN; CREATE TRIGGER "another_trigger\'name" @@ -216,11 +231,13 @@ BEGIN; ALTER TABLE "interesting!schema"."citus_local!_table" DISABLE TRIGGER "another_trigger\'name"; -- show that our truncate trigger is disabled .. - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; ALTER TABLE "interesting!schema"."citus_local!_table" ENABLE TRIGGER ALL; -- .. and now it is enabled back - SELECT * FROM citus_local_table_triggers; + SELECT * FROM citus_local_table_triggers + WHERE tgname NOT LIKE 'RI_ConstraintTrigger%'; ROLLBACK; -- as we create ddl jobs for DROP TRIGGER before standard process utility, diff --git a/src/test/regress/sql/citus_local_tables_queries.sql b/src/test/regress/sql/citus_local_tables_queries.sql index f98ead754..a4f8b6e00 100644 --- a/src/test/regress/sql/citus_local_tables_queries.sql +++ b/src/test/regress/sql/citus_local_tables_queries.sql @@ -13,11 +13,14 @@ SET client_min_messages to ERROR; SELECT 1 FROM master_add_node('localhost', :master_port, groupId => 0); RESET client_min_messages; +CREATE TABLE dummy_reference_table(a int unique, b int); +SELECT create_reference_table('dummy_reference_table'); + CREATE TABLE citus_local_table(a int, b int); -SELECT create_citus_local_table('citus_local_table'); +ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); CREATE TABLE citus_local_table_2(a int, b int); -SELECT create_citus_local_table('citus_local_table_2'); +ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); CREATE TABLE reference_table(a int, b int); SELECT create_reference_table('reference_table'); @@ -37,8 +40,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$ BEGIN SET client_min_messages to ERROR; - TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table; + TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2; + INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i; INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i; @@ -616,16 +620,16 @@ BEGIN; SELECT * FROM citus_local_table ORDER BY 1,2; SAVEPOINT sp2; - INSERT INTO citus_local_table VALUES (5), (6); - INSERT INTO distributed_table VALUES (5), (6); + INSERT INTO citus_local_table VALUES (3), (4); + INSERT INTO distributed_table VALUES (3), (4); ROLLBACK TO SAVEPOINT sp2; SELECT * FROM citus_local_table ORDER BY 1,2; SELECT * FROM distributed_table ORDER BY 1,2; SAVEPOINT sp3; - INSERT INTO citus_local_table VALUES (7), (8); - INSERT INTO reference_table VALUES (7), (8); + INSERT INTO citus_local_table VALUES (3), (2); + INSERT INTO reference_table VALUES (3), (2); ROLLBACK TO SAVEPOINT sp3; SELECT * FROM citus_local_table ORDER BY 1,2; diff --git a/src/test/regress/sql/citus_local_tables_queries_mx.sql b/src/test/regress/sql/citus_local_tables_queries_mx.sql index 17586333f..b1a9e4622 100644 --- a/src/test/regress/sql/citus_local_tables_queries_mx.sql +++ b/src/test/regress/sql/citus_local_tables_queries_mx.sql @@ -17,11 +17,14 @@ RESET client_min_messages; SELECT start_metadata_sync_to_node('localhost', :worker_1_port); SET citus.replication_model TO streaming; +CREATE TABLE dummy_reference_table(a int unique, b int); +SELECT create_reference_table('dummy_reference_table'); + CREATE TABLE citus_local_table(a int, b int); -SELECT create_citus_local_table('citus_local_table'); +ALTER TABLE citus_local_table ADD CONSTRAINT fkey_to_dummy_1 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); CREATE TABLE citus_local_table_2(a int, b int); -SELECT create_citus_local_table('citus_local_table_2'); +ALTER TABLE citus_local_table_2 ADD CONSTRAINT fkey_to_dummy_2 FOREIGN KEY (a) REFERENCES dummy_reference_table(a); CREATE TABLE reference_table(a int, b int); SELECT create_reference_table('reference_table'); @@ -44,8 +47,9 @@ CREATE FUNCTION clear_and_init_test_tables() RETURNS void AS $$ BEGIN SET client_min_messages to ERROR; - TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table; + TRUNCATE postgres_local_table, citus_local_table, reference_table, distributed_table, dummy_reference_table, citus_local_table_2; + INSERT INTO dummy_reference_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table SELECT i, i FROM generate_series(0, 5) i; INSERT INTO citus_local_table_2 SELECT i, i FROM generate_series(0, 5) i; INSERT INTO postgres_local_table SELECT i, i FROM generate_series(0, 5) i; @@ -638,16 +642,16 @@ BEGIN; SELECT * FROM citus_local_table ORDER BY 1,2; SAVEPOINT sp2; - INSERT INTO citus_local_table VALUES (5), (6); - INSERT INTO distributed_table VALUES (5), (6); + INSERT INTO citus_local_table VALUES (3), (4); + INSERT INTO distributed_table VALUES (3), (4); ROLLBACK TO SAVEPOINT sp2; SELECT * FROM citus_local_table ORDER BY 1,2; SELECT * FROM distributed_table ORDER BY 1,2; SAVEPOINT sp3; - INSERT INTO citus_local_table VALUES (7), (8); - INSERT INTO reference_table VALUES (7), (8); + INSERT INTO citus_local_table VALUES (3), (2); + INSERT INTO reference_table VALUES (3), (2); ROLLBACK TO SAVEPOINT sp3; SELECT * FROM citus_local_table ORDER BY 1,2; diff --git a/src/test/regress/sql/undistribute_table_cascade.sql b/src/test/regress/sql/undistribute_table_cascade.sql index b0c446838..d2f347ba5 100644 --- a/src/test/regress/sql/undistribute_table_cascade.sql +++ b/src/test/regress/sql/undistribute_table_cascade.sql @@ -354,16 +354,17 @@ BEGIN; ROLLBACK; BEGIN; + ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_5; ALTER TABLE reference_table_2 DROP CONSTRAINT fkey_7; - -- since now citus_local_table_2 has no foreign keys, show that + -- since now reference_table_2 has no foreign keys, show that -- cascade_via_foreign_keys option still works fine - SELECT undistribute_table('citus_local_table_2', cascade_via_foreign_keys=>true); + SELECT undistribute_table('reference_table_2', cascade_via_foreign_keys=>true); SELECT COUNT(*)=0 FROM pg_dist_partition, pg_tables WHERE tablename=logicalrelid::regclass::text AND schemaname='undistribute_table_cascade' AND - tablename='citus_local_table_2'; + tablename='reference_table_2'; ROLLBACK; CREATE SCHEMA "bad!schemaName";