From: Tom Lane <tgl@sss.pgh.pa.us>
To: Janne Annala <janne.annala@forenom.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: NEW.* and OLD.* inside trigger function don't seem to contain recently added columns
Date: Fri, 22 Mar 2024 20:41:52 -0400
Message-ID: <1218764.1711154512@sss.pgh.pa.us> (raw)
In-Reply-To: <PA6PR08MB10705C96AC875298000EF44B38A312@PA6PR08MB10705.eurprd08.prod.outlook.com>
References: <PA6PR08MB10705C96AC875298000EF44B38A312@PA6PR08MB10705.eurprd08.prod.outlook.com>
Janne Annala <janne.annala@forenom.com> writes:
> Here's the minimum case to reproduce the issue:
> CREATE FUNCTION x()
> RETURNS trigger
> LANGUAGE plpgsql
> AS $function$
> BEGIN
> IF ROW(NEW.*) IS DISTINCT FROM ROW(OLD.*) THEN
Try dropping the ROW() bit, that is just
IF NEW.* IS DISTINCT FROM OLD.* THEN
or even
IF NEW IS DISTINCT FROM OLD THEN
I think what is happening is that the ROW() notation is getting
expanded at parse time to
ROW(NEW.id, NEW.old_column, NEW.updated)
and then there's no dependency on the original rowtype that would
lead to that expansion getting reconsidered. Arguably that's a
bug, but it's not clear to me what the consequences of changing
that behavior would be.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, janne.annala@forenom.com, pgsql-bugs@lists.postgresql.org
Subject: Re: NEW.* and OLD.* inside trigger function don't seem to contain recently added columns
In-Reply-To: <1218764.1711154512@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox