diff --git a/src/backend/distributed/utils/citus_clauses.c b/src/backend/distributed/utils/citus_clauses.c index b5ea6562b..16a4083df 100644 --- a/src/backend/distributed/utils/citus_clauses.c +++ b/src/backend/distributed/utils/citus_clauses.c @@ -27,7 +27,7 @@ /* private function declarations */ -static bool IsVarNode(Node *node); +static bool IsVarOrParamSublink(Node *node); static Expr * citus_evaluate_expr(Expr *expr, Oid result_type, int32 result_typmod, Oid result_collation, MasterEvaluationContext *masterEvaluationContext); @@ -120,7 +120,8 @@ PartiallyEvaluateExpression(Node *expression, else if (ShouldEvaluateExpressionType(nodeTag) && ShouldEvaluateFunctionWithMasterContext(masterEvaluationContext)) { - if (FindNodeCheck(expression, IsVarNode)) + /* don't call citus_evaluate_expr on nodes it cannot handle */ + if (FindNodeCheck(expression, IsVarOrParamSublink)) { return (Node *) expression_tree_mutator(expression, PartiallyEvaluateExpression, @@ -200,11 +201,17 @@ ShouldEvaluateExpressionType(NodeTag nodeTag) /* - * IsVarNode returns whether a node is a Var (column reference). + * IsVarOrParamSublink returns whether node is a Var or PARAM_SUBLINK param. */ static bool -IsVarNode(Node *node) +IsVarOrParamSublink(Node *node) { + if (IsA(node, Param)) + { + /* ExecInitExpr cannot handle PARAM_SUBLINK */ + return ((Param *) node)->paramkind == PARAM_SUBLINK; + } + return IsA(node, Var); } diff --git a/src/test/regress/expected/multi_router_planner.out b/src/test/regress/expected/multi_router_planner.out index b6a68e849..d87250868 100644 --- a/src/test/regress/expected/multi_router_planner.out +++ b/src/test/regress/expected/multi_router_planner.out @@ -2363,7 +2363,7 @@ INSERT INTO articles_hash VALUES (51, 1, 'amateus', 1814), (52, 1, 'second amate DEBUG: Creating router plan DEBUG: Plan is router executable DETAIL: distribution column value: 1 --- verify insert is successfull (not router plannable and executable) +-- verify insert is successful (not router plannable and executable) SELECT id FROM articles_hash WHERE author_id = 1; @@ -2381,6 +2381,12 @@ DETAIL: distribution column value: 1 52 (7 rows) +-- https://github.com/citusdata/citus/issues/3624 +UPDATE articles_hash SET id = id +WHERE author_id = 1 AND title IN (SELECT name FROM authors_reference WHERE random() > 0.5); +DEBUG: Creating router plan +DEBUG: Plan is router executable +DETAIL: distribution column value: 1 SET client_min_messages to 'NOTICE'; -- test that a connection failure marks placements invalid SET citus.shard_replication_factor TO 2; diff --git a/src/test/regress/sql/multi_router_planner.sql b/src/test/regress/sql/multi_router_planner.sql index a9783b105..9315f1ac7 100644 --- a/src/test/regress/sql/multi_router_planner.sql +++ b/src/test/regress/sql/multi_router_planner.sql @@ -1096,11 +1096,15 @@ SELECT id -- insert query is router plannable even under task-tracker INSERT INTO articles_hash VALUES (51, 1, 'amateus', 1814), (52, 1, 'second amateus', 2824); --- verify insert is successfull (not router plannable and executable) +-- verify insert is successful (not router plannable and executable) SELECT id FROM articles_hash WHERE author_id = 1; +-- https://github.com/citusdata/citus/issues/3624 +UPDATE articles_hash SET id = id +WHERE author_id = 1 AND title IN (SELECT name FROM authors_reference WHERE random() > 0.5); + SET client_min_messages to 'NOTICE'; -- test that a connection failure marks placements invalid