Joe Conway wrote:
Given the above changes, it's almost working now -- only problem left is with triggers:


insert into foo values(11,'cat99',1.89); + ERROR: record type has not been registered + CONTEXT: In PL/R function rejectfoo

  delete from foo;
+ ERROR:  cache lookup failed for type 0
+ CONTEXT:  In PL/R function rejectfoo

(and a few other similar failures)

Any ideas why the trigger tuple type isn't registered, or what I'm doing wrong?

A little more info on this. It appears that the tuple type is set to either 2249 (RECORDOID) or 0. In the case of RECORDOID this traces all the way back to here:


/* ----------------------------------------------------------------
 *   CreateTemplateTupleDesc
 *
 *   This function allocates and zeros a tuple descriptor structure.
 *
 *   Tuple type ID information is initially set for an anonymous record
 *   type; caller can overwrite this if needed.
 * ----------------------------------------------------------------
 */

But the type id is never overwritten for a BEFORE INSERT trigger. It appears that somewhere it is explictly set to InvalidOid for both BEFORE DELETE and AFTER INSERT triggers (and possibly others). My take is that we now need to explicitly set the tuple type id for INSERT/UPDATE/DELETE statements -- not sure where the best place to do that is though. Does this sound correct?

Joe


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

http://archives.postgresql.org

Reply via email to