Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rnpST-00FQ1e-OW for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Mar 2024 00:42:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rnpSS-0084Gm-CQ for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Mar 2024 00:42:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rnpSS-0084Ge-4L for pgsql-bugs@lists.postgresql.org; Sat, 23 Mar 2024 00:42:00 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rnpSO-005wGT-Be for pgsql-bugs@lists.postgresql.org; Sat, 23 Mar 2024 00:41:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 42N0fqag1218765; Fri, 22 Mar 2024 20:41:52 -0400 From: Tom Lane To: Janne Annala cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: NEW.* and OLD.* inside trigger function don't seem to contain recently added columns In-reply-to: References: Comments: In-reply-to Janne Annala message dated "Fri, 22 Mar 2024 16:59:37 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1218763.1711154512.1@sss.pgh.pa.us> Date: Fri, 22 Mar 2024 20:41:52 -0400 Message-ID: <1218764.1711154512@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Janne Annala 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