mirror of https://github.com/citusdata/citus.git
CALL delegation: apply strip_implicit_coercions to distribution argument
parent
7ffd78b6e0
commit
4063e7ca67
|
@ -71,6 +71,7 @@ CallFuncExprRemotely(CallStmt *callStmt, DistObjectCacheEntry *procedure,
|
|||
FuncExpr *funcExpr, DestReceiver *dest)
|
||||
{
|
||||
Oid colocatedRelationId = InvalidOid;
|
||||
Node *partitionValueNode = NULL;
|
||||
Const *partitionValue = NULL;
|
||||
Datum partitionValueDatum = 0;
|
||||
ShardInterval *shardInterval = NULL;
|
||||
|
@ -118,12 +119,15 @@ CallFuncExprRemotely(CallStmt *callStmt, DistObjectCacheEntry *procedure,
|
|||
return false;
|
||||
}
|
||||
|
||||
partitionValue = (Const *) list_nth(funcExpr->args, procedure->distributionArgIndex);
|
||||
if (!IsA(partitionValue, Const))
|
||||
partitionValueNode = (Node *) list_nth(funcExpr->args,
|
||||
procedure->distributionArgIndex);
|
||||
partitionValueNode = strip_implicit_coercions(partitionValueNode);
|
||||
if (!IsA(partitionValueNode, Const))
|
||||
{
|
||||
ereport(DEBUG1, (errmsg("distribution argument value must be a constant")));
|
||||
return false;
|
||||
}
|
||||
partitionValue = (Const *) partitionValueNode;
|
||||
|
||||
partitionValueDatum = partitionValue->constvalue;
|
||||
if (partitionValue->consttype != partitionColumn->vartype)
|
||||
|
|
|
@ -34,6 +34,14 @@ select create_distributed_table('mx_call_dist_table_2', 'id');
|
|||
(1 row)
|
||||
|
||||
insert into mx_call_dist_table_2 values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
create table mx_call_dist_table_bigint(id bigint, val bigint);
|
||||
select create_distributed_table('mx_call_dist_table_bigint', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
insert into mx_call_dist_table_bigint values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
create table mx_call_dist_table_ref(id int, val int);
|
||||
select create_reference_table('mx_call_dist_table_ref');
|
||||
create_reference_table
|
||||
|
@ -61,6 +69,11 @@ BEGIN
|
|||
-- that are routed to the workers.
|
||||
y := y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id);
|
||||
END;$$;
|
||||
CREATE PROCEDURE mx_call_proc_bigint(x bigint, INOUT y bigint)
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
y := x + y * 2;
|
||||
END;$$;
|
||||
-- create another procedure which verifies:
|
||||
-- 1. we work fine with multiple return columns
|
||||
-- 2. we work fine in combination with custom types
|
||||
|
@ -103,6 +116,12 @@ select create_distributed_function('mx_call_proc(int,int)');
|
|||
|
||||
(1 row)
|
||||
|
||||
select create_distributed_function('mx_call_proc_bigint(bigint,bigint)');
|
||||
create_distributed_function
|
||||
-----------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select create_distributed_function('mx_call_proc_custom_types(mx_call_enum,mx_call_enum)');
|
||||
create_distributed_function
|
||||
-----------------------------
|
||||
|
@ -114,10 +133,10 @@ select create_distributed_function('mx_call_proc_custom_types(mx_call_enum,mx_ca
|
|||
SET client_min_messages TO DEBUG1;
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
DEBUG: stored procedure does not have co-located tables
|
||||
DEBUG: generating subplan 10_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 11_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 10 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('10_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 11 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('11_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
y
|
||||
|
@ -125,6 +144,13 @@ PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
|||
29
|
||||
(1 row)
|
||||
|
||||
call mx_call_proc_bigint(4, 2);
|
||||
DEBUG: stored procedure does not have co-located tables
|
||||
y
|
||||
---
|
||||
8
|
||||
(1 row)
|
||||
|
||||
call multi_mx_call.mx_call_proc_custom_types('S', 'A');
|
||||
DEBUG: stored procedure does not have co-located tables
|
||||
x | y
|
||||
|
@ -139,6 +165,12 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
(1 row)
|
||||
|
||||
select colocate_proc_with_table('mx_call_proc_bigint', 'mx_call_dist_table_bigint'::regclass, 1);
|
||||
colocate_proc_with_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select colocate_proc_with_table('mx_call_proc_custom_types', 'mx_call_dist_table_enum'::regclass, 1);
|
||||
colocate_proc_with_table
|
||||
--------------------------
|
||||
|
@ -173,14 +205,22 @@ DEBUG: pushing down the procedure
|
|||
S | S
|
||||
(1 row)
|
||||
|
||||
-- Test implicit cast of int to bigint
|
||||
call mx_call_proc_bigint(4, 2);
|
||||
DEBUG: pushing down the procedure
|
||||
y
|
||||
---
|
||||
8
|
||||
(1 row)
|
||||
|
||||
-- We don't allow distributing calls inside transactions
|
||||
begin;
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
DEBUG: cannot push down CALL in multi-statement transaction
|
||||
DEBUG: generating subplan 12_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 13_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 12 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 13 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('13_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
y
|
||||
|
@ -211,10 +251,10 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
DEBUG: cannot push down invalid distribution_argument_index
|
||||
DEBUG: generating subplan 14_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 15_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 14 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('14_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 15 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('15_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
y
|
||||
|
@ -230,10 +270,10 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
DEBUG: cannot push down invalid distribution_argument_index
|
||||
DEBUG: generating subplan 17_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 18_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 17 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('17_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 18 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('18_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
y
|
||||
|
@ -250,10 +290,10 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_ref'::regcla
|
|||
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
DEBUG: cannot push down CALL for reference tables
|
||||
DEBUG: generating subplan 19_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 20_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 19 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('19_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 20 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('20_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
y
|
||||
|
@ -270,10 +310,10 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_replica'::re
|
|||
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
DEBUG: cannot push down CALL for replicated distributed tables
|
||||
DEBUG: generating subplan 21_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 22_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 21 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('21_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 22 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('22_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
y
|
||||
|
@ -363,10 +403,10 @@ select stop_metadata_sync_to_node('localhost', :worker_2_port);
|
|||
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
DEBUG: there is no worker node with metadata
|
||||
DEBUG: generating subplan 27_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 28_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_call.mx_call_dist_table_1 t1 JOIN multi_mx_call.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 27 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('27_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 28 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('28_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
||||
y
|
||||
|
@ -398,7 +438,7 @@ SET client_min_messages TO DEBUG1;
|
|||
--
|
||||
CREATE FUNCTION mx_call_add(int, int) RETURNS int
|
||||
AS 'select $1 + $2;' LANGUAGE SQL IMMUTABLE;
|
||||
SELECT create_distributed_function('mx_call_add(int,int)', '$1');
|
||||
SELECT create_distributed_function('mx_call_add(int,int)');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
|
@ -445,4 +485,4 @@ PL/pgSQL function mx_call_proc(integer,integer) line 8 at assignment
|
|||
reset client_min_messages;
|
||||
\set VERBOSITY terse
|
||||
drop schema multi_mx_call cascade;
|
||||
NOTICE: drop cascades to 9 other objects
|
||||
NOTICE: drop cascades to 11 other objects
|
||||
|
|
|
@ -34,6 +34,14 @@ select create_distributed_table('mx_call_dist_table_2', 'id');
|
|||
(1 row)
|
||||
|
||||
insert into mx_call_dist_table_2 values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
create table mx_call_dist_table_bigint(id bigint, val bigint);
|
||||
select create_distributed_table('mx_call_dist_table_bigint', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
insert into mx_call_dist_table_bigint values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
create table mx_call_dist_table_ref(id int, val int);
|
||||
select create_reference_table('mx_call_dist_table_ref');
|
||||
create_reference_table
|
||||
|
@ -64,6 +72,14 @@ END;$$;
|
|||
ERROR: syntax error at or near "PROCEDURE"
|
||||
LINE 1: CREATE PROCEDURE mx_call_proc(x int, INOUT y int)
|
||||
^
|
||||
CREATE PROCEDURE mx_call_proc_bigint(x bigint, INOUT y bigint)
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
y := x + y * 2;
|
||||
END;$$;
|
||||
ERROR: syntax error at or near "PROCEDURE"
|
||||
LINE 1: CREATE PROCEDURE mx_call_proc_bigint(x bigint, INOUT y bigin...
|
||||
^
|
||||
-- create another procedure which verifies:
|
||||
-- 1. we work fine with multiple return columns
|
||||
-- 2. we work fine in combination with custom types
|
||||
|
@ -99,6 +115,10 @@ select create_distributed_function('mx_call_proc(int,int)');
|
|||
ERROR: function "mx_call_proc(int,int)" does not exist
|
||||
LINE 1: select create_distributed_function('mx_call_proc(int,int)');
|
||||
^
|
||||
select create_distributed_function('mx_call_proc_bigint(bigint,bigint)');
|
||||
ERROR: function "mx_call_proc_bigint(bigint,bigint)" does not exist
|
||||
LINE 1: select create_distributed_function('mx_call_proc_bigint(bigi...
|
||||
^
|
||||
select create_distributed_function('mx_call_proc_custom_types(mx_call_enum,mx_call_enum)');
|
||||
ERROR: function "mx_call_proc_custom_types(mx_call_enum,mx_call_enum)" does not exist
|
||||
LINE 1: select create_distributed_function('mx_call_proc_custom_type...
|
||||
|
@ -110,6 +130,10 @@ call multi_mx_call.mx_call_proc(2, 0);
|
|||
ERROR: syntax error at or near "call"
|
||||
LINE 1: call multi_mx_call.mx_call_proc(2, 0);
|
||||
^
|
||||
call mx_call_proc_bigint(4, 2);
|
||||
ERROR: syntax error at or near "call"
|
||||
LINE 1: call mx_call_proc_bigint(4, 2);
|
||||
^
|
||||
call multi_mx_call.mx_call_proc_custom_types('S', 'A');
|
||||
ERROR: syntax error at or near "call"
|
||||
LINE 1: call multi_mx_call.mx_call_proc_custom_types('S', 'A');
|
||||
|
@ -121,6 +145,12 @@ select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
(1 row)
|
||||
|
||||
select colocate_proc_with_table('mx_call_proc_bigint', 'mx_call_dist_table_bigint'::regclass, 1);
|
||||
colocate_proc_with_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select colocate_proc_with_table('mx_call_proc_custom_types', 'mx_call_dist_table_enum'::regclass, 1);
|
||||
colocate_proc_with_table
|
||||
--------------------------
|
||||
|
@ -143,6 +173,11 @@ call mx_call_proc_custom_types('S', 'A');
|
|||
ERROR: syntax error at or near "call"
|
||||
LINE 1: call mx_call_proc_custom_types('S', 'A');
|
||||
^
|
||||
-- Test implicit cast of int to bigint
|
||||
call mx_call_proc_bigint(4, 2);
|
||||
ERROR: syntax error at or near "call"
|
||||
LINE 1: call mx_call_proc_bigint(4, 2);
|
||||
^
|
||||
-- We don't allow distributing calls inside transactions
|
||||
begin;
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
|
@ -308,7 +343,7 @@ SET client_min_messages TO DEBUG1;
|
|||
--
|
||||
CREATE FUNCTION mx_call_add(int, int) RETURNS int
|
||||
AS 'select $1 + $2;' LANGUAGE SQL IMMUTABLE;
|
||||
SELECT create_distributed_function('mx_call_add(int,int)', '$1');
|
||||
SELECT create_distributed_function('mx_call_add(int,int)');
|
||||
DEBUG: switching to sequential query execution mode
|
||||
DETAIL: A distributed function is created. To make sure subsequent commands see the type correctly we need to make sure to use only one connection for all future commands
|
||||
create_distributed_function
|
||||
|
@ -334,4 +369,4 @@ LINE 1: call multi_mx_call.mx_call_proc(floor(random())::int, 2);
|
|||
reset client_min_messages;
|
||||
\set VERBOSITY terse
|
||||
drop schema multi_mx_call cascade;
|
||||
NOTICE: drop cascades to 5 other objects
|
||||
NOTICE: drop cascades to 6 other objects
|
||||
|
|
|
@ -33,6 +33,14 @@ select create_distributed_table('mx_call_dist_table_2', 'id');
|
|||
(1 row)
|
||||
|
||||
insert into mx_call_dist_table_2 values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
create table mx_call_dist_table_bigint(id bigint, val bigint);
|
||||
select create_distributed_table('mx_call_dist_table_bigint', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
insert into mx_call_dist_table_bigint values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
create table mx_call_dist_table_ref(id int, val int);
|
||||
select create_reference_table('mx_call_dist_table_ref');
|
||||
create_reference_table
|
||||
|
@ -63,6 +71,11 @@ BEGIN
|
|||
-- that are routed to the workers.
|
||||
y := y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id);
|
||||
END;$$;
|
||||
CREATE FUNCTION mx_call_func_bigint(x bigint, INOUT y bigint)
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
y := x + y * 2;
|
||||
END;$$;
|
||||
-- create another function which verifies:
|
||||
-- 1. we work fine with multiple return columns
|
||||
-- 2. we work fine in combination with custom types
|
||||
|
@ -108,6 +121,12 @@ select create_distributed_function('mx_call_func(int,int)');
|
|||
|
||||
(1 row)
|
||||
|
||||
select create_distributed_function('mx_call_func_bigint(bigint,bigint)');
|
||||
create_distributed_function
|
||||
-----------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select create_distributed_function('mx_call_func_custom_types(mx_call_enum,mx_call_enum)');
|
||||
create_distributed_function
|
||||
-----------------------------
|
||||
|
@ -125,10 +144,10 @@ select create_distributed_function('squares(int)');
|
|||
SET client_min_messages TO DEBUG1;
|
||||
select mx_call_func(2, 0);
|
||||
DEBUG: function does not have co-located tables
|
||||
DEBUG: generating subplan 10_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 11_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 10 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('10_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 11 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('11_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
mx_call_func
|
||||
|
@ -136,6 +155,13 @@ PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
|||
29
|
||||
(1 row)
|
||||
|
||||
select multi_mx_function_call_delegation.mx_call_func_bigint(4, 2);
|
||||
DEBUG: function does not have co-located tables
|
||||
mx_call_func_bigint
|
||||
---------------------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
select mx_call_func_custom_types('S', 'A');
|
||||
DEBUG: function does not have co-located tables
|
||||
mx_call_func_custom_types
|
||||
|
@ -150,6 +176,12 @@ select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
(1 row)
|
||||
|
||||
select colocate_proc_with_table('mx_call_func_bigint', 'mx_call_dist_table_bigint'::regclass, 1);
|
||||
colocate_proc_with_table
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select colocate_proc_with_table('mx_call_func_custom_types', 'mx_call_dist_table_enum'::regclass, 1);
|
||||
colocate_proc_with_table
|
||||
--------------------------
|
||||
|
@ -169,6 +201,13 @@ DEBUG: pushing down the function call
|
|||
28
|
||||
(1 row)
|
||||
|
||||
select mx_call_func_bigint(4, 2);
|
||||
DEBUG: pushing down the function call
|
||||
mx_call_func_bigint
|
||||
---------------------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
select mx_call_func_custom_types('S', 'A');
|
||||
DEBUG: pushing down the function call
|
||||
mx_call_func_custom_types
|
||||
|
@ -197,10 +236,10 @@ DEBUG: pushing down the function call
|
|||
begin;
|
||||
select mx_call_func(2, 0);
|
||||
DEBUG: not pushing down function calls in a multi-statement transaction
|
||||
DEBUG: generating subplan 12_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 13_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 12 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 13 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('13_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
mx_call_func
|
||||
|
@ -231,10 +270,10 @@ select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
select mx_call_func(2, 0);
|
||||
DEBUG: function call does not have a distribution argument
|
||||
DEBUG: generating subplan 14_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 15_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 14 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('14_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 15 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('15_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
mx_call_func
|
||||
|
@ -250,10 +289,10 @@ select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_1'::regclass
|
|||
|
||||
select mx_call_func(2, 0);
|
||||
DEBUG: function call does not have a distribution argument
|
||||
DEBUG: generating subplan 17_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 18_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 17 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('17_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 18 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('18_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
mx_call_func
|
||||
|
@ -270,10 +309,10 @@ select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_ref'::regcla
|
|||
|
||||
select mx_call_func(2, 0);
|
||||
DEBUG: cannnot push down function call for reference tables
|
||||
DEBUG: generating subplan 19_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 20_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 19 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('19_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 20 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('20_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
mx_call_func
|
||||
|
@ -290,10 +329,10 @@ select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_replica'::re
|
|||
|
||||
select mx_call_func(2, 0);
|
||||
DEBUG: cannot push down function call for replicated distributed tables
|
||||
DEBUG: generating subplan 21_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 22_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 21 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('21_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 22 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('22_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
mx_call_func
|
||||
|
@ -407,8 +446,8 @@ SELECT * FROM test WHERE not exists(
|
|||
SELECT delegated_function(4)
|
||||
);
|
||||
DEBUG: not pushing down function calls in CTEs or Subqueries
|
||||
DEBUG: generating subplan 30_1 for subquery SELECT multi_mx_function_call_delegation.delegated_function(4) AS delegated_function
|
||||
DEBUG: Plan 30 query after replacing subqueries and CTEs: SELECT x FROM multi_mx_function_call_delegation.test WHERE (NOT (EXISTS (SELECT intermediate_result.delegated_function FROM read_intermediate_result('30_1'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer))))
|
||||
DEBUG: generating subplan 31_1 for subquery SELECT multi_mx_function_call_delegation.delegated_function(4) AS delegated_function
|
||||
DEBUG: Plan 31 query after replacing subqueries and CTEs: SELECT x FROM multi_mx_function_call_delegation.test WHERE (NOT (EXISTS (SELECT intermediate_result.delegated_function FROM read_intermediate_result('31_1'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer))))
|
||||
x
|
||||
---
|
||||
(0 rows)
|
||||
|
@ -416,10 +455,10 @@ DEBUG: Plan 30 query after replacing subqueries and CTEs: SELECT x FROM multi_m
|
|||
WITH r AS (
|
||||
SELECT delegated_function(7)
|
||||
) SELECT * FROM test WHERE (SELECT count(*)=0 FROM r);
|
||||
DEBUG: generating subplan 33_1 for CTE r: SELECT multi_mx_function_call_delegation.delegated_function(7) AS delegated_function
|
||||
DEBUG: generating subplan 34_1 for CTE r: SELECT multi_mx_function_call_delegation.delegated_function(7) AS delegated_function
|
||||
DEBUG: not pushing down function calls in CTEs or Subqueries
|
||||
DEBUG: generating subplan 33_2 for subquery SELECT (count(*) OPERATOR(pg_catalog.=) 0) FROM (SELECT intermediate_result.delegated_function FROM read_intermediate_result('33_1'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer)) r
|
||||
DEBUG: Plan 33 query after replacing subqueries and CTEs: SELECT x FROM multi_mx_function_call_delegation.test WHERE (SELECT intermediate_result."?column?" FROM read_intermediate_result('33_2'::text, 'binary'::citus_copy_format) intermediate_result("?column?" boolean))
|
||||
DEBUG: generating subplan 34_2 for subquery SELECT (count(*) OPERATOR(pg_catalog.=) 0) FROM (SELECT intermediate_result.delegated_function FROM read_intermediate_result('34_1'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer)) r
|
||||
DEBUG: Plan 34 query after replacing subqueries and CTEs: SELECT x FROM multi_mx_function_call_delegation.test WHERE (SELECT intermediate_result."?column?" FROM read_intermediate_result('34_2'::text, 'binary'::citus_copy_format) intermediate_result("?column?" boolean))
|
||||
x
|
||||
---
|
||||
(0 rows)
|
||||
|
@ -429,10 +468,10 @@ WITH r AS (
|
|||
), t AS (
|
||||
SELECT count(*) c FROM r
|
||||
) SELECT * FROM test, t WHERE t.c=0;
|
||||
DEBUG: generating subplan 37_1 for CTE r: SELECT multi_mx_function_call_delegation.delegated_function(10) AS delegated_function
|
||||
DEBUG: generating subplan 38_1 for CTE r: SELECT multi_mx_function_call_delegation.delegated_function(10) AS delegated_function
|
||||
DEBUG: not pushing down function calls in CTEs or Subqueries
|
||||
DEBUG: generating subplan 37_2 for CTE t: SELECT count(*) AS c FROM (SELECT intermediate_result.delegated_function FROM read_intermediate_result('37_1'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer)) r
|
||||
DEBUG: Plan 37 query after replacing subqueries and CTEs: SELECT test.x, t.c FROM multi_mx_function_call_delegation.test, (SELECT intermediate_result.c FROM read_intermediate_result('37_2'::text, 'binary'::citus_copy_format) intermediate_result(c bigint)) t WHERE (t.c OPERATOR(pg_catalog.=) 0)
|
||||
DEBUG: generating subplan 38_2 for CTE t: SELECT count(*) AS c FROM (SELECT intermediate_result.delegated_function FROM read_intermediate_result('38_1'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer)) r
|
||||
DEBUG: Plan 38 query after replacing subqueries and CTEs: SELECT test.x, t.c FROM multi_mx_function_call_delegation.test, (SELECT intermediate_result.c FROM read_intermediate_result('38_2'::text, 'binary'::citus_copy_format) intermediate_result(c bigint)) t WHERE (t.c OPERATOR(pg_catalog.=) 0)
|
||||
x | c
|
||||
---+---
|
||||
(0 rows)
|
||||
|
@ -444,11 +483,11 @@ WITH r AS (
|
|||
), t AS (
|
||||
SELECT count(*) c FROM s
|
||||
) SELECT * FROM test, r, t WHERE t.c=0;
|
||||
DEBUG: generating subplan 41_1 for CTE r: SELECT count(*) AS count FROM multi_mx_function_call_delegation.test
|
||||
DEBUG: generating subplan 41_2 for CTE s: SELECT multi_mx_function_call_delegation.delegated_function(13) AS delegated_function
|
||||
DEBUG: generating subplan 42_1 for CTE r: SELECT count(*) AS count FROM multi_mx_function_call_delegation.test
|
||||
DEBUG: generating subplan 42_2 for CTE s: SELECT multi_mx_function_call_delegation.delegated_function(13) AS delegated_function
|
||||
DEBUG: not pushing down function calls in CTEs or Subqueries
|
||||
DEBUG: generating subplan 41_3 for CTE t: SELECT count(*) AS c FROM (SELECT intermediate_result.delegated_function FROM read_intermediate_result('41_2'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer)) s
|
||||
DEBUG: Plan 41 query after replacing subqueries and CTEs: SELECT test.x, r.count, t.c FROM multi_mx_function_call_delegation.test, (SELECT intermediate_result.count FROM read_intermediate_result('41_1'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) r, (SELECT intermediate_result.c FROM read_intermediate_result('41_3'::text, 'binary'::citus_copy_format) intermediate_result(c bigint)) t WHERE (t.c OPERATOR(pg_catalog.=) 0)
|
||||
DEBUG: generating subplan 42_3 for CTE t: SELECT count(*) AS c FROM (SELECT intermediate_result.delegated_function FROM read_intermediate_result('42_2'::text, 'binary'::citus_copy_format) intermediate_result(delegated_function integer)) s
|
||||
DEBUG: Plan 42 query after replacing subqueries and CTEs: SELECT test.x, r.count, t.c FROM multi_mx_function_call_delegation.test, (SELECT intermediate_result.count FROM read_intermediate_result('42_1'::text, 'binary'::citus_copy_format) intermediate_result(count bigint)) r, (SELECT intermediate_result.c FROM read_intermediate_result('42_3'::text, 'binary'::citus_copy_format) intermediate_result(c bigint)) t WHERE (t.c OPERATOR(pg_catalog.=) 0)
|
||||
x | count | c
|
||||
---+-------+---
|
||||
(0 rows)
|
||||
|
@ -468,10 +507,10 @@ select stop_metadata_sync_to_node('localhost', :worker_2_port);
|
|||
|
||||
select mx_call_func(2, 0);
|
||||
DEBUG: the worker node does not have metadata
|
||||
DEBUG: generating subplan 46_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
DEBUG: generating subplan 47_1 for subquery SELECT sum((t1.val OPERATOR(pg_catalog.+) t2.val)) AS sum FROM (multi_mx_function_call_delegation.mx_call_dist_table_1 t1 JOIN multi_mx_function_call_delegation.mx_call_dist_table_2 t2 ON ((t1.id OPERATOR(pg_catalog.=) t2.id)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
DEBUG: Plan 46 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('46_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
DEBUG: Plan 47 query after replacing subqueries and CTEs: SELECT (3 OPERATOR(pg_catalog.+) (SELECT intermediate_result.sum FROM read_intermediate_result('47_1'::text, 'binary'::citus_copy_format) intermediate_result(sum bigint)))
|
||||
CONTEXT: SQL statement "SELECT y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id)"
|
||||
PL/pgSQL function mx_call_func(integer,integer) line 8 at assignment
|
||||
mx_call_func
|
||||
|
@ -653,4 +692,4 @@ DEBUG: pushing down the function call
|
|||
RESET client_min_messages;
|
||||
\set VERBOSITY terse
|
||||
DROP SCHEMA multi_mx_function_call_delegation CASCADE;
|
||||
NOTICE: drop cascades to 12 other objects
|
||||
NOTICE: drop cascades to 14 other objects
|
||||
|
|
|
@ -27,6 +27,10 @@ create table mx_call_dist_table_2(id int, val int);
|
|||
select create_distributed_table('mx_call_dist_table_2', 'id');
|
||||
insert into mx_call_dist_table_2 values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
|
||||
create table mx_call_dist_table_bigint(id bigint, val bigint);
|
||||
select create_distributed_table('mx_call_dist_table_bigint', 'id');
|
||||
insert into mx_call_dist_table_bigint values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
|
||||
create table mx_call_dist_table_ref(id int, val int);
|
||||
select create_reference_table('mx_call_dist_table_ref');
|
||||
insert into mx_call_dist_table_ref values (2,7),(1,8),(2,8),(1,8),(2,8);
|
||||
|
@ -48,6 +52,12 @@ BEGIN
|
|||
y := y + (select sum(t1.val + t2.val) from multi_mx_call.mx_call_dist_table_1 t1 join multi_mx_call.mx_call_dist_table_2 t2 on t1.id = t2.id);
|
||||
END;$$;
|
||||
|
||||
CREATE PROCEDURE mx_call_proc_bigint(x bigint, INOUT y bigint)
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
y := x + y * 2;
|
||||
END;$$;
|
||||
|
||||
-- create another procedure which verifies:
|
||||
-- 1. we work fine with multiple return columns
|
||||
-- 2. we work fine in combination with custom types
|
||||
|
@ -68,16 +78,19 @@ call mx_call_proc_custom_types('S', 'A');
|
|||
|
||||
-- Mark both procedures as distributed ...
|
||||
select create_distributed_function('mx_call_proc(int,int)');
|
||||
select create_distributed_function('mx_call_proc_bigint(bigint,bigint)');
|
||||
select create_distributed_function('mx_call_proc_custom_types(mx_call_enum,mx_call_enum)');
|
||||
|
||||
-- We still don't route them to the workers, because they aren't
|
||||
-- colocated with any distributed tables.
|
||||
SET client_min_messages TO DEBUG1;
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
call mx_call_proc_bigint(4, 2);
|
||||
call multi_mx_call.mx_call_proc_custom_types('S', 'A');
|
||||
|
||||
-- Mark them as colocated with a table. Now we should route them to workers.
|
||||
select colocate_proc_with_table('mx_call_proc', 'mx_call_dist_table_1'::regclass, 1);
|
||||
select colocate_proc_with_table('mx_call_proc_bigint', 'mx_call_dist_table_bigint'::regclass, 1);
|
||||
select colocate_proc_with_table('mx_call_proc_custom_types', 'mx_call_dist_table_enum'::regclass, 1);
|
||||
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
|
@ -85,6 +98,9 @@ call multi_mx_call.mx_call_proc_custom_types('S', 'A');
|
|||
call mx_call_proc(2, 0);
|
||||
call mx_call_proc_custom_types('S', 'A');
|
||||
|
||||
-- Test implicit cast of int to bigint
|
||||
call mx_call_proc_bigint(4, 2);
|
||||
|
||||
-- We don't allow distributing calls inside transactions
|
||||
begin;
|
||||
call multi_mx_call.mx_call_proc(2, 0);
|
||||
|
@ -167,7 +183,7 @@ SET client_min_messages TO DEBUG1;
|
|||
--
|
||||
CREATE FUNCTION mx_call_add(int, int) RETURNS int
|
||||
AS 'select $1 + $2;' LANGUAGE SQL IMMUTABLE;
|
||||
SELECT create_distributed_function('mx_call_add(int,int)', '$1');
|
||||
SELECT create_distributed_function('mx_call_add(int,int)');
|
||||
|
||||
-- non-const distribution parameters cannot be pushed down
|
||||
call multi_mx_call.mx_call_proc(2, mx_call_add(3, 4));
|
||||
|
|
|
@ -25,6 +25,10 @@ create table mx_call_dist_table_2(id int, val int);
|
|||
select create_distributed_table('mx_call_dist_table_2', 'id');
|
||||
insert into mx_call_dist_table_2 values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
|
||||
create table mx_call_dist_table_bigint(id bigint, val bigint);
|
||||
select create_distributed_table('mx_call_dist_table_bigint', 'id');
|
||||
insert into mx_call_dist_table_bigint values (1,1),(1,2),(2,2),(3,3),(3,4);
|
||||
|
||||
create table mx_call_dist_table_ref(id int, val int);
|
||||
select create_reference_table('mx_call_dist_table_ref');
|
||||
insert into mx_call_dist_table_ref values (2,7),(1,8),(2,8),(1,8),(2,8);
|
||||
|
@ -49,6 +53,12 @@ BEGIN
|
|||
y := y + (select sum(t1.val + t2.val) from multi_mx_function_call_delegation.mx_call_dist_table_1 t1 join multi_mx_function_call_delegation.mx_call_dist_table_2 t2 on t1.id = t2.id);
|
||||
END;$$;
|
||||
|
||||
CREATE FUNCTION mx_call_func_bigint(x bigint, INOUT y bigint)
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
y := x + y * 2;
|
||||
END;$$;
|
||||
|
||||
-- create another function which verifies:
|
||||
-- 1. we work fine with multiple return columns
|
||||
-- 2. we work fine in combination with custom types
|
||||
|
@ -69,6 +79,7 @@ select mx_call_func(2, 0);
|
|||
|
||||
-- Mark both functions as distributed ...
|
||||
select create_distributed_function('mx_call_func(int,int)');
|
||||
select create_distributed_function('mx_call_func_bigint(bigint,bigint)');
|
||||
select create_distributed_function('mx_call_func_custom_types(mx_call_enum,mx_call_enum)');
|
||||
select create_distributed_function('squares(int)');
|
||||
|
||||
|
@ -76,14 +87,17 @@ select create_distributed_function('squares(int)');
|
|||
-- colocated with any distributed tables.
|
||||
SET client_min_messages TO DEBUG1;
|
||||
select mx_call_func(2, 0);
|
||||
select multi_mx_function_call_delegation.mx_call_func_bigint(4, 2);
|
||||
select mx_call_func_custom_types('S', 'A');
|
||||
|
||||
-- Mark them as colocated with a table. Now we should route them to workers.
|
||||
select colocate_proc_with_table('mx_call_func', 'mx_call_dist_table_1'::regclass, 1);
|
||||
select colocate_proc_with_table('mx_call_func_bigint', 'mx_call_dist_table_bigint'::regclass, 1);
|
||||
select colocate_proc_with_table('mx_call_func_custom_types', 'mx_call_dist_table_enum'::regclass, 1);
|
||||
select colocate_proc_with_table('squares', 'mx_call_dist_table_2'::regclass, 0);
|
||||
|
||||
select mx_call_func(2, 0);
|
||||
select mx_call_func_bigint(4, 2);
|
||||
select mx_call_func_custom_types('S', 'A');
|
||||
select squares(4);
|
||||
select multi_mx_function_call_delegation.mx_call_func(2, 0);
|
||||
|
|
Loading…
Reference in New Issue