Re: SPI_ERROR_CONNECT within pl/pgsql, PG 8.4

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: SPI_ERROR_CONNECT within pl/pgsql, PG 8.4
Дата
Msg-id 20196.1247584515@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: SPI_ERROR_CONNECT within pl/pgsql, PG 8.4  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Ответы Re: SPI_ERROR_CONNECT within pl/pgsql, PG 8.4  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Re: SPI_ERROR_CONNECT within pl/pgsql, PG 8.4  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Список pgsql-bugs
I think the attached patch will fix it for you.

            regards, tom lane

Index: src/backend/utils/cache/plancache.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/cache/plancache.c,v
retrieving revision 1.27
diff -c -r1.27 plancache.c
*** src/backend/utils/cache/plancache.c    11 Jun 2009 14:49:05 -0000    1.27
--- src/backend/utils/cache/plancache.c    14 Jul 2009 15:04:38 -0000
***************
*** 45,50 ****
--- 45,51 ----
  #include "access/transam.h"
  #include "catalog/namespace.h"
  #include "executor/executor.h"
+ #include "executor/spi.h"
  #include "nodes/nodeFuncs.h"
  #include "optimizer/planmain.h"
  #include "storage/lmgr.h"
***************
*** 502,509 ****
--- 503,521 ----
          {
              /*
               * Generate plans for queries.
+              *
+              * The planner may try to call SPI-using functions, which causes
+              * a problem if we're already inside one.  Rather than expect
+              * all SPI-using code to do SPI_push whenever a replan could
+              * happen, it seems best to take care of the case here.
               */
+             bool    pushed;
+
+             pushed = SPI_push_conditional();
+
              slist = pg_plan_queries(slist, plansource->cursor_options, NULL);
+
+             SPI_pop_conditional(pushed);
          }

          /*

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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: BUG #4919: CREATE USER command slows down system performance
Следующее
От: Frank van Vugt
Дата:
Сообщение: Re: SPI_ERROR_CONNECT within pl/pgsql, PG 8.4