diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-11-04 22:26:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-11-04 22:26:08 +0000 |
commit | 9bedd128d6ed83798004b3c7ddc33f33703ccf23 (patch) | |
tree | 95a475a5da180f19c69b5bcf2f6e764b1bc69ea7 /src/include/utils/plancache.h | |
parent | 48912acc089a6148529f12ab0a75b1bf026f231d (diff) | |
download | postgresql-9bedd128d6ed83798004b3c7ddc33f33703ccf23.tar.gz |
Add support for invoking parser callback hooks via SPI and in cached plans.
As proof of concept, modify plpgsql to use the hooks. plpgsql is still
inserting $n symbols textually, but the "back end" of the parsing process now
goes through the ParamRef hook instead of using a fixed parameter-type array,
and then execution only fetches actually-referenced parameters, using a hook
added to ParamListInfo.
Although there's a lot left to be done in plpgsql, this already cures the
"if (TG_OP = 'INSERT' and NEW.foo ...)" problem, as illustrated by the
changed regression test.
Diffstat (limited to 'src/include/utils/plancache.h')
-rw-r--r-- | src/include/utils/plancache.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h index ea919bd456..68e3f72b19 100644 --- a/src/include/utils/plancache.h +++ b/src/include/utils/plancache.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.15 2009/01/01 17:24:02 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.16 2009/11/04 22:26:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -16,6 +16,7 @@ #define PLANCACHE_H #include "access/tupdesc.h" +#include "nodes/params.h" /* * CachedPlanSource represents the portion of a cached plan that persists @@ -50,6 +51,8 @@ typedef struct CachedPlanSource const char *commandTag; /* command tag (a constant!), or NULL */ Oid *param_types; /* array of parameter type OIDs, or NULL */ int num_params; /* length of param_types array */ + ParserSetupHook parserSetup; /* alternative parameter spec method */ + void *parserSetupArg; int cursor_options; /* cursor options used for planning */ bool fully_planned; /* do we cache planner or rewriter output? */ bool fixed_result; /* disallow change in result tupdesc? */ @@ -105,6 +108,9 @@ extern CachedPlanSource *FastCreateCachedPlan(Node *raw_parse_tree, bool fully_planned, bool fixed_result, MemoryContext context); +extern void CachedPlanSetParserHook(CachedPlanSource *plansource, + ParserSetupHook parserSetup, + void *parserSetupArg); extern void DropCachedPlan(CachedPlanSource *plansource); extern CachedPlan *RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner); |