mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Adjust things so that the query_string of a cached plan and the sourceText of
a portal are never NULL, but reliably provide the source text of the query.
It turns out that there was only one place that was really taking a short-cut,
which was the 'EXECUTE' utility statement. That doesn't seem like a
sufficiently critical performance hotspot to justify not offering a guarantee
of validity of the portal source text. Fix it to copy the source text over
from the cached plan. Add Asserts in the places that set up cached plans and
portals to reject null source strings, and simplify a bunch of places that
formerly needed to guard against nulls.
There may be a few places that cons up statements for execution without
having any source text at all; I found one such in ConvertTriggerToFK().
It seems sufficient to inject a phony source string in such a case,
for instance
ProcessUtility((Node *) atstmt,
"(generated ALTER TABLE ADD FOREIGN KEY command)",
NULL, false, None_Receiver, NULL);
We should take a second look at the usage of debug_query_string,
particularly the recently added current_query() SQL function.
ITAGAKI Takahiro and Tom Lane
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.11 2008/01/01 19:45:59 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.12 2008/07/18 20:26:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,8 +20,7 @@
|
||||
/*
|
||||
* CachedPlanSource represents the portion of a cached plan that persists
|
||||
* across invalidation/replan cycles. It stores a raw parse tree (required),
|
||||
* the original source text (optional, but highly recommended to improve
|
||||
* error reports), and adjunct data.
|
||||
* the original source text (also required, as of 8.4), and adjunct data.
|
||||
*
|
||||
* Normally, both the struct itself and the subsidiary data live in the
|
||||
* context denoted by the context field, while the linked-to CachedPlan, if
|
||||
@@ -47,7 +46,7 @@
|
||||
typedef struct CachedPlanSource
|
||||
{
|
||||
Node *raw_parse_tree; /* output of raw_parser() */
|
||||
char *query_string; /* text of query, or NULL */
|
||||
char *query_string; /* text of query (as of 8.4, never NULL) */
|
||||
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 */
|
||||
|
||||
Reference in New Issue
Block a user