diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-04-22 01:26:01 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-04-22 01:26:01 +0000 |
commit | 2206b498d8240447a9353ce4e994ba41a8e307ac (patch) | |
tree | eb60585d0dae556ae45aae35a7d50f83be715ab4 /src/backend/tcop/postgres.c | |
parent | 0606860a20511c41d5c9074831e6328547722537 (diff) | |
download | postgresql-2206b498d8240447a9353ce4e994ba41a8e307ac.tar.gz postgresql-2206b498d8240447a9353ce4e994ba41a8e307ac.zip |
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.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 28 |
1 files changed, 15 insertions, 13 deletions
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 |