Expand test coverage for combinations of master evalution, deferred pruning, parameters, local execution

- Router           & Remote & Requires Master Evaluation & With Param & Without Param
- Fast Path Router & Remote & Requires Master Evaluation & With Param & Without Param
pull/3553/head
Onder Kalaci 2020-03-02 10:17:21 +01:00 committed by Marco Slot
parent dc4c0c032e
commit f72916875f
9 changed files with 4133 additions and 19 deletions

View File

@ -47,6 +47,20 @@ SELECT create_distributed_table('collections_list', 'key');
CREATE TABLE collections_list_0
PARTITION OF collections_list (key, ser, ts, collection_id, value)
FOR VALUES IN ( 0 );
-- create a volatile function that returns the local node id
CREATE OR REPLACE FUNCTION get_local_node_id_volatile()
RETURNS INT AS $$
DECLARE localGroupId int;
BEGIN
SELECT groupid INTO localGroupId FROM pg_dist_local_group;
RETURN localGroupId;
END; $$ language plpgsql VOLATILE;
SELECT create_distributed_function('get_local_node_id_volatile()');
create_distributed_function
---------------------------------------------------------------------
(1 row)
-- connection worker and get ready for the tests
\c - - - :worker_1_port
SET search_path TO local_shard_execution;
@ -634,6 +648,33 @@ PL/pgSQL function only_local_execution() line 5 at SQL statement
NOTICE: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
CONTEXT: SQL statement "DELETE FROM distributed_table WHERE key = 1"
PL/pgSQL function only_local_execution() line 6 at SQL statement
-- insert a row that we need in the next tests
INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '29';
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1, '11'::text, 21) ON CONFLICT(key) DO UPDATE SET value = '29'::text
-- make sure that functions can use local execution
CREATE OR REPLACE PROCEDURE only_local_execution_with_function_evaluation() AS $$
DECLARE nodeId INT;
BEGIN
-- fast path router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table WHERE key = 1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
-- regular router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table d1 JOIN distributed_table d2 USING (key) WHERE d1.key = 1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
END;
$$ LANGUAGE plpgsql;
CALL only_local_execution_with_function_evaluation();
NOTICE: executing the command locally: SELECT local_shard_execution.get_local_node_id_volatile() AS get_local_node_id_volatile FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
CONTEXT: SQL statement "SELECT get_local_node_id_volatile() FROM distributed_table WHERE key = 1"
PL/pgSQL function only_local_execution_with_function_evaluation() line 5 at SQL statement
NOTICE: executing the command locally: SELECT local_shard_execution.get_local_node_id_volatile() AS get_local_node_id_volatile FROM (local_shard_execution.distributed_table_1470001 d1(key, value, age) JOIN local_shard_execution.distributed_table_1470001 d2(key, value, age) USING (key)) WHERE (d1.key OPERATOR(pg_catalog.=) 1)
CONTEXT: SQL statement "SELECT get_local_node_id_volatile() FROM distributed_table d1 JOIN distributed_table d2 USING (key) WHERE d1.key = 1"
PL/pgSQL function only_local_execution_with_function_evaluation() line 11 at SQL statement
CREATE OR REPLACE PROCEDURE only_local_execution_with_params(int) AS $$
DECLARE cnt INT;
BEGIN
@ -652,6 +693,29 @@ PL/pgSQL function only_local_execution_with_params(integer) line 5 at SQL statem
NOTICE: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
CONTEXT: SQL statement "DELETE FROM distributed_table WHERE key = $1"
PL/pgSQL function only_local_execution_with_params(integer) line 6 at SQL statement
CREATE OR REPLACE PROCEDURE only_local_execution_with_function_evaluation_param(int) AS $$
DECLARE nodeId INT;
BEGIN
-- fast path router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table WHERE key = $1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
-- regular router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table d1 JOIN distributed_table d2 USING (key) WHERE d1.key = $1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
END;
$$ LANGUAGE plpgsql;
CALL only_local_execution_with_function_evaluation_param(1);
NOTICE: executing the command locally: SELECT local_shard_execution.get_local_node_id_volatile() AS get_local_node_id_volatile FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
CONTEXT: SQL statement "SELECT get_local_node_id_volatile() FROM distributed_table WHERE key = $1"
PL/pgSQL function only_local_execution_with_function_evaluation_param(integer) line 5 at SQL statement
NOTICE: executing the command locally: SELECT local_shard_execution.get_local_node_id_volatile() AS get_local_node_id_volatile FROM (local_shard_execution.distributed_table_1470001 d1(key, value, age) JOIN local_shard_execution.distributed_table_1470001 d2(key, value, age) USING (key)) WHERE (d1.key OPERATOR(pg_catalog.=) $1)
CONTEXT: SQL statement "SELECT get_local_node_id_volatile() FROM distributed_table d1 JOIN distributed_table d2 USING (key) WHERE d1.key = $1"
PL/pgSQL function only_local_execution_with_function_evaluation_param(integer) line 11 at SQL statement
CREATE OR REPLACE PROCEDURE local_execution_followed_by_dist() AS $$
DECLARE cnt INT;
BEGIN

View File

@ -53,50 +53,113 @@ SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key =
(1 row)
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE p1(int) AS SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key = $1;
execute p1(1);
PREPARE fast_path_router_with_param(int) AS SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key = $1;
execute fast_path_router_with_param(1);
?column?
---------------------------------------------------------------------
t
(1 row)
execute p1(2);
execute fast_path_router_with_param(2);
?column?
---------------------------------------------------------------------
t
(1 row)
execute p1(3);
execute fast_path_router_with_param(3);
?column?
---------------------------------------------------------------------
t
(1 row)
execute p1(4);
execute fast_path_router_with_param(4);
?column?
---------------------------------------------------------------------
t
(1 row)
execute p1(5);
execute fast_path_router_with_param(5);
?column?
---------------------------------------------------------------------
t
(1 row)
execute p1(6);
execute fast_path_router_with_param(6);
?column?
---------------------------------------------------------------------
t
(1 row)
execute p1(7);
execute fast_path_router_with_param(7);
?column?
---------------------------------------------------------------------
t
(1 row)
execute p1(8);
execute fast_path_router_with_param(8);
?column?
---------------------------------------------------------------------
t
(1 row)
-- same query as fast_path_router_with_param, but with consts
SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key = 1;
?column?
---------------------------------------------------------------------
t
(1 row)
PREPARE router_with_param(int) AS SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table m1 JOIN master_evaluation_table m2 USING(key) WHERE key = $1;
execute router_with_param(1);
?column?
---------------------------------------------------------------------
t
(1 row)
execute router_with_param(2);
?column?
---------------------------------------------------------------------
t
(1 row)
execute router_with_param(3);
?column?
---------------------------------------------------------------------
t
(1 row)
execute router_with_param(4);
?column?
---------------------------------------------------------------------
t
(1 row)
execute router_with_param(5);
?column?
---------------------------------------------------------------------
t
(1 row)
execute router_with_param(6);
?column?
---------------------------------------------------------------------
t
(1 row)
execute router_with_param(7);
?column?
---------------------------------------------------------------------
t
(1 row)
execute router_with_param(8);
?column?
---------------------------------------------------------------------
t
(1 row)
-- same query as router_with_param, but with consts
SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table m1 JOIN master_evaluation_table m2 USING(key) WHERE key = 1;
?column?
---------------------------------------------------------------------
t

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,8 @@ 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 master_evaluation
test: master_evaluation master_evaluation_modify master_evaluation_select
test: multi_mx_call
test: multi_mx_function_call_delegation
test: multi_mx_modifications local_shard_execution
test: multi_mx_transaction_recovery

View File

@ -36,6 +36,16 @@ CREATE TABLE collections_list_0
PARTITION OF collections_list (key, ser, ts, collection_id, value)
FOR VALUES IN ( 0 );
-- create a volatile function that returns the local node id
CREATE OR REPLACE FUNCTION get_local_node_id_volatile()
RETURNS INT AS $$
DECLARE localGroupId int;
BEGIN
SELECT groupid INTO localGroupId FROM pg_dist_local_group;
RETURN localGroupId;
END; $$ language plpgsql VOLATILE;
SELECT create_distributed_function('get_local_node_id_volatile()');
-- connection worker and get ready for the tests
\c - - - :worker_1_port
SET search_path TO local_shard_execution;
@ -361,6 +371,29 @@ $$ LANGUAGE plpgsql;
CALL only_local_execution();
-- insert a row that we need in the next tests
INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '29';
-- make sure that functions can use local execution
CREATE OR REPLACE PROCEDURE only_local_execution_with_function_evaluation() AS $$
DECLARE nodeId INT;
BEGIN
-- fast path router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table WHERE key = 1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
-- regular router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table d1 JOIN distributed_table d2 USING (key) WHERE d1.key = 1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
END;
$$ LANGUAGE plpgsql;
CALL only_local_execution_with_function_evaluation();
CREATE OR REPLACE PROCEDURE only_local_execution_with_params(int) AS $$
DECLARE cnt INT;
BEGIN
@ -372,6 +405,25 @@ $$ LANGUAGE plpgsql;
CALL only_local_execution_with_params(1);
CREATE OR REPLACE PROCEDURE only_local_execution_with_function_evaluation_param(int) AS $$
DECLARE nodeId INT;
BEGIN
-- fast path router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table WHERE key = $1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
-- regular router
SELECT get_local_node_id_volatile() INTO nodeId FROM distributed_table d1 JOIN distributed_table d2 USING (key) WHERE d1.key = $1;
IF nodeId <= 0 THEN
RAISE NOTICE 'unexpected node id';
END IF;
END;
$$ LANGUAGE plpgsql;
CALL only_local_execution_with_function_evaluation_param(1);
CREATE OR REPLACE PROCEDURE local_execution_followed_by_dist() AS $$
DECLARE cnt INT;
BEGIN

View File

@ -36,16 +36,33 @@ INSERT INTO master_evaluation_table SELECT i, i FROM generate_series(0,100)i;
SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key = 1;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE p1(int) AS SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key = $1;
PREPARE fast_path_router_with_param(int) AS SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key = $1;
execute p1(1);
execute p1(2);
execute p1(3);
execute p1(4);
execute p1(5);
execute p1(6);
execute p1(7);
execute p1(8);
execute fast_path_router_with_param(1);
execute fast_path_router_with_param(2);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(4);
execute fast_path_router_with_param(5);
execute fast_path_router_with_param(6);
execute fast_path_router_with_param(7);
execute fast_path_router_with_param(8);
-- same query as fast_path_router_with_param, but with consts
SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table WHERE key = 1;
PREPARE router_with_param(int) AS SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table m1 JOIN master_evaluation_table m2 USING(key) WHERE key = $1;
execute router_with_param(1);
execute router_with_param(2);
execute router_with_param(3);
execute router_with_param(4);
execute router_with_param(5);
execute router_with_param(6);
execute router_with_param(7);
execute router_with_param(8);
-- same query as router_with_param, but with consts
SELECT get_local_node_id_volatile() > 0 FROM master_evaluation_table m1 JOIN master_evaluation_table m2 USING(key) WHERE key = 1;
-- for multi-shard queries, we still expect the evaluation to happen on the workers
SELECT count(*), max(get_local_node_id_volatile()) != 0, min(get_local_node_id_volatile()) != 0 FROM master_evaluation_table;

View File

@ -0,0 +1,502 @@
-- This test relies on metadata being synced
-- that's why is should be executed on MX schedule
CREATE SCHEMA master_evaluation_combinations_modify;
SET search_path TO master_evaluation_combinations_modify;
-- in this test, we are considering combinations of
-- several Citus features, and there is one prepared
-- statement for the combinations of following:
-- (a) Router Modify vs Fast Path Router Modify
-- (b) Local Execution vs Remote Execution
-- (c) Parameters on distribution key vs Parameters on non-dist key
-- vs Non-parametrized queries
-- (d) Master Function Evaluation Required vs
-- Master Function Evaluation Not Required
SET citus.next_shard_id TO 1180000;
-- create a volatile function that returns the local node id
CREATE OR REPLACE FUNCTION get_local_node_id_stable()
RETURNS INT AS $$
DECLARE localGroupId int;
BEGIN
SELECT groupid INTO localGroupId FROM pg_dist_local_group;
RETURN localGroupId;
END; $$ language plpgsql STABLE;
SELECT create_distributed_function('get_local_node_id_stable()');
-- returns 1 on coordinator
CREATE OR REPLACE FUNCTION get_constant_stable()
RETURNS INT AS $$
BEGIN
RETURN 1;
END; $$ language plpgsql STABLE;
CREATE TYPE user_data AS (name text, age int);
SET citus.replication_model TO streaming;
SET citus.shard_replication_factor TO 1;
CREATE TABLE user_info_data (user_id int, u_data user_data);
SELECT create_distributed_table('user_info_data', 'user_id');
-- show that local id is 0, we'll use this information
SELECT get_local_node_id_stable();
INSERT INTO user_info_data SELECT i, ('name' || i, i % 20 + 20)::user_data FROM generate_series(0,7)i;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param(int) AS DELETE FROM user_info_data WHERE user_id = $1 RETURNING *;
execute fast_path_router_with_param(0);
execute fast_path_router_with_param(1);
execute fast_path_router_with_param(2);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(4);
execute fast_path_router_with_param(5);
execute fast_path_router_with_param(6);
execute fast_path_router_with_param(7);
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param_and_func(int) AS DELETE FROM user_info_data WHERE u_data = ('test', get_local_node_id_stable())::user_data AND user_id = $1 RETURNING *;
INSERT INTO user_info_data SELECT i, ('test', 0)::user_data FROM generate_series(0,7)i;
-- should evaluate the function on the coordinator, hence get_local_node_id_stable() returns zero
execute fast_path_router_with_param_and_func(0);
execute fast_path_router_with_param_and_func(1);
execute fast_path_router_with_param_and_func(2);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(4);
execute fast_path_router_with_param_and_func(5);
execute fast_path_router_with_param_and_func(6);
execute fast_path_router_with_param_and_func(7);
INSERT INTO user_info_data SELECT 1, ('test' || i, 0)::user_data FROM generate_series(0,7)i;
PREPARE fast_path_router_with_param_on_non_dist_key_and_func(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 1 RETURNING *;
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test0', get_local_node_id_stable())::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test1', get_local_node_id_stable())::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test2', get_local_node_id_stable())::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test3', get_local_node_id_stable())::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test4', get_local_node_id_stable())::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test5', get_local_node_id_stable())::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test6', get_local_node_id_stable())::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('test7', get_local_node_id_stable())::user_data);
INSERT INTO user_info_data SELECT 1, ('test', i)::user_data FROM generate_series(0,7)i;
PREPARE fast_path_router_with_param_on_non_dist_key(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 1 RETURNING
*;
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 0)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 2)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 3)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 4)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 5)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 6)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 7)::user_data);
INSERT INTO user_info_data SELECT i, ('test', i)::user_data FROM generate_series(0,7)i;
PREPARE fast_path_router_with_two_params(user_data, int) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = $2 RETURNING
*;
EXECUTE fast_path_router_with_two_params(('test', 0)::user_data, 0);
EXECUTE fast_path_router_with_two_params(('test', 1)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 2);
EXECUTE fast_path_router_with_two_params(('test', 3)::user_data, 3);
EXECUTE fast_path_router_with_two_params(('test', 4)::user_data, 4);
EXECUTE fast_path_router_with_two_params(('test', 5)::user_data, 5);
EXECUTE fast_path_router_with_two_params(('test', 6)::user_data, 6);
EXECUTE fast_path_router_with_two_params(('test', 7)::user_data, 7);
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
PREPARE fast_path_router_with_only_function AS DELETE FROM user_info_data WHERE get_local_node_id_stable() = 0 AND user_id = 1 RETURNING *;
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE fast_path_router_with_only_function;
ALTER TABLE user_info_data ADD COLUMN user_index INT;
PREPARE insert_with_function_and_param(user_data) AS INSERT INTO user_info_data VALUES (1, $1, get_local_node_id_stable()) RETURNING user_id;
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
ALTER TABLE user_info_data DROP COLUMN user_index;
TRUNCATE user_info_data;
INSERT INTO user_info_data SELECT i, ('test', i)::user_data FROM generate_series(0,7)i;
-- make sure that it is also true for non fast-path router queries with paramaters
PREPARE router_with_param(int) AS DELETE FROM user_info_data WHERE user_id = $1 AND user_id = $1 RETURNING *;
execute router_with_param(0);
execute router_with_param(1);
execute router_with_param(2);
execute router_with_param(3);
execute router_with_param(4);
execute router_with_param(5);
execute router_with_param(6);
execute router_with_param(7);
-- make sure that it is also true for non fast-path router queries with paramaters
PREPARE router_with_param_and_func(int) AS DELETE FROM user_info_data WHERE u_data = ('test', get_local_node_id_stable())::user_data AND user_id = $1 AND user_id = $1 RETURNING *;
INSERT INTO user_info_data SELECT i, ('test', 0)::user_data FROM generate_series(0,7)i;
execute router_with_param_and_func(0);
execute router_with_param_and_func(1);
execute router_with_param_and_func(2);
execute router_with_param_and_func(3);
execute router_with_param_and_func(4);
execute router_with_param_and_func(5);
execute router_with_param_and_func(6);
execute router_with_param_and_func(7);
INSERT INTO user_info_data SELECT 1, ('test' || i, 0)::user_data FROM generate_series(0,7)i;
PREPARE router_with_param_on_non_dist_key_and_func(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 1 AND user_id = 1 RETURNING *;
EXECUTE router_with_param_on_non_dist_key_and_func(('test0', get_local_node_id_stable())::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('test1', get_local_node_id_stable())::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('test2', get_local_node_id_stable())::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('test3', get_local_node_id_stable())::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('test4', get_local_node_id_stable())::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('test5', get_local_node_id_stable())::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('test6', get_local_node_id_stable())::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('test7', get_local_node_id_stable())::user_data);
INSERT INTO user_info_data SELECT 1, ('test', i)::user_data FROM generate_series(0,7)i;
PREPARE router_with_param_on_non_dist_key(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 1 AND user_id = 1 RETURNING *;
EXECUTE router_with_param_on_non_dist_key(('test', 0)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 2)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 3)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 4)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 5)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 6)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 7)::user_data);
INSERT INTO user_info_data SELECT i, ('test', i)::user_data FROM generate_series(0,7)i;
PREPARE router_with_two_params(user_data, int) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = $2 AND user_id = $2 RETURNING
*;
EXECUTE router_with_two_params(('test', 0)::user_data, 0);
EXECUTE router_with_two_params(('test', 1)::user_data, 1);
EXECUTE router_with_two_params(('test', 2)::user_data, 2);
EXECUTE router_with_two_params(('test', 3)::user_data, 3);
EXECUTE router_with_two_params(('test', 4)::user_data, 4);
EXECUTE router_with_two_params(('test', 5)::user_data, 5);
EXECUTE router_with_two_params(('test', 6)::user_data, 6);
EXECUTE router_with_two_params(('test', 7)::user_data, 7);
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
PREPARE router_with_only_function AS DELETE FROM user_info_data WHERE get_local_node_id_stable() = 0 AND user_id = 1 AND user_id = 1 RETURNING *;
EXECUTE router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
\c - - - :worker_2_port
SET citus.log_local_commands TO ON;
SET search_path TO master_evaluation_combinations_modify;
-- returns 2 on the worker
CREATE OR REPLACE FUNCTION get_constant_stable()
RETURNS INT AS $$
BEGIN
RETURN 2;
END; $$ language plpgsql STABLE;
-- all local values
INSERT INTO user_info_data (user_id, u_data) VALUES
(3, '(''test3'', 3)'), (4, '(''test4'', 4)'), (7, '(''test7'', 7)'),
(9, '(''test9'', 9)'), (11, '(''test11'', 11)'), (12, '(''test12'', 12)'),
(14, '(''test14'', 14)'), (16, '(''test16'', 16)');
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param(int) AS DELETE FROM user_info_data WHERE user_id = $1 RETURNING *;
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(4);
execute fast_path_router_with_param(7);
execute fast_path_router_with_param(9);
execute fast_path_router_with_param(11);
execute fast_path_router_with_param(12);
execute fast_path_router_with_param(14);
execute fast_path_router_with_param(16);
INSERT INTO user_info_data (user_id, u_data) VALUES
(3, '(''test'', 2)'), (4, '(''test'', 2)'), (7, '(''test'', 2)'),
(9, '(''test'', 9)'), (11, '(''test'', 2)'), (12, '(''test'', 2)'),
(14, '(''test'', 2)'), (16, '(''test'', 2)');
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param_and_func(int) AS DELETE FROM user_info_data WHERE u_data = ('''test''', get_constant_stable())::user_data AND user_id = $1 RETURNING *;
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(4);
execute fast_path_router_with_param_and_func(7);
execute fast_path_router_with_param_and_func(9);
execute fast_path_router_with_param_and_func(11);
execute fast_path_router_with_param_and_func(12);
execute fast_path_router_with_param_and_func(14);
execute fast_path_router_with_param_and_func(16);
PREPARE fast_path_router_with_param_on_non_dist_key_and_func(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 3 RETURNING *;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)'::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
PREPARE fast_path_router_with_param_on_non_dist_key(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 3 RETURNING *;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES
(3, ('test', 2)), (4, ('test', 2)), (7, ('test', 2)),
(9, ('test', 2)), (11, ('test', 2)), (12, ('test', 2)),
(14, ('test', 2)), (16, ('test', 2));
PREPARE fast_path_router_with_two_params(user_data, int) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = $2 RETURNING *;
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 3);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 4);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 7);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 9);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 11);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 12);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 14);
EXECUTE fast_path_router_with_two_params(('test', 2)::user_data, 16);
PREPARE fast_path_router_with_only_function AS DELETE FROM user_info_data WHERE get_constant_stable() = 2AND user_id = 3 RETURNING *;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE fast_path_router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE fast_path_router_with_only_function;
-------
\c - - - :master_port
SET search_path TO master_evaluation_combinations_modify;
ALTER TABLE user_info_data ADD COLUMN user_index INT;
\c - - - :worker_2_port
SET search_path TO master_evaluation_combinations_modify;
PREPARE insert_with_function_and_param(user_data) AS INSERT INTO user_info_data VALUES (3, $1, get_local_node_id_stable()) RETURNING user_id;
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
\c - - - :master_port
SET search_path TO master_evaluation_combinations_modify;
ALTER TABLE user_info_data DROP COLUMN user_index;
TRUNCATE user_info_data;
\c - - - :worker_2_port
SET citus.log_local_commands TO ON;
SET search_path TO master_evaluation_combinations_modify;
-- all local values
INSERT INTO user_info_data (user_id, u_data) VALUES
(3, '(''test3'', 3)'), (4, '(''test4'', 4)'), (7, '(''test7'', 7)'),
(9, '(''test9'', 9)'), (11, '(''test11'', 11)'), (12, '(''test12'', 12)'),
(14, '(''test14'', 14)'), (16, '(''test16'', 16)');
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE router_with_param(int) AS DELETE FROM user_info_data WHERE user_id = $1 AND user_id = $1 RETURNING *;
execute router_with_param(3);
execute router_with_param(4);
execute router_with_param(7);
execute router_with_param(9);
execute router_with_param(11);
execute router_with_param(12);
execute router_with_param(14);
execute router_with_param(16);
INSERT INTO user_info_data (user_id, u_data) VALUES
(3, '(''test'', 2)'), (4, '(''test'', 2)'), (7, '(''test'', 2)'),
(9, '(''test'', 9)'), (11, '(''test'', 2)'), (12, '(''test'', 2)'),
(14, '(''test'', 2)'), (16, '(''test'', 2)');
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE router_with_param_and_func(int) AS DELETE FROM user_info_data WHERE u_data = ('''test''', get_constant_stable())::user_data AND user_id = $1 AND user_id = $1 RETURNING *;
execute router_with_param_and_func(3);
execute router_with_param_and_func(4);
execute router_with_param_and_func(7);
execute router_with_param_and_func(9);
execute router_with_param_and_func(11);
execute router_with_param_and_func(12);
execute router_with_param_and_func(14);
execute router_with_param_and_func(16);
PREPARE router_with_param_on_non_dist_key_and_func(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 3 AND user_id = 3 RETURNING *;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)'::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
PREPARE router_with_param_on_non_dist_key(user_data) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = 3 AND user_id = 3 RETURNING *;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
INSERT INTO user_info_data (user_id, u_data) VALUES
(3, ('test', 2)), (4, ('test', 2)), (7, ('test', 2)),
(9, ('test', 2)), (11, ('test', 2)), (12, ('test', 2)),
(14, ('test', 2)), (16, ('test', 2));
PREPARE router_with_two_params(user_data, int) AS DELETE FROM user_info_data WHERE u_data = $1 AND user_id = $2 AND user_id = $2 RETURNING *;
EXECUTE router_with_two_params(('test', 2)::user_data, 3);
EXECUTE router_with_two_params(('test', 2)::user_data, 4);
EXECUTE router_with_two_params(('test', 2)::user_data, 7);
EXECUTE router_with_two_params(('test', 2)::user_data, 9);
EXECUTE router_with_two_params(('test', 2)::user_data, 11);
EXECUTE router_with_two_params(('test', 2)::user_data, 12);
EXECUTE router_with_two_params(('test', 2)::user_data, 14);
EXECUTE router_with_two_params(('test', 2)::user_data, 16);
PREPARE router_with_only_function AS DELETE FROM user_info_data WHERE get_constant_stable() = 2AND user_id = 3 RETURNING *;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE router_with_only_function;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
EXECUTE router_with_only_function;
-- suppress notices
\c - - - :master_port
SET client_min_messages TO ERROR;
DROP SCHEMA master_evaluation_combinations_modify CASCADE;

View File

@ -0,0 +1,373 @@
-- This test relies on metadata being synced
-- that's why is should be executed on MX schedule
-- in this test, we are considering combinations of
-- several Citus features, and there is one prepared
-- statement for the combinations of following:
-- (a) Router Select vs Fast Path Router Select
-- (b) Local Execution vs Remote Execution
-- (c) Parameters on distribution key vs Parameters on non-dist key
-- vs Non-parametrized queries
-- (d) Master Function Evaluation Required vs
-- Master Function Evaluation Not Required
CREATE SCHEMA master_evaluation_combinations;
SET search_path TO master_evaluation_combinations;
SET citus.next_shard_id TO 1170000;
-- create a volatile function that returns the local node id
CREATE OR REPLACE FUNCTION get_local_node_id_volatile()
RETURNS INT AS $$
DECLARE localGroupId int;
BEGIN
SELECT groupid INTO localGroupId FROM pg_dist_local_group;
RETURN localGroupId;
END; $$ language plpgsql VOLATILE;
SELECT create_distributed_function('get_local_node_id_volatile()');
CREATE TYPE user_data AS (name text, age int);
SET citus.replication_model TO streaming;
SET citus.shard_replication_factor TO 1;
CREATE TABLE user_info_data (user_id int, u_data user_data);
SELECT create_distributed_table('user_info_data', 'user_id');
-- show that local id is 0, we'll use this information
SELECT get_local_node_id_volatile();
-- load data
INSERT INTO user_info_data SELECT i, ('name' || i, i % 20 + 20)::user_data FROM generate_series(0,100)i;
-- we expect that the function is evaluated on the worker node, so we should get a row
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param(int) AS SELECT count(*) FROM user_info_data WHERE user_id = $1;
execute fast_path_router_with_param(1);
execute fast_path_router_with_param(2);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(4);
execute fast_path_router_with_param(5);
execute fast_path_router_with_param(6);
execute fast_path_router_with_param(7);
execute fast_path_router_with_param(8);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param_and_func(int) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = $1;
execute fast_path_router_with_param_and_func(1);
execute fast_path_router_with_param_and_func(2);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(4);
execute fast_path_router_with_param_and_func(5);
execute fast_path_router_with_param_and_func(6);
execute fast_path_router_with_param_and_func(7);
execute fast_path_router_with_param_and_func(8);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1 AND u_data = ('name1', 21)::user_data;
PREPARE fast_path_router_with_param_on_non_dist_key_and_func(user_data) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1 AND u_data = $1;
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
SELECT count(*) FROM user_info_data WHERE user_id = 1 AND u_data = ('name1', 21)::user_data;
PREPARE fast_path_router_with_param_on_non_dist_key(user_data) AS SELECT count(*) FROM user_info_data WHERE user_id = 1 AND u_data = $1;
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name1', 21)::user_data);
PREPARE fast_path_router_with_two_params(user_data, int) AS SELECT count(*) FROM user_info_data WHERE user_id = $2 AND u_data = $1;
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE fast_path_router_with_two_params(('name1', 21)::user_data, 1);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1;
PREPARE fast_path_router_with_only_function AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = 1;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE router_with_param(int) AS SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = $1;
execute router_with_param(1);
execute router_with_param(2);
execute router_with_param(3);
execute router_with_param(4);
execute router_with_param(5);
execute router_with_param(6);
execute router_with_param(7);
execute router_with_param(8);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data m1 JOIN user_info_data m2 USING(user_id) WHERE m1.user_id = 1;
PREPARE router_with_param_and_func(int) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data m1 JOIN user_info_data m2 USING(user_id) WHERE m1.user_id = $1;
execute router_with_param_and_func(1);
execute router_with_param_and_func(2);
execute router_with_param_and_func(3);
execute router_with_param_and_func(4);
execute router_with_param_and_func(5);
execute router_with_param_and_func(6);
execute router_with_param_and_func(7);
execute router_with_param_and_func(8);
-- same query as router_with_param, but with consts
SELECT get_local_node_id_volatile() > 0 FROM user_info_data m1 JOIN user_info_data m2 USING(user_id) WHERE m1.user_id = 1;
PREPARE router_with_param_on_non_dist_key(user_data) AS SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 1 AND u1.u_data = $1;
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name1', 21)::user_data);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 1 AND u1.u_data = ('name1', 21)::user_data;
PREPARE router_with_param_on_non_dist_key_and_func(user_data) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 1 AND u1.u_data = $1;
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name1', 21)::user_data);
SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = 1 AND u1.u_data = ('name1', 21)::user_data;
PREPARE router_with_two_params(user_data, int) AS SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = $2 AND u1.u_data = $1;
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
EXECUTE router_with_two_params(('name1', 21)::user_data, 1);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING(user_id) WHERE user_id = 1;
PREPARE router_with_only_function AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING(user_id) WHERE user_id = 1;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
\c - - - :worker_2_port
SET citus.log_local_commands TO ON;
SET search_path TO master_evaluation_combinations;
-- show that the data with user_id = 3 is local
SELECT count(*) FROM user_info_data WHERE user_id = 3;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param(int) AS SELECT count(*) FROM user_info_data WHERE user_id = $1;
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(3);
execute fast_path_router_with_param(3);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 3;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE fast_path_router_with_param_and_func(int) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = $1;
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(3);
execute fast_path_router_with_param_and_func(8);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 3 AND u_data = ('name3', 23)::user_data;
PREPARE fast_path_router_with_param_on_non_dist_key_and_func(user_data) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 3 AND u_data = $1;
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
SELECT count(*) FROM user_info_data WHERE user_id = 3 AND u_data = ('name3', 23)::user_data;
PREPARE fast_path_router_with_param_on_non_dist_key(user_data) AS SELECT count(*) FROM user_info_data WHERE user_id = 3 AND u_data = $1;
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE fast_path_router_with_param_on_non_dist_key(('name3', 23)::user_data);
PREPARE fast_path_router_with_only_function AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 3;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
EXECUTE fast_path_router_with_only_function;
SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = 3;
-- make sure that it is also true for fast-path router queries with paramaters
PREPARE router_with_param(int) AS SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = $1;
execute router_with_param(3);
execute router_with_param(3);
execute router_with_param(3);
execute router_with_param(3);
execute router_with_param(3);
execute router_with_param(3);
execute router_with_param(3);
execute router_with_param(3);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data m1 JOIN user_info_data m2 USING(user_id) WHERE m1.user_id = 3;
PREPARE router_with_param_and_func(int) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data m1 JOIN user_info_data m2 USING(user_id) WHERE m1.user_id = $1;
execute router_with_param_and_func(3);
execute router_with_param_and_func(3);
execute router_with_param_and_func(3);
execute router_with_param_and_func(3);
execute router_with_param_and_func(3);
execute router_with_param_and_func(3);
execute router_with_param_and_func(3);
execute router_with_param_and_func(3);
-- same query as router_with_param, but with consts
SELECT get_local_node_id_volatile() > 0 FROM user_info_data m1 JOIN user_info_data m2 USING(user_id) WHERE m1.user_id = 3;
SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 3 AND u1.u_data = ('name3', 23)::user_data;
SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 3 AND u1.u_data = ('name3', 23)::user_data;
PREPARE router_with_param_on_non_dist_key(user_data) AS SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 3 AND u1.u_data = $1;
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key(('name3', 23)::user_data);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 3 AND u1.u_data = ('name3', 23)::user_data;
PREPARE router_with_param_on_non_dist_key_and_func(user_data) AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE u1.user_id = 3 AND u1.u_data = $1;
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
EXECUTE router_with_param_on_non_dist_key_and_func(('name3', 23)::user_data);
SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = 3 AND u1.u_data = ('name3', 23)::user_data;
PREPARE router_with_two_params(user_data, int) AS SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = $2 AND u1.u_data = $1;
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
EXECUTE router_with_two_params(('name3', 23)::user_data, 3);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING(user_id) WHERE user_id = 3;
PREPARE router_with_only_function AS SELECT get_local_node_id_volatile() > 0 FROM user_info_data u1 JOIN user_info_data u2 USING(user_id) WHERE user_id = 3;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
EXECUTE router_with_only_function;
-- suppress notices
\c - - - :master_port
SET client_min_messages TO ERROR;
DROP SCHEMA master_evaluation_combinations CASCADE;