On Wed, Nov 3, 2010 at 10:28, Tom Lane <t...@sss.pgh.pa.us> wrote: > OK, applied.
Thanks! > I notice that plpython is also using the trigger relation's OID, but I > don't know that language well enough to tell whether it really needs to. This thread was started by someone working a plpython a validator, I figured the two areas overlap somewhat and did not want to step on any toes. Anyhow the patch is tiny. So toes should remain intact. Find it attached. Given that plpython can only return None/OK", "MODIFY" or "SKIP" and looking around the code for a bit, I don't see any reason it needs it. I only tried plpython3, but it passed an installcheck and some additional testing (two tables with the same column name and different types using the same trigger). [ Aside ] I almost thought using tgreloid was required as PLy_modify_tuple has: plpython.c:748 modvalues[i] = InputFunctionCall(&proc->result.out.r.atts[atti].typfunc, ^^^^^ NULL, proc->result.out.r.atts[atti].typioparam ^^^^^ But Ply_procedure_get has this bit which gets run every time the function is called: plpython.c: 1336 /* * Input/output conversion for trigger tuples. Use the result * TypeInfo variable to store the tuple conversion info. We do this * over again on each call to cover the possibility that the * relation's tupdesc changed since the trigger was last called. * PLy_input_tuple_funcs and PLy_output_tuple_funcs are responsible * for not doing repetitive work. */ .... PLy_input_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att); PLy_output_tuple_funcs(&(proc->result), tdata->tg_relation->rd_att); .... I double checked the other pls just for my sanity. They get it right, that is look it up instead of using anything cached in proc_desc.
*** a/src/pl/plpython/plpython.c --- b/src/pl/plpython/plpython.c *************** *** 1298,1304 **** PLy_procedure_get(FunctionCallInfo fcinfo, Oid tgreloid) if (!HeapTupleIsValid(procTup)) elog(ERROR, "cache lookup failed for function %u", fn_oid); ! rv = snprintf(key, sizeof(key), "%u_%u", fn_oid, tgreloid); if (rv >= sizeof(key) || rv < 0) elog(ERROR, "key too long"); --- 1298,1308 ---- if (!HeapTupleIsValid(procTup)) elog(ERROR, "cache lookup failed for function %u", fn_oid); ! if(OidIsValid(tgreloid)) ! rv = snprintf(key, sizeof(key), "%u_trigger", fn_oid); ! else ! rv = snprintf(key, sizeof(key), "%u", fn_oid); ! if (rv >= sizeof(key) || rv < 0) elog(ERROR, "key too long"); *************** *** 1365,1374 **** PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key) if (OidIsValid(tgreloid)) rv = snprintf(procName, sizeof(procName), ! "__plpython_procedure_%s_%u_trigger_%u", NameStr(procStruct->proname), ! HeapTupleGetOid(procTup), ! tgreloid); else rv = snprintf(procName, sizeof(procName), "__plpython_procedure_%s_%u", --- 1369,1377 ---- if (OidIsValid(tgreloid)) rv = snprintf(procName, sizeof(procName), ! "__plpython_procedure_%s_%u_trigger", NameStr(procStruct->proname), ! HeapTupleGetOid(procTup)); else rv = snprintf(procName, sizeof(procName), "__plpython_procedure_%s_%u",
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers