Fix #7242, CALL(@0) crash backend

When executing a prepared CALL, which is not pure SQL but available
with some drivers like npgsql and jpgdbc, Citus entered a code path where
a plan is not defined, while trying to increase its cost.
Thus SIG11 when plan is a NULL pointer.

Fix by just increasing plan cost when plan is not null.

However, it is a bit suspicious to get here with a NULL plan and maybe a
better change will be to not call ShardPlacementForFunctionColocatedWithDistTable()
with a NULL plan at all (in call.c:134)
pull/7288/head
Cédric Villemain 2023-10-31 09:53:03 +01:00
parent ea5551689e
commit f9e46ba010
2 changed files with 5 additions and 1 deletions

View File

@ -702,6 +702,7 @@ DissuadePlannerFromUsingPlan(PlannedStmt *plan)
* Arbitrarily high cost, but low enough that it can be added up
* without overflowing by choose_custom_plan().
*/
Assert(plan != NULL);
plan->planTree->total_cost = FLT_MAX / 100000000;
}

View File

@ -526,7 +526,10 @@ ShardPlacementForFunctionColocatedWithDistTable(DistObjectCacheEntry *procedure,
if (partitionParam->paramkind == PARAM_EXTERN)
{
/* Don't log a message, we should end up here again without a parameter */
DissuadePlannerFromUsingPlan(plan);
if (plan)
{
DissuadePlannerFromUsingPlan(plan);
}
return NULL;
}
}