From 2206b498d8240447a9353ce4e994ba41a8e307ac Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 22 Apr 2006 01:26:01 +0000 Subject: 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. --- src/backend/tcop/postgres.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 3c24fa532a6..04e432594e3 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -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 -- cgit v1.2.3