diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-17 18:40:11 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-17 18:40:11 +0000 |
commit | 5f2b17e617f53edceb0b3c7a19542850316b9908 (patch) | |
tree | a5fd35d4d72c99733660ea4ec84df2e01c30a3bf /src | |
parent | 64b9dfa56f26190d7fce953789db28626f0be200 (diff) | |
download | postgresql-5f2b17e617f53edceb0b3c7a19542850316b9908.tar.gz postgresql-5f2b17e617f53edceb0b3c7a19542850316b9908.zip |
Back-patch fix for plpython problems with dropped table columns;
per bug report from Arthur Ward, who also tested this patch.
Diffstat (limited to 'src')
-rw-r--r-- | src/pl/plpython/plpython.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index 92e920d182b..5f485aa9e19 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -29,7 +29,7 @@ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.26.2.5 2003/06/11 18:33:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.26.2.6 2003/09/17 18:40:11 tgl Exp $ * ********************************************************************* */ @@ -586,9 +586,6 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata, plkeys = PyDict_Keys(plntup); natts = PyList_Size(plkeys); - if (natts != proc->result.out.r.natts) - elog(ERROR, "plpython: TD[\"new\"] has an incorrect number of keys."); - modattrs = palloc(natts * sizeof(int)); modvalues = palloc(natts * sizeof(Datum)); for (i = 0; i < natts; i++) @@ -622,7 +619,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata, Py_INCREF(plval); - if (plval != Py_None) + if (plval != Py_None && !tupdesc->attrs[atti]->attisdropped) { plstr = PyObject_Str(plval); src = PyString_AsString(plstr); @@ -1363,6 +1360,9 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) HeapTuple typeTup; Form_pg_type typeStruct; + if (desc->attrs[i]->attisdropped) + continue; + datum = ObjectIdGetDatum(desc->attrs[i]->atttypid); typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -1403,6 +1403,9 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) HeapTuple typeTup; Form_pg_type typeStruct; + if (desc->attrs[i]->attisdropped) + continue; + datum = ObjectIdGetDatum(desc->attrs[i]->atttypid); typeTup = SearchSysCache(TYPEOID, datum, 0, 0, 0); if (!HeapTupleIsValid(typeTup)) @@ -1594,6 +1597,9 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc) bool is_null; PyObject *value; + if (desc->attrs[i]->attisdropped) + continue; + key = NameStr(desc->attrs[i]->attname); vattr = heap_getattr(tuple, (i + 1), desc, &is_null); |