diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-02 18:31:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-02 18:31:50 +0000 |
commit | 1591fcbec77f6544a0f665758bae912c68e6fa42 (patch) | |
tree | 164febe5a5dac789fc6194235312c15c3ce4e1fe /src/backend/commands/prepare.c | |
parent | ad6bf716baa7c4c1d0c2fbece0344046e3ce1173 (diff) | |
download | postgresql-1591fcbec77f6544a0f665758bae912c68e6fa42.tar.gz postgresql-1591fcbec77f6544a0f665758bae912c68e6fa42.zip |
Revert my bad decision of about a year ago to make PortalDefineQuery
responsible for copying the query string into the new Portal. Such copying
is unnecessary in the common code path through exec_simple_query, and in
this case it can be enormously expensive because the string might contain
a large number of individual commands; we were copying the entire, long
string for each command, resulting in O(N^2) behavior for N commands.
(This is the cause of bug #4079.) A second problem with it is that
PortalDefineQuery really can't risk error, because if it elog's before
having set up the Portal, we will leak the plancache refcount that the
caller is trying to hand off to the portal. So go back to the design in
which the caller is responsible for making sure everything is copied into
the portal if necessary.
Diffstat (limited to 'src/backend/commands/prepare.c')
-rw-r--r-- | src/backend/commands/prepare.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 681647fac56..575dad9fb3f 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -10,7 +10,7 @@ * Copyright (c) 2002-2008, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.84 2008/03/26 18:48:59 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.85 2008/04/02 18:31:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -250,9 +250,13 @@ ExecuteQuery(ExecuteStmt *stmt, const char *queryString, plan_list = cplan->stmt_list; } + /* + * Note: we don't bother to copy the source query string into the portal. + * Any errors it might be useful for will already have been reported. + */ PortalDefineQuery(portal, NULL, - entry->plansource->query_string, + NULL, entry->plansource->commandTag, plan_list, cplan); |