Commit b3ee4c50 authored by Andres Freund's avatar Andres Freund

Cope with NULL query string in ExecInitParallelPlan().

It's far from clear that this is the right approach - but a good
portion of the buildfarm has been red for a few hours, on the last day
of the CF. And this fixes at least the obvious crash. So let's go with
that for now.

Discussion: https://postgr.es/m/20210407225806.majgznh4lk34hjvu%40alap3.anarazel.de
parent 8ffb0035
...@@ -647,7 +647,7 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, ...@@ -647,7 +647,7 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
shm_toc_estimate_keys(&pcxt->estimator, 1); shm_toc_estimate_keys(&pcxt->estimator, 1);
/* Estimate space for query text. */ /* Estimate space for query text. */
query_len = strlen(estate->es_sourceText); query_len = estate->es_sourceText ? strlen(estate->es_sourceText) : 0;
shm_toc_estimate_chunk(&pcxt->estimator, query_len + 1); shm_toc_estimate_chunk(&pcxt->estimator, query_len + 1);
shm_toc_estimate_keys(&pcxt->estimator, 1); shm_toc_estimate_keys(&pcxt->estimator, 1);
...@@ -742,7 +742,10 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, ...@@ -742,7 +742,10 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate,
/* Store query string */ /* Store query string */
query_string = shm_toc_allocate(pcxt->toc, query_len + 1); query_string = shm_toc_allocate(pcxt->toc, query_len + 1);
memcpy(query_string, estate->es_sourceText, query_len + 1); if (query_len == 0)
query_string[0] = 0;
else
memcpy(query_string, estate->es_sourceText, query_len + 1);
shm_toc_insert(pcxt->toc, PARALLEL_KEY_QUERY_TEXT, query_string); shm_toc_insert(pcxt->toc, PARALLEL_KEY_QUERY_TEXT, query_string);
/* Store serialized PlannedStmt. */ /* Store serialized PlannedStmt. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment