Re: plpython (triggers?) and dropped attributes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Arthur Ward" <award(at)dominionsciences(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: plpython (triggers?) and dropped attributes
Date: 2003-09-16 01:15:39
Message-ID: 12351.1063674939@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Arthur Ward" <award(at)dominionsciences(dot)com> writes:
> I have a table with a plpython trigger defined on it in 7.3.4. I've
> dropped a column from that table, and now I cannot get a plpython trigger
> to run at all on that table.

Would you try the attached patch?

regards, tom lane

*** src/pl/plpython/plpython.c.orig Wed Jun 11 14:33:46 2003
--- src/pl/plpython/plpython.c Mon Sep 15 21:12:51 2003
***************
*** 586,594 ****
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++)
--- 586,591 ----
***************
*** 622,628 ****

Py_INCREF(plval);

! if (plval != Py_None)
{
plstr = PyObject_Str(plval);
src = PyString_AsString(plstr);
--- 619,625 ----

Py_INCREF(plval);

! if (plval != Py_None && !tupdesc->attrs[atti]->attisdropped)
{
plstr = PyObject_Str(plval);
src = PyString_AsString(plstr);
***************
*** 1363,1368 ****
--- 1360,1368 ----
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,1408 ****
--- 1403,1411 ----
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))
***************
*** 1593,1598 ****
--- 1596,1604 ----
vdat;
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);

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Theodore Petrosky 2003-09-16 12:36:48 making 7.4 beta2 on Mac OS x
Previous Message Arthur Ward 2003-09-15 22:32:08 plpython (triggers?) and dropped attributes