Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2789b72

Browse files
committed
Volatile-qualify a dozen variables in plpython.c to eliminate warnings
from old versions of gcc. It's not clear to me that this is really necessary for correctness, but less warnings are always good. Per buildfarm results and local testing.
1 parent 39f06dc commit 2789b72

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

src/pl/plpython/plpython.c

+28-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plpython.c - python as a procedural language for PostgreSQL
33
*
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 $
55
*
66
*********************************************************************
77
*/
@@ -1714,7 +1714,7 @@ PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
17141714
HeapTuple tuple;
17151715
Datum *values;
17161716
char *nulls;
1717-
int i;
1717+
volatile int i;
17181718

17191719
Assert(PyMapping_Check(mapping));
17201720

@@ -1729,8 +1729,8 @@ PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
17291729
for (i = 0; i < desc->natts; ++i)
17301730
{
17311731
char *key;
1732-
PyObject *value,
1733-
*so;
1732+
PyObject * volatile value,
1733+
* volatile so;
17341734

17351735
key = NameStr(desc->attrs[i]->attname);
17361736
value = so = NULL;
@@ -1794,7 +1794,7 @@ PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
17941794
HeapTuple tuple;
17951795
Datum *values;
17961796
char *nulls;
1797-
int i;
1797+
volatile int i;
17981798

17991799
Assert(PySequence_Check(sequence));
18001800

@@ -1818,8 +1818,8 @@ PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
18181818
nulls = palloc(sizeof(char) * desc->natts);
18191819
for (i = 0; i < desc->natts; ++i)
18201820
{
1821-
PyObject *value,
1822-
*so;
1821+
PyObject * volatile value,
1822+
* volatile so;
18231823

18241824
value = so = NULL;
18251825
PG_TRY();
@@ -1876,7 +1876,7 @@ PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
18761876
HeapTuple tuple;
18771877
Datum *values;
18781878
char *nulls;
1879-
int i;
1879+
volatile int i;
18801880

18811881
desc = lookup_rowtype_tupdesc(info->out.d.typoid, -1);
18821882
if (info->is_rowtype == 2)
@@ -1889,8 +1889,8 @@ PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
18891889
for (i = 0; i < desc->natts; ++i)
18901890
{
18911891
char *key;
1892-
PyObject *value,
1893-
*so;
1892+
PyObject * volatile value,
1893+
* volatile so;
18941894

18951895
key = NameStr(desc->attrs[i]->attname);
18961896
value = so = NULL;
@@ -2473,13 +2473,14 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
24732473
PG_TRY();
24742474
{
24752475
char *nulls = palloc(nargs * sizeof(char));
2476+
volatile int j;
24762477

2477-
for (i = 0; i < nargs; i++)
2478+
for (j = 0; j < nargs; j++)
24782479
{
24792480
PyObject *elem,
24802481
*so;
24812482

2482-
elem = PySequence_GetItem(list, i);
2483+
elem = PySequence_GetItem(list, j);
24832484
if (elem != Py_None)
24842485
{
24852486
so = PyObject_Str(elem);
@@ -2492,10 +2493,10 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
24922493
{
24932494
char *sv = PyString_AsString(so);
24942495

2495-
plan->values[i] =
2496-
InputFunctionCall(&(plan->args[i].out.d.typfunc),
2496+
plan->values[j] =
2497+
InputFunctionCall(&(plan->args[j].out.d.typfunc),
24972498
sv,
2498-
plan->args[i].out.d.typioparam,
2499+
plan->args[j].out.d.typioparam,
24992500
-1);
25002501
}
25012502
PG_CATCH();
@@ -2506,17 +2507,17 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
25062507
PG_END_TRY();
25072508

25082509
Py_DECREF(so);
2509-
nulls[i] = ' ';
2510+
nulls[j] = ' ';
25102511
}
25112512
else
25122513
{
25132514
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),
25162517
NULL,
2517-
plan->args[i].out.d.typioparam,
2518+
plan->args[j].out.d.typioparam,
25182519
-1);
2519-
nulls[i] = 'n';
2520+
nulls[j] = 'n';
25202521
}
25212522
}
25222523

@@ -2527,20 +2528,22 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
25272528
}
25282529
PG_CATCH();
25292530
{
2531+
int k;
2532+
25302533
MemoryContextSwitchTo(oldcontext);
25312534
PLy_error_in_progress = CopyErrorData();
25322535
FlushErrorState();
25332536

25342537
/*
25352538
* cleanup plan->values array
25362539
*/
2537-
for (i = 0; i < nargs; i++)
2540+
for (k = 0; k < nargs; k++)
25382541
{
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)))
25412544
{
2542-
pfree(DatumGetPointer(plan->values[i]));
2543-
plan->values[i] = PointerGetDatum(NULL);
2545+
pfree(DatumGetPointer(plan->values[k]));
2546+
plan->values[k] = PointerGetDatum(NULL);
25442547
}
25452548
}
25462549

0 commit comments

Comments
 (0)