aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-07-18 20:26:06 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-07-18 20:26:06 +0000
commita1c692358bb9958b7cb67e4284aae6aa3aabf714 (patch)
tree30e5c80eabbbce990ec44aac20f37ff3d8fd80ca /src/backend/executor
parent6cc88f0af5b12b22ce1826a26b1a953c434bd165 (diff)
downloadpostgresql-a1c692358bb9958b7cb67e4284aae6aa3aabf714.tar.gz
postgresql-a1c692358bb9958b7cb67e4284aae6aa3aabf714.zip
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
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/spi.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 32e53265d97..443ee57e682 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.196 2008/06/01 17:32:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.197 2008/07/18 20:26:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1057,10 +1057,8 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
*/
oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
- /* Copy the plan's query string, if available, into the portal */
- query_string = plansource->query_string;
- if (query_string)
- query_string = pstrdup(query_string);
+ /* Copy the plan's query string into the portal */
+ query_string = pstrdup(plansource->query_string);
/* If the plan has parameters, copy them into the portal */
if (plan->nargs > 0)