Re: Triggers might be caching broken fmgr info

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Triggers might be caching broken fmgr info
Date: 2001-05-16 19:07:13
Message-ID: 19670.990040033@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> My best guess is that the trigger fmgr lookup in trigger.c:846
> if (trigger->tgfunc.fn_oid == InvalidOid)
> fmgr_info(trigger->tgfoid, &trigger->tgfunc);
> might be reading out of an incompletely initialized trigger->tgfunc
> structure.

Yes, that's the problem.

> This is supported by the fact that if I move the
> finfo->fn_oid = functionId;
> assignment in fmgr_info() to the very end of that function, this passes
> gracefully (because the elog comes before the assignment).

I think this is an OK fix, since utils/fmgr/README documents as valid
the technique trigger.c is using:

fn_oid = InvalidOid can be used
to denote a not-yet-initialized FmgrInfo struct.

fmgr_info is clearly failing to live up to the implications of that
commitment. Please move the fn_oid assignment, and insert a note
that it must be last...

> This might even be a workable fix, but I'm wondering whether elog(ERROR)
> should not flush the trigger cache.

The cache in question is part of the relcache, and no we don't want to
flush it on every elog(ERROR).

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-05-16 19:14:07 Re: Followup to IRIX6.5 installation of PG 7.1.1
Previous Message Peter Eisentraut 2001-05-16 18:58:58 pgaccess and pgtksh