*** pgsql/src/backend/utils/cache/plancache.c 2009/06/11 14:49:05 1.27 --- pgsql/src/backend/utils/cache/plancache.c 2009/07/14 15:37:55 1.27.2.1 *************** *** 35,41 **** * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.26 2009/01/01 17:23:50 momjian Exp $ * *------------------------------------------------------------------------- */ --- 35,41 ---- * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.27 2009/06/11 14:49:05 momjian Exp $ * *------------------------------------------------------------------------- */ *************** *** 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" *************** RevalidateCachedPlan(CachedPlanSource *p *** 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); } /*