1
1
/**********************************************************************
2
2
* plpython.c - python as a procedural language for PostgreSQL
3
3
*
4
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.101 2007/05/31 15:13:05 petere Exp $
4
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.102 2007/07/13 04:57:59 tgl Exp $
5
5
*
6
6
*********************************************************************
7
7
*/
@@ -1714,7 +1714,7 @@ PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
1714
1714
HeapTuple tuple ;
1715
1715
Datum * values ;
1716
1716
char * nulls ;
1717
- int i ;
1717
+ volatile int i ;
1718
1718
1719
1719
Assert (PyMapping_Check (mapping ));
1720
1720
@@ -1729,8 +1729,8 @@ PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
1729
1729
for (i = 0 ; i < desc -> natts ; ++ i )
1730
1730
{
1731
1731
char * key ;
1732
- PyObject * value ,
1733
- * so ;
1732
+ PyObject * volatile value ,
1733
+ * volatile so ;
1734
1734
1735
1735
key = NameStr (desc -> attrs [i ]-> attname );
1736
1736
value = so = NULL ;
@@ -1794,7 +1794,7 @@ PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
1794
1794
HeapTuple tuple ;
1795
1795
Datum * values ;
1796
1796
char * nulls ;
1797
- int i ;
1797
+ volatile int i ;
1798
1798
1799
1799
Assert (PySequence_Check (sequence ));
1800
1800
@@ -1818,8 +1818,8 @@ PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
1818
1818
nulls = palloc (sizeof (char ) * desc -> natts );
1819
1819
for (i = 0 ; i < desc -> natts ; ++ i )
1820
1820
{
1821
- PyObject * value ,
1822
- * so ;
1821
+ PyObject * volatile value ,
1822
+ * volatile so ;
1823
1823
1824
1824
value = so = NULL ;
1825
1825
PG_TRY ();
@@ -1876,7 +1876,7 @@ PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
1876
1876
HeapTuple tuple ;
1877
1877
Datum * values ;
1878
1878
char * nulls ;
1879
- int i ;
1879
+ volatile int i ;
1880
1880
1881
1881
desc = lookup_rowtype_tupdesc (info -> out .d .typoid , -1 );
1882
1882
if (info -> is_rowtype == 2 )
@@ -1889,8 +1889,8 @@ PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
1889
1889
for (i = 0 ; i < desc -> natts ; ++ i )
1890
1890
{
1891
1891
char * key ;
1892
- PyObject * value ,
1893
- * so ;
1892
+ PyObject * volatile value ,
1893
+ * volatile so ;
1894
1894
1895
1895
key = NameStr (desc -> attrs [i ]-> attname );
1896
1896
value = so = NULL ;
@@ -2473,13 +2473,14 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
2473
2473
PG_TRY ();
2474
2474
{
2475
2475
char * nulls = palloc (nargs * sizeof (char ));
2476
+ volatile int j ;
2476
2477
2477
- for (i = 0 ; i < nargs ; i ++ )
2478
+ for (j = 0 ; j < nargs ; j ++ )
2478
2479
{
2479
2480
PyObject * elem ,
2480
2481
* so ;
2481
2482
2482
- elem = PySequence_GetItem (list , i );
2483
+ elem = PySequence_GetItem (list , j );
2483
2484
if (elem != Py_None )
2484
2485
{
2485
2486
so = PyObject_Str (elem );
@@ -2492,10 +2493,10 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
2492
2493
{
2493
2494
char * sv = PyString_AsString (so );
2494
2495
2495
- plan -> values [i ] =
2496
- InputFunctionCall (& (plan -> args [i ].out .d .typfunc ),
2496
+ plan -> values [j ] =
2497
+ InputFunctionCall (& (plan -> args [j ].out .d .typfunc ),
2497
2498
sv ,
2498
- plan -> args [i ].out .d .typioparam ,
2499
+ plan -> args [j ].out .d .typioparam ,
2499
2500
-1 );
2500
2501
}
2501
2502
PG_CATCH ();
@@ -2506,17 +2507,17 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
2506
2507
PG_END_TRY ();
2507
2508
2508
2509
Py_DECREF (so );
2509
- nulls [i ] = ' ' ;
2510
+ nulls [j ] = ' ' ;
2510
2511
}
2511
2512
else
2512
2513
{
2513
2514
Py_DECREF (elem );
2514
- plan -> values [i ] =
2515
- InputFunctionCall (& (plan -> args [i ].out .d .typfunc ),
2515
+ plan -> values [j ] =
2516
+ InputFunctionCall (& (plan -> args [j ].out .d .typfunc ),
2516
2517
NULL ,
2517
- plan -> args [i ].out .d .typioparam ,
2518
+ plan -> args [j ].out .d .typioparam ,
2518
2519
-1 );
2519
- nulls [i ] = 'n' ;
2520
+ nulls [j ] = 'n' ;
2520
2521
}
2521
2522
}
2522
2523
@@ -2527,20 +2528,22 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
2527
2528
}
2528
2529
PG_CATCH ();
2529
2530
{
2531
+ int k ;
2532
+
2530
2533
MemoryContextSwitchTo (oldcontext );
2531
2534
PLy_error_in_progress = CopyErrorData ();
2532
2535
FlushErrorState ();
2533
2536
2534
2537
/*
2535
2538
* cleanup plan->values array
2536
2539
*/
2537
- for (i = 0 ; i < nargs ; i ++ )
2540
+ for (k = 0 ; k < nargs ; k ++ )
2538
2541
{
2539
- if (!plan -> args [i ].out .d .typbyval &&
2540
- (plan -> values [i ] != PointerGetDatum (NULL )))
2542
+ if (!plan -> args [k ].out .d .typbyval &&
2543
+ (plan -> values [k ] != PointerGetDatum (NULL )))
2541
2544
{
2542
- pfree (DatumGetPointer (plan -> values [i ]));
2543
- plan -> values [i ] = PointerGetDatum (NULL );
2545
+ pfree (DatumGetPointer (plan -> values [k ]));
2546
+ plan -> values [k ] = PointerGetDatum (NULL );
2544
2547
}
2545
2548
}
2546
2549
0 commit comments