diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/cache/plancache.c | 11 | ||||
-rw-r--r-- | src/backend/utils/mmgr/portalmem.c | 18 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index dbe889cb6ce..fd0433bb379 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -33,7 +33,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.18 2008/05/12 20:02:02 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.19 2008/07/18 20:26:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -104,8 +104,7 @@ InitPlanCache(void) * about all that we do here is copy it into permanent storage. * * raw_parse_tree: output of raw_parser() - * query_string: original query text (can be NULL if not available, but - * that is discouraged because it degrades error message quality) + * query_string: original query text (as of PG 8.4, must not be NULL) * commandTag: compile-time-constant tag for query, or NULL if empty query * param_types: array of parameter type OIDs, or NULL if none * num_params: number of parameters @@ -130,6 +129,8 @@ CreateCachedPlan(Node *raw_parse_tree, MemoryContext source_context; MemoryContext oldcxt; + Assert(query_string != NULL); /* required as of 8.4 */ + /* * Make a dedicated memory context for the CachedPlanSource and its * subsidiary data. We expect it can be pretty small. @@ -152,7 +153,7 @@ CreateCachedPlan(Node *raw_parse_tree, oldcxt = MemoryContextSwitchTo(source_context); plansource = (CachedPlanSource *) palloc(sizeof(CachedPlanSource)); plansource->raw_parse_tree = copyObject(raw_parse_tree); - plansource->query_string = query_string ? pstrdup(query_string) : NULL; + plansource->query_string = pstrdup(query_string); plansource->commandTag = commandTag; /* no copying needed */ if (num_params > 0) { @@ -228,6 +229,8 @@ FastCreateCachedPlan(Node *raw_parse_tree, OverrideSearchPath *search_path; MemoryContext oldcxt; + Assert(query_string != NULL); /* required as of 8.4 */ + /* * Fetch current search_path into given context, but do any recalculation * work required in caller's context. diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 4470961a282..b98b578ed24 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.110 2008/05/12 00:00:52 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.111 2008/07/18 20:26:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -271,7 +271,11 @@ CreateNewPortal(void) * PortalDefineQuery * A simple subroutine to establish a portal's query. * - * Notes: commandTag shall be NULL if and only if the original query string + * Notes: as of PG 8.4, caller MUST supply a sourceText string; it is not + * allowed anymore to pass NULL. (If you really don't have source text, + * you can pass a constant string, perhaps "(query not available)".) + * + * commandTag shall be NULL if and only if the original query string * (before rewriting) was an empty string. Also, the passed commandTag must * be a pointer to a constant string, since it is not copied. * @@ -284,7 +288,7 @@ CreateNewPortal(void) * copying them into the portal's heap context. * * The caller is also responsible for ensuring that the passed prepStmtName - * and sourceText (if not NULL) have adequate lifetime. + * (if not NULL) and sourceText have adequate lifetime. * * NB: this function mustn't do much beyond storing the passed values; in * particular don't do anything that risks elog(ERROR). If that were to @@ -302,7 +306,8 @@ PortalDefineQuery(Portal portal, AssertArg(PortalIsValid(portal)); AssertState(portal->status == PORTAL_NEW); - Assert(commandTag != NULL || stmts == NIL); + AssertArg(sourceText != NULL); + AssertArg(commandTag != NULL || stmts == NIL); portal->prepStmtName = prepStmtName; portal->sourceText = sourceText; @@ -927,10 +932,7 @@ pg_cursor(PG_FUNCTION_ARGS) MemSet(nulls, 0, sizeof(nulls)); values[0] = CStringGetTextDatum(portal->name); - if (!portal->sourceText) - nulls[1] = true; - else - values[1] = CStringGetTextDatum(portal->sourceText); + values[1] = CStringGetTextDatum(portal->sourceText); values[2] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_HOLD); values[3] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_BINARY); values[4] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_SCROLL); |