diff --git a/src/test/regress/expected/multi_mx_call.out b/src/test/regress/expected/multi_mx_call.out new file mode 100644 index 000000000..8bb27d90d --- /dev/null +++ b/src/test/regress/expected/multi_mx_call.out @@ -0,0 +1,38 @@ +-- Test passing off CALL to mx workers +-- Create worker-local tables to test procedure calls were routed +set citus.shard_replication_factor to 1; +set citus.replication_model to 'streaming'; +CREATE TABLE mx_call_dist_table(id int); +select create_distributed_table('mx_call_dist_table', 'id'); + create_distributed_table +-------------------------- + +(1 row) + +insert into mx_call_dist_table values (1),(2),(3),(4),(5); +CREATE PROCEDURE mx_call_proc(x int, INOUT y int) LANGUAGE plpgsql AS $$ +BEGIN + y := x + (select case groupid when 0 then 1 else 0 end from pg_dist_local_group); + y := y + (select sum(id) from mx_call_dist_table); +END; +$$; +select create_distributed_function('mx_call_proc(int,int)'); + create_distributed_function +----------------------------- + +(1 row) + +update citus.pg_dist_object +set distribution_argument_index = 1, colocationid = pg_dist_partition.colocationid +from pg_proc, pg_dist_partition +where proname = 'mx_call_proc' and oid = objid and pg_dist_partition.logicalrelid = 'mx_call_dist_table'::regclass; +call mx_call_proc(2, 0); + y +---- + 17 +(1 row) + +DROP TABLE mx_call_dist_table; +DROP PROCEDURE mx_call_proc; +reset citus.shard_replication_factor; +reset citus.replication_model; diff --git a/src/test/regress/expected/multi_mx_call_0.out b/src/test/regress/expected/multi_mx_call_0.out new file mode 100644 index 000000000..06944ae61 --- /dev/null +++ b/src/test/regress/expected/multi_mx_call_0.out @@ -0,0 +1,40 @@ +-- Test passing off CALL to mx workers +-- Create worker-local tables to test procedure calls were routed +set citus.shard_replication_factor to 1; +set citus.replication_model to 'streaming'; +CREATE TABLE mx_call_dist_table(id int); +select create_distributed_table('mx_call_dist_table', 'id'); + create_distributed_table +-------------------------- + +(1 row) + +insert into mx_call_dist_table values (1),(2),(3),(4),(5); +CREATE PROCEDURE mx_call_proc(x int, INOUT y int) LANGUAGE plpgsql AS $$ +BEGIN + y := x + (select case groupid when 0 then 1 else 0 end from pg_dist_local_group); + y := y + (select sum(id) from mx_call_dist_table); +END; +$$; +ERROR: syntax error at or near "PROCEDURE" +LINE 1: CREATE PROCEDURE mx_call_proc(x int, INOUT y int) LANGUAGE p... + ^ +select create_distributed_function('mx_call_proc(int,int)'); +ERROR: function "mx_call_proc(int,int)" does not exist +LINE 1: select create_distributed_function('mx_call_proc(int,int)'); + ^ +update citus.pg_dist_object +set distribution_argument_index = 1, colocationid = pg_dist_partition.colocationid +from pg_proc, pg_dist_partition +where proname = 'mx_call_proc' and oid = objid and pg_dist_partition.logicalrelid = 'mx_call_dist_table'::regclass; +call mx_call_proc(2, 0); +ERROR: syntax error at or near "call" +LINE 1: call mx_call_proc(2, 0); + ^ +DROP TABLE mx_call_dist_table; +DROP PROCEDURE mx_call_proc; +ERROR: syntax error at or near "PROCEDURE" +LINE 1: DROP PROCEDURE mx_call_proc; + ^ +reset citus.shard_replication_factor; +reset citus.replication_model; diff --git a/src/test/regress/multi_mx_schedule b/src/test/regress/multi_mx_schedule index 47c2956ad..6e19b1f57 100644 --- a/src/test/regress/multi_mx_schedule +++ b/src/test/regress/multi_mx_schedule @@ -32,6 +32,7 @@ test: recursive_dml_queries_mx multi_mx_truncate_from_worker test: multi_mx_repartition_udt_prepare mx_foreign_key_to_reference_table test: multi_mx_repartition_join_w1 multi_mx_repartition_join_w2 multi_mx_repartition_udt_w1 multi_mx_repartition_udt_w2 test: multi_mx_metadata +test: multi_mx_call test: multi_mx_modifications local_shard_execution test: multi_mx_transaction_recovery test: multi_mx_modifying_xacts diff --git a/src/test/regress/sql/multi_mx_call.sql b/src/test/regress/sql/multi_mx_call.sql new file mode 100644 index 000000000..8ff85ffab --- /dev/null +++ b/src/test/regress/sql/multi_mx_call.sql @@ -0,0 +1,30 @@ +-- Test passing off CALL to mx workers + +-- Create worker-local tables to test procedure calls were routed + +set citus.shard_replication_factor to 1; +set citus.replication_model to 'streaming'; + +CREATE TABLE mx_call_dist_table(id int); +select create_distributed_table('mx_call_dist_table', 'id'); +insert into mx_call_dist_table values (1),(2),(3),(4),(5); + +CREATE PROCEDURE mx_call_proc(x int, INOUT y int) LANGUAGE plpgsql AS $$ +BEGIN + y := x + (select case groupid when 0 then 1 else 0 end from pg_dist_local_group); + y := y + (select sum(id) from mx_call_dist_table); +END; +$$; + +select create_distributed_function('mx_call_proc(int,int)'); +update citus.pg_dist_object +set distribution_argument_index = 1, colocationid = pg_dist_partition.colocationid +from pg_proc, pg_dist_partition +where proname = 'mx_call_proc' and oid = objid and pg_dist_partition.logicalrelid = 'mx_call_dist_table'::regclass; + +call mx_call_proc(2, 0); + +DROP TABLE mx_call_dist_table; +DROP PROCEDURE mx_call_proc; +reset citus.shard_replication_factor; +reset citus.replication_model;