Skip to content

Commit 972e20b

Browse files
committed
exec_parse_message neglected to copy parameter type array into the
required memory context when handling client-specified parameter types for an unnamed statement. Per report from Kris Jurka.
1 parent 96b1719 commit 972e20b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/backend/tcop/postgres.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.529 2007/03/22 19:55:04 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.530 2007/03/29 19:10:10 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1239,12 +1239,24 @@ exec_parse_message(const char *query_string, /* string to execute */
12391239
}
12401240
else
12411241
{
1242-
/* query_string needs to be copied into unnamed_stmt_context */
1243-
/* the rest is there already */
1242+
/*
1243+
* paramTypes and query_string need to be copied into
1244+
* unnamed_stmt_context. The rest is there already
1245+
*/
1246+
Oid *newParamTypes;
1247+
1248+
if (numParams > 0)
1249+
{
1250+
newParamTypes = (Oid *) palloc(numParams * sizeof(Oid));
1251+
memcpy(newParamTypes, paramTypes, numParams * sizeof(Oid));
1252+
}
1253+
else
1254+
newParamTypes = NULL;
1255+
12441256
unnamed_stmt_psrc = FastCreateCachedPlan(raw_parse_tree,
12451257
pstrdup(query_string),
12461258
commandTag,
1247-
paramTypes,
1259+
newParamTypes,
12481260
numParams,
12491261
stmt_list,
12501262
fully_planned,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy