Re: why does plperl cache functions using just a bool for is_trigger

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jan Urbański <wulczer@wulczer.org>
Cc: Postgres - Hackers <pgsql-hackers@postgresql.org>
Date: 2010-10-24T22:44:47Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Remove unnecessary use of trigger flag to hash plperl functions

=?UTF-8?B?SmFuIFVyYmHFhHNraQ==?= <wulczer@wulczer.org> writes:
> I see that plperl uses a triple of (function oid, is_trigger flag, user
> id) as a hash key for caching compiled functions. OTOH pltcl and plpgsql
> both use (oid, trigger relation oid, user id). Is there any reason why
> just using a bool as plperl does would be wrong?

plpgsql needs to consider the trigger relation OID because datatypes of
the trigger relation's columns will make their way into cached plans
for the function.  The same function, if applied as a trigger on two
different rels, could therefore have different cached plans so it needs
two separate cache entries.

In PLs where this kind of dependency isn't possible, there's no need for
separate function cache entries.

I'm not certain that plperl is actually correct to do it that way,
but that's the basic idea.

			regards, tom lane