Test: multi_mx_call

pull/3026/head
Philip Dubé 2019-09-18 00:37:56 +00:00 committed by Philip Dubé
parent bc1ad67eb5
commit 16b8d17aba
4 changed files with 109 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;