Re: Consistent segfault in complex query

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Consistent segfault in complex query
Дата
Msg-id 5943.1536877122@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Consistent segfault in complex query  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Consistent segfault in complex query  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-hackers
I wrote:
> Your other idea of forcing initPlan parameters to be evaluated before we
> enter the EPQ execution environment is probably more workable.

Concretely, the attached seems to be enough to fix it (though I only
tried the simplest case you posted).

I don't find anything to love about ExecEvalParamExecParams: it's badly
named, badly located, full of undocumented assumptions, and probably
causes a memory leak.  Plus it doesn't exist as far back as we need it
for this.  But fixing those problems is a separable task.  In the
meantime, this is an expedient way to test whether this approach can work.

            regards, tom lane

diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index c583e02..35c9eb2 100644
*** a/src/backend/executor/execMain.c
--- b/src/backend/executor/execMain.c
***************
*** 46,51 ****
--- 46,52 ----
  #include "commands/matview.h"
  #include "commands/trigger.h"
  #include "executor/execdebug.h"
+ #include "executor/execExpr.h"
  #include "foreign/fdwapi.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
*************** EvalPlanQualBegin(EPQState *epqstate, ES
*** 3078,3083 ****
--- 3079,3087 ----
          {
              int            i;

+             /* First, force evaluation of any initPlans needed by subplan */
+             ExecEvalParamExecParams(planstate->plan->extParam, parentestate);
+
              i = list_length(parentestate->es_plannedstmt->paramExecTypes);

              while (--i >= 0)
*************** EvalPlanQualStart(EPQState *epqstate, ES
*** 3170,3175 ****
--- 3174,3182 ----
      {
          int            i;

+         /* First, force evaluation of any initPlans needed by subplan */
+         ExecEvalParamExecParams(planTree->extParam, parentestate);
+
          i = list_length(parentestate->es_plannedstmt->paramExecTypes);
          estate->es_param_exec_vals = (ParamExecData *)
              palloc0(i * sizeof(ParamExecData));

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Gierth
Дата:
Сообщение: Re: Consistent segfault in complex query
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Consistent segfault in complex query