Lists: | pgsql-bugs |
---|
From: | "Arthur Ward" <award(at)dominionsciences(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | plpython (triggers?) and dropped attributes |
Date: | 2003-09-15 22:32:08 |
Message-ID: | 1310.192.168.0.101.1063665128.squirrel@192.168.0.2 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
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. I've dropped both the trigger and function
and recreated them from scratch (not using "create or replace"), and I
still get the following error when I set off the trigger:
ERROR: plpython: Cache lookup for attribute
`........pg.dropped.5........' type `0' failed
The trigger procedure has a plpy.info call as the first statement, and I'm
not seeing that output, thus I believe it's a problem in plpython. I
suppose this is a bug in plpython's trigger handler building up the
TD['new'] and TD['old'] structures. I figured I'd toss this out and see if
somebody familiar with the plpython code can spot the problem faster than
if I start muddling through the code blindly.
Any thoughts?
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 |
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);
From: | "Arthur Ward" <award(at)dominionsciences(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: plpython (triggers?) and dropped attributes |
Date: | 2003-09-17 16:35:26 |
Message-ID: | 8536.68.62.129.152.1063816526.squirrel@award.gotdns.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
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?
Lightly tested, but it seems to be working. Thanks a bunch!