"Arthur Ward" <[EMAIL PROTECTED]> 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);

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to