mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Make use of plancache module for SPI plans. In particular, since plpgsql
uses SPI plans, this finally fixes the ancient gotcha that you can't drop and recreate a temp table used by a plpgsql function. Along the way, clean up SPI's API a little bit by declaring SPI plan pointers as "SPIPlanPtr" instead of "void *". This is cosmetic but helps to forestall simple programming mistakes. (I have changed some but not all of the callers to match; there are still some "void *"'s in contrib and the PL's. This is intentional so that we can see if anyone's compiler complains about it.)
This commit is contained in:
@ -19,7 +19,7 @@ typedef struct
|
||||
{
|
||||
char *ident;
|
||||
int nplans;
|
||||
void **splan;
|
||||
SPIPlanPtr *splan;
|
||||
} EPlan;
|
||||
|
||||
static EPlan *FPlans = NULL;
|
||||
@ -163,7 +163,7 @@ check_primary_key(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
if (plan->nplans <= 0)
|
||||
{
|
||||
void *pplan;
|
||||
SPIPlanPtr pplan;
|
||||
char sql[8192];
|
||||
|
||||
/*
|
||||
@ -191,7 +191,7 @@ check_primary_key(PG_FUNCTION_ARGS)
|
||||
if (pplan == NULL)
|
||||
/* internal error */
|
||||
elog(ERROR, "check_primary_key: SPI_saveplan returned %d", SPI_result);
|
||||
plan->splan = (void **) malloc(sizeof(void *));
|
||||
plan->splan = (SPIPlanPtr *) malloc(sizeof(SPIPlanPtr));
|
||||
*(plan->splan) = pplan;
|
||||
plan->nplans = 1;
|
||||
}
|
||||
@ -413,11 +413,11 @@ check_foreign_key(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
if (plan->nplans <= 0)
|
||||
{
|
||||
void *pplan;
|
||||
SPIPlanPtr pplan;
|
||||
char sql[8192];
|
||||
char **args2 = args;
|
||||
|
||||
plan->splan = (void **) malloc(nrefs * sizeof(void *));
|
||||
plan->splan = (SPIPlanPtr *) malloc(nrefs * sizeof(SPIPlanPtr));
|
||||
|
||||
for (r = 0; r < nrefs; r++)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ Datum get_timetravel(PG_FUNCTION_ARGS);
|
||||
typedef struct
|
||||
{
|
||||
char *ident;
|
||||
void *splan;
|
||||
SPIPlanPtr splan;
|
||||
} EPlan;
|
||||
|
||||
static EPlan *Plans = NULL; /* for UPDATE/DELETE */
|
||||
@ -308,7 +308,7 @@ timetravel(PG_FUNCTION_ARGS)
|
||||
/* if there is no plan ... */
|
||||
if (plan->splan == NULL)
|
||||
{
|
||||
void *pplan;
|
||||
SPIPlanPtr pplan;
|
||||
Oid *ctypes;
|
||||
char sql[8192];
|
||||
char separ = ' ';
|
||||
|
Reference in New Issue
Block a user