1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Simplify ParamListInfo data structure to support only numbered parameters,

not named ones, and replace linear searches of the list with array indexing.
The named-parameter support has been dead code for many years anyway,
and recent profiling suggests that the searching was costing a noticeable
amount of performance for complex queries.
This commit is contained in:
Tom Lane
2006-04-22 01:26:01 +00:00
parent 0606860a20
commit 2206b498d8
20 changed files with 214 additions and 335 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.484 2006/04/18 00:52:23 momjian Exp $
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.485 2006/04/22 01:26:00 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@ -1479,8 +1479,10 @@ exec_bind_message(StringInfo input_message)
oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
params = (ParamListInfo)
palloc0((numParams + 1) * sizeof(ParamListInfoData));
/* sizeof(ParamListInfoData) includes the first array element */
params = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
(numParams - 1) * sizeof(ParamExternData));
params->numParams = numParams;
i = 0;
foreach(l, pstmt->argtype_list)
@ -1545,8 +1547,10 @@ exec_bind_message(StringInfo input_message)
else
pstring = pg_client_to_server(pbuf.data, plength);
params[i].value = OidInputFunctionCall(typinput, pstring,
typioparam, -1);
params->params[i].value = OidInputFunctionCall(typinput,
pstring,
typioparam,
-1);
/* Free result of encoding conversion, if any */
if (pstring && pstring != pbuf.data)
pfree(pstring);
@ -1567,8 +1571,10 @@ exec_bind_message(StringInfo input_message)
else
bufptr = &pbuf;
params[i].value = OidReceiveFunctionCall(typreceive, bufptr,
typioparam, -1);
params->params[i].value = OidReceiveFunctionCall(typreceive,
bufptr,
typioparam,
-1);
/* Trouble if it didn't eat the whole buffer */
if (!isNull && pbuf.cursor != pbuf.len)
@ -1589,16 +1595,12 @@ exec_bind_message(StringInfo input_message)
if (!isNull)
pbuf.data[plength] = csave;
params[i].kind = PARAM_NUM;
params[i].id = i + 1;
params[i].ptype = ptype;
params[i].isnull = isNull;
params->params[i].isnull = isNull;
params->params[i].ptype = ptype;
i++;
}
params[i].kind = PARAM_INVALID;
MemoryContextSwitchTo(oldContext);
}
else