88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.494 2006/08/04 18:53:46 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.495 2006/08/06 02:00:52 momjian Exp $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
@@ -1364,7 +1364,6 @@ exec_bind_message(StringInfo input_message)
13641364int numParams ;
13651365int numRFormats ;
13661366int16 * rformats = NULL ;
1367- int i ;
13681367PreparedStatement * pstmt ;
13691368Portal portal ;
13701369ParamListInfo params ;
@@ -1391,6 +1390,8 @@ exec_bind_message(StringInfo input_message)
13911390numPFormats = pq_getmsgint (input_message ,2 );
13921391if (numPFormats > 0 )
13931392{
1393+ int i ;
1394+
13941395pformats = (int16 * )palloc (numPFormats * sizeof (int16 ));
13951396for (i = 0 ;i < numPFormats ;i ++ )
13961397pformats [i ]= pq_getmsgint (input_message ,2 );
@@ -1463,6 +1464,7 @@ exec_bind_message(StringInfo input_message)
14631464{
14641465ListCell * l ;
14651466MemoryContext oldContext ;
1467+ int paramno ;
14661468
14671469oldContext = MemoryContextSwitchTo (PortalGetHeapMemory (portal ));
14681470
@@ -1471,7 +1473,7 @@ exec_bind_message(StringInfo input_message)
14711473(numParams - 1 )* sizeof (ParamExternData ));
14721474params -> numParams = numParams ;
14731475
1474- i = 0 ;
1476+ paramno = 0 ;
14751477foreach (l ,pstmt -> argtype_list )
14761478{
14771479Oid ptype = lfirst_oid (l );
@@ -1511,7 +1513,7 @@ exec_bind_message(StringInfo input_message)
15111513}
15121514
15131515if (numPFormats > 1 )
1514- pformat = pformats [i ];
1516+ pformat = pformats [paramno ];
15151517else if (numPFormats > 0 )
15161518pformat = pformats [0 ];
15171519else
@@ -1534,7 +1536,7 @@ exec_bind_message(StringInfo input_message)
15341536else
15351537pstring = pg_client_to_server (pbuf .data ,plength );
15361538
1537- params -> params [i ].value = OidInputFunctionCall (typinput ,
1539+ params -> params [paramno ].value = OidInputFunctionCall (typinput ,
15381540pstring ,
15391541typioparam ,
15401542-1 );
@@ -1558,7 +1560,7 @@ exec_bind_message(StringInfo input_message)
15581560else
15591561bufptr = & pbuf ;
15601562
1561- params -> params [i ].value = OidReceiveFunctionCall (typreceive ,
1563+ params -> params [paramno ].value = OidReceiveFunctionCall (typreceive ,
15621564bufptr ,
15631565typioparam ,
15641566-1 );
@@ -1568,7 +1570,7 @@ exec_bind_message(StringInfo input_message)
15681570ereport (ERROR ,
15691571(errcode (ERRCODE_INVALID_BINARY_REPRESENTATION ),
15701572errmsg ("incorrect binary data format in bind parameter %d" ,
1571- i + 1 )));
1573+ paramno + 1 )));
15721574}
15731575else
15741576{
@@ -1582,10 +1584,10 @@ exec_bind_message(StringInfo input_message)
15821584if (!isNull )
15831585pbuf .data [plength ]= csave ;
15841586
1585- params -> params [i ].isnull = isNull ;
1586- params -> params [i ].ptype = ptype ;
1587+ params -> params [paramno ].isnull = isNull ;
1588+ params -> params [paramno ].ptype = ptype ;
15871589
1588- i ++ ;
1590+ paramno ++ ;
15891591}
15901592
15911593MemoryContextSwitchTo (oldContext );
@@ -1597,6 +1599,8 @@ exec_bind_message(StringInfo input_message)
15971599numRFormats = pq_getmsgint (input_message ,2 );
15981600if (numRFormats > 0 )
15991601{
1602+ int i ;
1603+
16001604rformats = (int16 * )palloc (numRFormats * sizeof (int16 ));
16011605for (i = 0 ;i < numRFormats ;i ++ )
16021606rformats [i ]= pq_getmsgint (input_message ,2 );