Merge pull request #5064 from citusdata/solidfy_prepared_statements

Improve regression tests for prepared statements for local cached plans
pull/5050/head^2
Önder Kalacı 2021-06-21 14:07:32 +03:00 committed by GitHub
commit 206401b708
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 368 additions and 25 deletions

View File

@ -454,6 +454,12 @@ EXECUTE insert_with_function_and_param(('test', 1)::user_data);
1
(1 row)
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
user_id
---------------------------------------------------------------------
1
(1 row)
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
@ -816,6 +822,13 @@ EXECUTE router_with_only_function;
1 | (test,1)
(1 row)
INSERT INTO user_info_data VALUES(1, ('test', 1)::user_data);
EXECUTE router_with_only_function;
user_id | u_data
---------------------------------------------------------------------
1 | (test,1)
(1 row)
\c - - - :worker_2_port
SET citus.log_local_commands TO ON;
SET search_path TO coordinator_evaluation_combinations_modify;
@ -1077,6 +1090,15 @@ NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combi
3 | ('test',2)
(1 row)
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, '(''test'',2)'::coordinator_evaluation_combinations_modify.user_data)
EXECUTE fast_path_router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combinations_modify.user_info_data_1180001 user_info_data WHERE ((u_data OPERATOR(pg_catalog.=) '(''test'',2)'::coordinator_evaluation_combinations_modify.user_data) AND (user_id OPERATOR(pg_catalog.=) 3)) RETURNING user_id, u_data
user_id | u_data
---------------------------------------------------------------------
3 | ('test',2)
(1 row)
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 user_id, u_data;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, ROW('test'::text, 1)::coordinator_evaluation_combinations_modify.user_data)
@ -1141,6 +1163,15 @@ NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combi
3 | (test,1)
(1 row)
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, ROW('test'::text, 1)::coordinator_evaluation_combinations_modify.user_data)
EXECUTE fast_path_router_with_param_on_non_dist_key(('test', 1)::user_data);
NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combinations_modify.user_info_data_1180001 user_info_data WHERE ((u_data OPERATOR(pg_catalog.=) '(test,1)'::coordinator_evaluation_combinations_modify.user_data) AND (user_id OPERATOR(pg_catalog.=) 3)) RETURNING user_id, u_data
user_id | u_data
---------------------------------------------------------------------
3 | (test,1)
(1 row)
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)),
@ -1268,6 +1299,15 @@ NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combi
3 | (test,2)
(1 row)
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, ROW('test'::text, 2)::coordinator_evaluation_combinations_modify.user_data)
EXECUTE fast_path_router_with_only_function;
NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combinations_modify.user_info_data_1180001 user_info_data WHERE (true AND (user_id OPERATOR(pg_catalog.=) 3)) RETURNING user_id, u_data
user_id | u_data
---------------------------------------------------------------------
3 | (test,2)
(1 row)
PREPARE insert_with_function_and_param(user_data) AS INSERT INTO user_info_data VALUES (3, $1, (get_local_node_id_stable() > 0)::int) RETURNING user_id;
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data, user_index) VALUES (3, '(test,1)'::coordinator_evaluation_combinations_modify.user_data, 1) RETURNING user_id
@ -1318,6 +1358,13 @@ NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combi
3
(1 row)
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data, user_index) VALUES (3, '(test,1)'::coordinator_evaluation_combinations_modify.user_data, 1) RETURNING user_id
user_id
---------------------------------------------------------------------
3
(1 row)
TRUNCATE user_info_data;
-- all local values
INSERT INTO user_info_data (user_id, u_data) VALUES
@ -1571,6 +1618,15 @@ NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combi
3 | ('test',2)
(1 row)
INSERT INTO user_info_data (user_id, u_data) VALUES (3, '(''test'', 2)');
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, '(''test'',2)'::coordinator_evaluation_combinations_modify.user_data)
EXECUTE router_with_param_on_non_dist_key_and_func(('''test''', get_constant_stable())::user_data);
NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combinations_modify.user_info_data_1180001 user_info_data WHERE ((u_data OPERATOR(pg_catalog.=) $1::coordinator_evaluation_combinations_modify.user_data) AND (user_id OPERATOR(pg_catalog.=) 3) AND (user_id OPERATOR(pg_catalog.=) 3)) RETURNING user_id, u_data
user_id | u_data
---------------------------------------------------------------------
3 | ('test',2)
(1 row)
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 user_id, u_data;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, ROW('test'::text, 1)::coordinator_evaluation_combinations_modify.user_data)
@ -1635,6 +1691,15 @@ NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combi
3 | (test,1)
(1 row)
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, ROW('test'::text, 1)::coordinator_evaluation_combinations_modify.user_data)
EXECUTE router_with_param_on_non_dist_key(('test', 1)::user_data);
NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combinations_modify.user_info_data_1180001 user_info_data WHERE ((u_data OPERATOR(pg_catalog.=) $1::coordinator_evaluation_combinations_modify.user_data) AND (user_id OPERATOR(pg_catalog.=) 3) AND (user_id OPERATOR(pg_catalog.=) 3)) RETURNING user_id, u_data
user_id | u_data
---------------------------------------------------------------------
3 | (test,1)
(1 row)
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)),
@ -1762,6 +1827,15 @@ NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combi
3 | (test,2)
(1 row)
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 2)::user_data);
NOTICE: executing the command locally: INSERT INTO coordinator_evaluation_combinations_modify.user_info_data_1180001 (user_id, u_data) VALUES (3, ROW('test'::text, 2)::coordinator_evaluation_combinations_modify.user_data)
EXECUTE router_with_only_function;
NOTICE: executing the command locally: DELETE FROM coordinator_evaluation_combinations_modify.user_info_data_1180001 user_info_data WHERE (true AND (user_id OPERATOR(pg_catalog.=) 3)) RETURNING user_id, u_data
user_id | u_data
---------------------------------------------------------------------
3 | (test,2)
(1 row)
-- suppress notices
\c - - - :master_port
SET client_min_messages TO ERROR;

View File

@ -201,6 +201,18 @@ EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
t
(1 row)
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1 AND u_data = ('name1', 21)::user_data;
?column?
---------------------------------------------------------------------
@ -582,6 +594,12 @@ EXECUTE router_with_param_and_func_on_non_dist_key(1);
t
(1 row)
EXECUTE router_with_param_and_func_on_non_dist_key(1);
?column?
---------------------------------------------------------------------
t
(1 row)
-- 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;
?column?
@ -1005,6 +1023,20 @@ NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinati
t
(1 row)
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM coordinator_evaluation_combinations.user_info_data_1170001 user_info_data WHERE ((user_id OPERATOR(pg_catalog.=) 3) AND (user_index OPERATOR(pg_catalog.=) $1))
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM coordinator_evaluation_combinations.user_info_data_1170001 user_info_data WHERE ((user_id OPERATOR(pg_catalog.=) 3) AND (user_index OPERATOR(pg_catalog.=) $1))
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 3 AND u_data = ('name3', 23)::user_data;
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM coordinator_evaluation_combinations.user_info_data_1170001 user_info_data WHERE ((user_id OPERATOR(pg_catalog.=) 3) AND (u_data OPERATOR(pg_catalog.=) ROW('name3'::text, 23)::coordinator_evaluation_combinations.user_data))
?column?
@ -1211,6 +1243,20 @@ NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinati
t
(1 row)
EXECUTE fast_path_router_with_only_function;
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM coordinator_evaluation_combinations.user_info_data_1170001 user_info_data WHERE (user_id OPERATOR(pg_catalog.=) 3)
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE fast_path_router_with_only_function;
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM coordinator_evaluation_combinations.user_info_data_1170001 user_info_data WHERE (user_id OPERATOR(pg_catalog.=) 3)
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT count(*) FROM user_info_data u1 JOIN user_info_data u2 USING (user_id) WHERE user_id = 3;
NOTICE: executing the command locally: SELECT count(*) AS count FROM (coordinator_evaluation_combinations.user_info_data_1170001 u1(user_id, u_data, user_index) JOIN coordinator_evaluation_combinations.user_info_data_1170001 u2(user_id, u_data, user_index) USING (user_id)) WHERE (u1.user_id OPERATOR(pg_catalog.=) 3)
count
@ -1391,6 +1437,13 @@ NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinati
t
(1 row)
EXECUTE router_with_param_and_func_on_non_dist_key(3);
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM coordinator_evaluation_combinations.user_info_data_1170001 user_info_data WHERE ((user_id OPERATOR(pg_catalog.=) 3) AND (user_id OPERATOR(pg_catalog.=) 3) AND (user_index OPERATOR(pg_catalog.=) $1))
?column?
---------------------------------------------------------------------
t
(1 row)
-- 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;
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM (coordinator_evaluation_combinations.user_info_data_1170001 m1(user_id, u_data, user_index) JOIN coordinator_evaluation_combinations.user_info_data_1170001 m2(user_id, u_data, user_index) USING (user_id)) WHERE (m1.user_id OPERATOR(pg_catalog.=) 3)
@ -1683,6 +1736,13 @@ NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinati
t
(1 row)
EXECUTE router_with_only_function;
NOTICE: executing the command locally: SELECT (coordinator_evaluation_combinations.get_local_node_id_volatile() OPERATOR(pg_catalog.>) 0) FROM (coordinator_evaluation_combinations.user_info_data_1170001 u1(user_id, u_data, user_index) JOIN coordinator_evaluation_combinations.user_info_data_1170001 u2(user_id, u_data, user_index) USING (user_id)) WHERE (u1.user_id OPERATOR(pg_catalog.=) 3)
?column?
---------------------------------------------------------------------
t
(1 row)
-- suppress notices
\c - - - :master_port
SET client_min_messages TO ERROR;

View File

@ -1072,7 +1072,7 @@ SELECT DISTINCT trim(value) FROM (
PREPARE local_prepare_param (int) AS SELECT count(*) FROM distributed_table WHERE key = $1;
PREPARE remote_prepare_param (int) AS SELECT count(*) FROM distributed_table WHERE key != $1;
BEGIN;
-- 6 local execution without params
-- 8 local execution without params
EXECUTE local_prepare_no_param;
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
count
@ -1115,7 +1115,21 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shar
1
(1 row)
-- 6 local execution without params and some subqueries
EXECUTE local_prepare_no_param;
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
count
---------------------------------------------------------------------
1
(1 row)
EXECUTE local_prepare_no_param;
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
count
---------------------------------------------------------------------
1
(1 row)
-- 8 local execution without params and some subqueries
EXECUTE local_prepare_no_param_subquery;
NOTICE: executing the command locally: SELECT worker_column_1 AS value FROM (SELECT distributed_table.value AS worker_column_1 FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE ((distributed_table.key OPERATOR(pg_catalog.=) ANY (ARRAY[1, 6, 500, 701])) AND (((SELECT 2))::double precision OPERATOR(pg_catalog.>) random()))) worker_subquery ORDER BY worker_column_1 LIMIT '2'::bigint
NOTICE: executing the command locally: SELECT worker_column_1 AS value FROM (SELECT distributed_table.value AS worker_column_1 FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE ((distributed_table.key OPERATOR(pg_catalog.=) ANY (ARRAY[1, 6, 500, 701])) AND (((SELECT 2))::double precision OPERATOR(pg_catalog.>) random()))) worker_subquery ORDER BY worker_column_1 LIMIT '2'::bigint
@ -1170,7 +1184,25 @@ NOTICE: executing the command locally: SELECT DISTINCT btrim(value) AS btrim FR
12
(1 row)
-- 6 local executions with params
EXECUTE local_prepare_no_param_subquery;
NOTICE: executing the command locally: SELECT worker_column_1 AS value FROM (SELECT distributed_table.value AS worker_column_1 FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE ((distributed_table.key OPERATOR(pg_catalog.=) ANY (ARRAY[1, 6, 500, 701])) AND (((SELECT 2))::double precision OPERATOR(pg_catalog.>) random()))) worker_subquery ORDER BY worker_column_1 LIMIT '2'::bigint
NOTICE: executing the command locally: SELECT worker_column_1 AS value FROM (SELECT distributed_table.value AS worker_column_1 FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE ((distributed_table.key OPERATOR(pg_catalog.=) ANY (ARRAY[1, 6, 500, 701])) AND (((SELECT 2))::double precision OPERATOR(pg_catalog.>) random()))) worker_subquery ORDER BY worker_column_1 LIMIT '2'::bigint
NOTICE: executing the command locally: SELECT DISTINCT btrim(value) AS btrim FROM (SELECT intermediate_result.value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(value text)) t
btrim
---------------------------------------------------------------------
12
(1 row)
EXECUTE local_prepare_no_param_subquery;
NOTICE: executing the command locally: SELECT worker_column_1 AS value FROM (SELECT distributed_table.value AS worker_column_1 FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE ((distributed_table.key OPERATOR(pg_catalog.=) ANY (ARRAY[1, 6, 500, 701])) AND (((SELECT 2))::double precision OPERATOR(pg_catalog.>) random()))) worker_subquery ORDER BY worker_column_1 LIMIT '2'::bigint
NOTICE: executing the command locally: SELECT worker_column_1 AS value FROM (SELECT distributed_table.value AS worker_column_1 FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE ((distributed_table.key OPERATOR(pg_catalog.=) ANY (ARRAY[1, 6, 500, 701])) AND (((SELECT 2))::double precision OPERATOR(pg_catalog.>) random()))) worker_subquery ORDER BY worker_column_1 LIMIT '2'::bigint
NOTICE: executing the command locally: SELECT DISTINCT btrim(value) AS btrim FROM (SELECT intermediate_result.value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(value text)) t
btrim
---------------------------------------------------------------------
12
(1 row)
-- 8 local executions with params
EXECUTE local_prepare_param(1);
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
count
@ -1213,6 +1245,20 @@ NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shar
0
(1 row)
EXECUTE local_prepare_param(6);
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (key OPERATOR(pg_catalog.=) 6)
count
---------------------------------------------------------------------
0
(1 row)
EXECUTE local_prepare_param(6);
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (key OPERATOR(pg_catalog.=) 6)
count
---------------------------------------------------------------------
0
(1 row)
-- followed by a non-local execution
EXECUTE remote_prepare_param(1);
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.<>) 1)
@ -1226,7 +1272,7 @@ COMMIT;
PREPARE local_insert_prepare_no_param AS INSERT INTO distributed_table VALUES (1+0*random(), '11',21::int) ON CONFLICT(key) DO UPDATE SET value = '29' || '28' RETURNING *, key + 1, value || '30', age * 15;
PREPARE local_insert_prepare_param (int) AS INSERT INTO distributed_table VALUES ($1+0*random(), '11',21::int) ON CONFLICT(key) DO UPDATE SET value = '29' || '28' RETURNING *, key + 1, value || '30', age * 15;
BEGIN;
-- 6 local execution without params
-- 8 local execution without params
EXECUTE local_insert_prepare_no_param;
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'::bigint) ON CONFLICT(key) DO UPDATE SET value = '2928'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age, (citus_table_alias.key OPERATOR(pg_catalog.+) 1), (citus_table_alias.value OPERATOR(pg_catalog.||) '30'::text), (citus_table_alias.age OPERATOR(pg_catalog.*) 15)
key | value | age | ?column? | ?column? | ?column?
@ -1269,7 +1315,21 @@ NOTICE: executing the command locally: INSERT INTO local_shard_execution.distri
1 | 2928 | 21 | 2 | 292830 | 315
(1 row)
-- 6 local executions with params
EXECUTE local_insert_prepare_no_param;
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'::bigint) ON CONFLICT(key) DO UPDATE SET value = '2928'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age, (citus_table_alias.key OPERATOR(pg_catalog.+) 1), (citus_table_alias.value OPERATOR(pg_catalog.||) '30'::text), (citus_table_alias.age OPERATOR(pg_catalog.*) 15)
key | value | age | ?column? | ?column? | ?column?
---------------------------------------------------------------------
1 | 2928 | 21 | 2 | 292830 | 315
(1 row)
EXECUTE local_insert_prepare_no_param;
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'::bigint) ON CONFLICT(key) DO UPDATE SET value = '2928'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age, (citus_table_alias.key OPERATOR(pg_catalog.+) 1), (citus_table_alias.value OPERATOR(pg_catalog.||) '30'::text), (citus_table_alias.age OPERATOR(pg_catalog.*) 15)
key | value | age | ?column? | ?column? | ?column?
---------------------------------------------------------------------
1 | 2928 | 21 | 2 | 292830 | 315
(1 row)
-- 8 local executions with params
EXECUTE local_insert_prepare_param(1);
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'::bigint) ON CONFLICT(key) DO UPDATE SET value = '2928'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age, (citus_table_alias.key OPERATOR(pg_catalog.+) 1), (citus_table_alias.value OPERATOR(pg_catalog.||) '30'::text), (citus_table_alias.age OPERATOR(pg_catalog.*) 15)
key | value | age | ?column? | ?column? | ?column?
@ -1312,6 +1372,20 @@ NOTICE: executing the command locally: INSERT INTO local_shard_execution.distri
6 | 2928 | 21 | 7 | 292830 | 315
(1 row)
EXECUTE local_insert_prepare_param(6);
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470003 AS citus_table_alias (key, value, age) VALUES (6, '11'::text, '21'::bigint) ON CONFLICT(key) DO UPDATE SET value = '2928'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age, (citus_table_alias.key OPERATOR(pg_catalog.+) 1), (citus_table_alias.value OPERATOR(pg_catalog.||) '30'::text), (citus_table_alias.age OPERATOR(pg_catalog.*) 15)
key | value | age | ?column? | ?column? | ?column?
---------------------------------------------------------------------
6 | 2928 | 21 | 7 | 292830 | 315
(1 row)
EXECUTE local_insert_prepare_param(6);
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470003 AS citus_table_alias (key, value, age) VALUES (6, '11'::text, '21'::bigint) ON CONFLICT(key) DO UPDATE SET value = '2928'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age, (citus_table_alias.key OPERATOR(pg_catalog.+) 1), (citus_table_alias.value OPERATOR(pg_catalog.||) '30'::text), (citus_table_alias.age OPERATOR(pg_catalog.*) 15)
key | value | age | ?column? | ?column? | ?column?
---------------------------------------------------------------------
6 | 2928 | 21 | 7 | 292830 | 315
(1 row)
-- followed by a non-local execution
EXECUTE remote_prepare_param(2);
NOTICE: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.<>) 2)
@ -1343,6 +1417,16 @@ NOTICE: executing the command locally: INSERT INTO local_shard_execution.distri
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1,'55'::text,'21'::bigint), (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_no_param;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1,'55'::text,'21'::bigint), (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_no_param;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1,'55'::text,'21'::bigint), (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_no_param;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1,'55'::text,'21'::bigint), (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470003 AS citus_table_alias (key, value, age) VALUES (6,'55'::text,'21'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470003 AS citus_table_alias (key, value, age) VALUES (6,'55'::text,'21'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470003 AS citus_table_alias (key, value, age) VALUES (6,'55'::text,'21'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
@ -1376,6 +1460,11 @@ NOTICE: executing the command locally: INSERT INTO local_shard_execution.distri
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470003 AS citus_table_alias (key, value, age) VALUES (6,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_params(5,1);
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (5,'55'::text,'21'::bigint), (1,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_params(1,6);
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1,'55'::text,'21'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470003 AS citus_table_alias (key, value, age) VALUES (6,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
EXECUTE local_multi_row_insert_prepare_params(1,5);
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1,'55'::text,'21'::bigint), (5,'15'::text,'33'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
-- one task is remote
EXECUTE local_multi_row_insert_prepare_params(5,11);
NOTICE: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (5,'55'::text,'21'::bigint) ON CONFLICT(key) WHERE ((key OPERATOR(pg_catalog.>) 3) AND (key OPERATOR(pg_catalog.<) 4)) DO UPDATE SET value = ('88'::text OPERATOR(pg_catalog.||) excluded.value)
@ -1691,6 +1780,34 @@ NOTICE: executing the command locally: INSERT INTO local_shard_execution.collec
710 | 3940649673949192
(1 row)
-- get ready for the next executions
DELETE FROM collections_list WHERE key IN (5,6);
SELECT setval('collections_list_key_seq', 4);
setval
---------------------------------------------------------------------
4
(1 row)
EXECUTE serial_prepared_local;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.collections_list_1470009 (key, ser, collection_id) VALUES ('5'::bigint, '3940649673949193'::bigint, 0) RETURNING key, ser
key | ser
---------------------------------------------------------------------
5 | 3940649673949193
(1 row)
SELECT setval('collections_list_key_seq', 5);
setval
---------------------------------------------------------------------
5
(1 row)
EXECUTE serial_prepared_local;
NOTICE: executing the command locally: INSERT INTO local_shard_execution.collections_list_1470011 (key, ser, collection_id) VALUES ('6'::bigint, '3940649673949194'::bigint, 0) RETURNING key, ser
key | ser
---------------------------------------------------------------------
6 | 3940649673949194
(1 row)
-- and, one remote test
SELECT setval('collections_list_key_seq', 10);
setval
@ -1701,7 +1818,7 @@ SELECT setval('collections_list_key_seq', 10);
EXECUTE serial_prepared_local;
key | ser
---------------------------------------------------------------------
11 | 3940649673949193
11 | 3940649673949195
(1 row)
-- the final queries for the following CTEs are going to happen on the intermediate results only
@ -1889,6 +2006,7 @@ CALL regular_procedure('no');
CALL regular_procedure('no');
CALL regular_procedure('no');
CALL regular_procedure('no');
CALL regular_procedure('no');
PREPARE multi_shard_no_dist_key(invite_resp) AS select * from event_responses where response = $1::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC LIMIT 1;
EXECUTE multi_shard_no_dist_key('yes');
event_id | user_id | response
@ -1932,6 +2050,12 @@ EXECUTE multi_shard_no_dist_key('yes');
2 | 2 | yes
(1 row)
EXECUTE multi_shard_no_dist_key('yes');
event_id | user_id | response
---------------------------------------------------------------------
2 | 2 | yes
(1 row)
PREPARE multi_shard_with_dist_key(int, invite_resp) AS select * from event_responses where event_id > $1 AND response = $2::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC LIMIT 1;
EXECUTE multi_shard_with_dist_key(1, 'yes');
event_id | user_id | response
@ -1975,6 +2099,12 @@ EXECUTE multi_shard_with_dist_key(1, 'yes');
2 | 2 | yes
(1 row)
EXECUTE multi_shard_with_dist_key(1, 'yes');
event_id | user_id | response
---------------------------------------------------------------------
2 | 2 | yes
(1 row)
PREPARE query_pushdown_no_dist_key(invite_resp) AS select * from event_responses e1 LEFT JOIN event_responses e2 USING(event_id) where e1.response = $1::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC, 4 DESC LIMIT 1;
EXECUTE query_pushdown_no_dist_key('yes');
event_id | user_id | response | user_id | response
@ -2018,6 +2148,12 @@ EXECUTE query_pushdown_no_dist_key('yes');
2 | 2 | yes | 2 | yes
(1 row)
EXECUTE query_pushdown_no_dist_key('yes');
event_id | user_id | response | user_id | response
---------------------------------------------------------------------
2 | 2 | yes | 2 | yes
(1 row)
PREPARE insert_select_via_coord(invite_resp) AS INSERT INTO event_responses SELECT * FROM event_responses where response = $1::invite_resp LIMIT 1 ON CONFLICT (event_id, user_id) DO NOTHING ;
EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
@ -2026,6 +2162,7 @@ EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
PREPARE insert_select_pushdown(invite_resp) AS INSERT INTO event_responses SELECT * FROM event_responses where response = $1::invite_resp ON CONFLICT (event_id, user_id) DO NOTHING;
EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
@ -2034,6 +2171,7 @@ EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
PREPARE router_select_with_no_dist_key_filter(invite_resp) AS select * from event_responses where event_id = 1 AND response = $1::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC LIMIT 1;
EXECUTE router_select_with_no_dist_key_filter('yes');
event_id | user_id | response
@ -2077,6 +2215,12 @@ EXECUTE router_select_with_no_dist_key_filter('yes');
1 | 1 | yes
(1 row)
EXECUTE router_select_with_no_dist_key_filter('yes');
event_id | user_id | response
---------------------------------------------------------------------
1 | 1 | yes
(1 row)
-- rest of the tests assume the table is empty
TRUNCATE event_responses;
CREATE OR REPLACE PROCEDURE register_for_event(p_event_id int, p_user_id int, p_choice invite_resp)
@ -2100,7 +2244,7 @@ SELECT create_distributed_function('register_for_event(int,int,invite_resp)', 'p
(1 row)
-- call 7 times to make sure it works after the 5th time(postgres binds values after the 5th time)
-- call 8 times to make sure it works after the 5th time(postgres binds values after the 5th time and Citus 2nd time)
-- after 6th, the local execution caches the local plans and uses it
-- execute it both locally and remotely
CALL register_for_event(16, 1, 'yes');
@ -2111,6 +2255,7 @@ CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
\c - - - :worker_2_port
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
@ -2120,6 +2265,7 @@ CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
-- values 16, 17 and 19 hits the same
-- shard, so we're re-using the same cached
-- plans per statement across different distribution

View File

@ -651,7 +651,7 @@ SELECT * FROM mx_call_dist_table_1 WHERE id >= 40 ORDER BY id, val;
41 | 4
(2 rows)
-- Prepared statements. Repeat six times to test for generic plans
-- Prepared statements. Repeat 8 times to test for generic plans
PREPARE call_plan (int, int) AS SELECT mx_call_func($1, $2);
EXECUTE call_plan(2, 0);
DEBUG: pushing down the function call
@ -695,6 +695,20 @@ DEBUG: pushing down the function call
28
(1 row)
EXECUTE call_plan(2, 0);
DEBUG: pushing down the function call
mx_call_func
---------------------------------------------------------------------
28
(1 row)
EXECUTE call_plan(2, 0);
DEBUG: pushing down the function call
mx_call_func
---------------------------------------------------------------------
28
(1 row)
\c - - - :worker_1_port
SET search_path TO multi_mx_function_call_delegation, public;
-- create_distributed_function is disallowed from worker nodes

View File

@ -159,6 +159,7 @@ 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);
TRUNCATE user_info_data;
@ -265,6 +266,8 @@ 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
@ -346,9 +349,8 @@ 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 user_id, u_data;
INSERT INTO user_info_data (user_id, u_data) VALUES (3, ('test', 1)::user_data);
@ -365,7 +367,8 @@ 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
@ -400,7 +403,8 @@ 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;
PREPARE insert_with_function_and_param(user_data) AS INSERT INTO user_info_data VALUES (3, $1, (get_local_node_id_stable() > 0)::int) RETURNING user_id;
EXECUTE insert_with_function_and_param(('test', 1)::user_data);
@ -410,6 +414,7 @@ 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);
TRUNCATE user_info_data;
@ -479,8 +484,8 @@ 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 user_id, u_data;
@ -498,7 +503,8 @@ 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
@ -533,6 +539,8 @@ 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

View File

@ -81,7 +81,8 @@ EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(1);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 1 AND u_data = ('name1', 21)::user_data;
@ -172,6 +173,7 @@ EXECUTE router_with_param_and_func_on_non_dist_key(1);
EXECUTE router_with_param_and_func_on_non_dist_key(1);
EXECUTE router_with_param_and_func_on_non_dist_key(1);
EXECUTE router_with_param_and_func_on_non_dist_key(1);
EXECUTE router_with_param_and_func_on_non_dist_key(1);
-- 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;
@ -274,6 +276,8 @@ EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
EXECUTE fast_path_router_with_param_and_func_on_non_dist_key(3);
SELECT get_local_node_id_volatile() > 0 FROM user_info_data WHERE user_id = 3 AND u_data = ('name3', 23)::user_data;
@ -311,6 +315,8 @@ 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;
@ -351,6 +357,7 @@ EXECUTE router_with_param_and_func_on_non_dist_key(3);
EXECUTE router_with_param_and_func_on_non_dist_key(3);
EXECUTE router_with_param_and_func_on_non_dist_key(3);
EXECUTE router_with_param_and_func_on_non_dist_key(3);
EXECUTE router_with_param_and_func_on_non_dist_key(3);
-- same query as router_with_param, but with consts
@ -410,6 +417,7 @@ 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

View File

@ -580,7 +580,9 @@ SELECT DISTINCT trim(value) FROM (
PREPARE local_prepare_param (int) AS SELECT count(*) FROM distributed_table WHERE key = $1;
PREPARE remote_prepare_param (int) AS SELECT count(*) FROM distributed_table WHERE key != $1;
BEGIN;
-- 6 local execution without params
-- 8 local execution without params
EXECUTE local_prepare_no_param;
EXECUTE local_prepare_no_param;
EXECUTE local_prepare_no_param;
EXECUTE local_prepare_no_param;
EXECUTE local_prepare_no_param;
@ -588,7 +590,9 @@ BEGIN;
EXECUTE local_prepare_no_param;
EXECUTE local_prepare_no_param;
-- 6 local execution without params and some subqueries
-- 8 local execution without params and some subqueries
EXECUTE local_prepare_no_param_subquery;
EXECUTE local_prepare_no_param_subquery;
EXECUTE local_prepare_no_param_subquery;
EXECUTE local_prepare_no_param_subquery;
EXECUTE local_prepare_no_param_subquery;
@ -596,13 +600,15 @@ BEGIN;
EXECUTE local_prepare_no_param_subquery;
EXECUTE local_prepare_no_param_subquery;
-- 6 local executions with params
-- 8 local executions with params
EXECUTE local_prepare_param(1);
EXECUTE local_prepare_param(5);
EXECUTE local_prepare_param(6);
EXECUTE local_prepare_param(1);
EXECUTE local_prepare_param(5);
EXECUTE local_prepare_param(6);
EXECUTE local_prepare_param(6);
EXECUTE local_prepare_param(6);
-- followed by a non-local execution
EXECUTE remote_prepare_param(1);
@ -611,7 +617,9 @@ COMMIT;
PREPARE local_insert_prepare_no_param AS INSERT INTO distributed_table VALUES (1+0*random(), '11',21::int) ON CONFLICT(key) DO UPDATE SET value = '29' || '28' RETURNING *, key + 1, value || '30', age * 15;
PREPARE local_insert_prepare_param (int) AS INSERT INTO distributed_table VALUES ($1+0*random(), '11',21::int) ON CONFLICT(key) DO UPDATE SET value = '29' || '28' RETURNING *, key + 1, value || '30', age * 15;
BEGIN;
-- 6 local execution without params
-- 8 local execution without params
EXECUTE local_insert_prepare_no_param;
EXECUTE local_insert_prepare_no_param;
EXECUTE local_insert_prepare_no_param;
EXECUTE local_insert_prepare_no_param;
EXECUTE local_insert_prepare_no_param;
@ -619,13 +627,15 @@ BEGIN;
EXECUTE local_insert_prepare_no_param;
EXECUTE local_insert_prepare_no_param;
-- 6 local executions with params
-- 8 local executions with params
EXECUTE local_insert_prepare_param(1);
EXECUTE local_insert_prepare_param(5);
EXECUTE local_insert_prepare_param(6);
EXECUTE local_insert_prepare_param(1);
EXECUTE local_insert_prepare_param(5);
EXECUTE local_insert_prepare_param(6);
EXECUTE local_insert_prepare_param(6);
EXECUTE local_insert_prepare_param(6);
-- followed by a non-local execution
EXECUTE remote_prepare_param(2);
@ -647,6 +657,8 @@ BEGIN;
EXECUTE local_multi_row_insert_prepare_no_param;
EXECUTE local_multi_row_insert_prepare_no_param;
EXECUTE local_multi_row_insert_prepare_no_param;
EXECUTE local_multi_row_insert_prepare_no_param;
EXECUTE local_multi_row_insert_prepare_no_param;
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
@ -654,6 +666,8 @@ BEGIN;
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
EXECUTE local_multi_row_insert_prepare_no_param_multi_shard;
EXECUTE local_multi_row_insert_prepare_params(1,6);
EXECUTE local_multi_row_insert_prepare_params(1,5);
@ -661,6 +675,8 @@ BEGIN;
EXECUTE local_multi_row_insert_prepare_params(5,1);
EXECUTE local_multi_row_insert_prepare_params(5,6);
EXECUTE local_multi_row_insert_prepare_params(5,1);
EXECUTE local_multi_row_insert_prepare_params(1,6);
EXECUTE local_multi_row_insert_prepare_params(1,5);
-- one task is remote
EXECUTE local_multi_row_insert_prepare_params(5,11);
@ -817,6 +833,13 @@ EXECUTE serial_prepared_local;
SELECT setval('collections_list_key_seq', 709);
EXECUTE serial_prepared_local;
-- get ready for the next executions
DELETE FROM collections_list WHERE key IN (5,6);
SELECT setval('collections_list_key_seq', 4);
EXECUTE serial_prepared_local;
SELECT setval('collections_list_key_seq', 5);
EXECUTE serial_prepared_local;
-- and, one remote test
SELECT setval('collections_list_key_seq', 10);
EXECUTE serial_prepared_local;
@ -929,6 +952,7 @@ CALL regular_procedure('no');
CALL regular_procedure('no');
CALL regular_procedure('no');
CALL regular_procedure('no');
CALL regular_procedure('no');
PREPARE multi_shard_no_dist_key(invite_resp) AS select * from event_responses where response = $1::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC LIMIT 1;
EXECUTE multi_shard_no_dist_key('yes');
@ -938,6 +962,7 @@ EXECUTE multi_shard_no_dist_key('yes');
EXECUTE multi_shard_no_dist_key('yes');
EXECUTE multi_shard_no_dist_key('yes');
EXECUTE multi_shard_no_dist_key('yes');
EXECUTE multi_shard_no_dist_key('yes');
PREPARE multi_shard_with_dist_key(int, invite_resp) AS select * from event_responses where event_id > $1 AND response = $2::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC LIMIT 1;
EXECUTE multi_shard_with_dist_key(1, 'yes');
@ -947,6 +972,7 @@ EXECUTE multi_shard_with_dist_key(1, 'yes');
EXECUTE multi_shard_with_dist_key(1, 'yes');
EXECUTE multi_shard_with_dist_key(1, 'yes');
EXECUTE multi_shard_with_dist_key(1, 'yes');
EXECUTE multi_shard_with_dist_key(1, 'yes');
PREPARE query_pushdown_no_dist_key(invite_resp) AS select * from event_responses e1 LEFT JOIN event_responses e2 USING(event_id) where e1.response = $1::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC, 4 DESC LIMIT 1;
EXECUTE query_pushdown_no_dist_key('yes');
@ -956,6 +982,7 @@ EXECUTE query_pushdown_no_dist_key('yes');
EXECUTE query_pushdown_no_dist_key('yes');
EXECUTE query_pushdown_no_dist_key('yes');
EXECUTE query_pushdown_no_dist_key('yes');
EXECUTE query_pushdown_no_dist_key('yes');
PREPARE insert_select_via_coord(invite_resp) AS INSERT INTO event_responses SELECT * FROM event_responses where response = $1::invite_resp LIMIT 1 ON CONFLICT (event_id, user_id) DO NOTHING ;
EXECUTE insert_select_via_coord('yes');
@ -965,6 +992,7 @@ EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
EXECUTE insert_select_via_coord('yes');
PREPARE insert_select_pushdown(invite_resp) AS INSERT INTO event_responses SELECT * FROM event_responses where response = $1::invite_resp ON CONFLICT (event_id, user_id) DO NOTHING;
EXECUTE insert_select_pushdown('yes');
@ -974,6 +1002,7 @@ EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
EXECUTE insert_select_pushdown('yes');
PREPARE router_select_with_no_dist_key_filter(invite_resp) AS select * from event_responses where event_id = 1 AND response = $1::invite_resp ORDER BY 1 DESC, 2 DESC, 3 DESC LIMIT 1;
EXECUTE router_select_with_no_dist_key_filter('yes');
@ -983,6 +1012,7 @@ EXECUTE router_select_with_no_dist_key_filter('yes');
EXECUTE router_select_with_no_dist_key_filter('yes');
EXECUTE router_select_with_no_dist_key_filter('yes');
EXECUTE router_select_with_no_dist_key_filter('yes');
EXECUTE router_select_with_no_dist_key_filter('yes');
-- rest of the tests assume the table is empty
TRUNCATE event_responses;
@ -1005,7 +1035,7 @@ $fn$;
SELECT create_distributed_function('register_for_event(int,int,invite_resp)', 'p_event_id', 'event_responses');
-- call 7 times to make sure it works after the 5th time(postgres binds values after the 5th time)
-- call 8 times to make sure it works after the 5th time(postgres binds values after the 5th time and Citus 2nd time)
-- after 6th, the local execution caches the local plans and uses it
-- execute it both locally and remotely
CALL register_for_event(16, 1, 'yes');
@ -1016,6 +1046,7 @@ CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
\c - - - :worker_2_port
CALL register_for_event(16, 1, 'yes');
@ -1024,7 +1055,7 @@ CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');
CALL register_for_event(16, 1, 'yes');

View File

@ -259,7 +259,7 @@ select mx_call_func(2, 0), mx_call_func(0, 2);
DO $$ BEGIN perform mx_call_func_tbl(40); END; $$;
SELECT * FROM mx_call_dist_table_1 WHERE id >= 40 ORDER BY id, val;
-- Prepared statements. Repeat six times to test for generic plans
-- Prepared statements. Repeat 8 times to test for generic plans
PREPARE call_plan (int, int) AS SELECT mx_call_func($1, $2);
EXECUTE call_plan(2, 0);
EXECUTE call_plan(2, 0);
@ -267,6 +267,8 @@ EXECUTE call_plan(2, 0);
EXECUTE call_plan(2, 0);
EXECUTE call_plan(2, 0);
EXECUTE call_plan(2, 0);
EXECUTE call_plan(2, 0);
EXECUTE call_plan(2, 0);
\c - - - :worker_1_port
SET search_path TO multi_mx_function_call_delegation, public;