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.96) (envelope-from ) id 1wEkDO-004M0C-2j for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 08:42:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEkDN-001c1O-26 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 08:42:45 +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.96) (envelope-from ) id 1wEkDN-001c1F-19 for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 08:42:45 +0000 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wEkDL-00000001tf5-1Zb2 for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 08:42:44 +0000 Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-8a068db9989so34966596d6.0 for ; Mon, 20 Apr 2026 01:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776674563; cv=none; d=google.com; s=arc-20240605; b=Caj1WwZA3rvyiqtjAfwWctZrsBo8/oRFbHkQ13Uu6qzM+5CEuQ4AL/of9tRrxPR817 +5YrWj336Qgnh1YgQpn5EkV0UZ182je5L+x4NnlD6f9vq/bOhvyoEuWLsUulhyVmq2UB r7LaqqMhTzPaTBJiuGB1lvdMI/cvJ3ysbELOr+CLkSADHGTTQVw3TeHRWKHTQiG/LxH6 YbT7hSPix1wfilf47xohqJxcgw9UaAn2Z5FcYT02NEFhKF7BFb6wlLG2yrLDZXl/w8Ad b/uhLqO7pVtbCOEiCm+L89a1WptOX+5zzo00vXlHrCJcuHky7vYsf5qphJnlyCOvHLbT ewQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=g6W3P35s3YHChF5QdepkwqKTNmm2RLBT/dvnP79tyus=; fh=8i6imh6BaNFWiRCssEI/A57Chsl+J4pRWQJG+YxupaE=; b=Ho152q3o/0snygipEZn8phYxYipoLwyji8yth9C8k5IhcyvnQYKNTCytV4q1eyIPcJ dKa8rBUzW/ozftQzxl51P2A90E9CQJ+LqPiixpuNGqNS+160l4uOWKBbBg9ASysDw/Il kHWFv4S3Y9QqVJpfy/xJRno+E2sEXJwPoANrU4mHr4ZoF5bDPvnRgBJDpO9Z5oqnvoT7 X5L6CQ+lZK365D8FLDJk3aCjmgenxq52cDLUxXfsfWVyLzu0/ou3zMIwmVXNs2En2Pj/ OAr2siEeIiWFpq4IWfooG9ha2t5RMbeouNOkeypYD87z4Yx6xoYB2VqWr0VE4EjNQPrT 8iJw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776674563; x=1777279363; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=g6W3P35s3YHChF5QdepkwqKTNmm2RLBT/dvnP79tyus=; b=L5yxhekz7WozVMcdyRhGPQBEJBZJgB1GfZpQElykvmxTflOErLFmi7bpv6vRkdobEH T2bEEOWB7Qdk0O5vUA+xZNnJ7Yo3XL2OKy5y/f/ia3tSGsNveo9e158SX+C+koDqMLJH coYG5obgWnMNxkSImQGfTUYop66QqonXrtozg3EtuQxbanhpIZbLScbHvhzQf6Ez8Kfq qHSdciW1w64tLnqVv5ktdZPKRjcBKV7fY9tgjvFHljUSOE3BgKmrSs4DjEueuEHnVIAL SFBGNh/cbHFtqr5YhhB/hIfbu2HGJt2PwLyxoCgajBD81twmiiFXu+e5gyt5v6v884ZM OoIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776674563; x=1777279363; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=g6W3P35s3YHChF5QdepkwqKTNmm2RLBT/dvnP79tyus=; b=mqtcPltatWBB+HF3LhaNUWjG4ng/UiRr30Fgy71n2vkwZreaiwInl1hN7CFSEGMD7K 7D9uMElGLIpAevCXLx+Egjq2Oz6xGzRQKm3Vm9c0O4atkzzX/QMZl9LELLmfVz/Y1hQ/ s4d5SWGLmz1/IB111etDeP65efrPhQsVKKneqxfQFGsJglwswoh3vA9SxWQpSGTnYncj 6rDAkhbKT8PQzE4l3Aajqug76lSQQyrhaK8aB+q8CK2s2KDTUFshx8txY3v7kW4hVBJy myKiDLHYOlWhhnCxau0gmUYss3v4+DVuck37n9I8WJ+PHq/aNY8T9xXCl5VBjwVYGwqZ dMJQ== X-Forwarded-Encrypted: i=1; AFNElJ8blAOMUmGVsOARrsrUEeGKiyV/xmorjuuDIm8h+mlldMiB70Kqu8CBhtGaRpodRIkfypcKaanoezlqmgGD@lists.postgresql.org X-Gm-Message-State: AOJu0YzBflbz/SS54IbhsiaeuD2uUiJ/H8ZuXDRwh4zcwFZ9ZH5W6/hi cr8XZzmIj/6GZYV4TRD9gJxdQfutpaxzrSTtUNfVGgNWflO0no5BkBYKmDKgcljXDsktjgjUSSC cAE0FpZ96RiJ4Nvco4RRigVkJbP9S8UE= X-Gm-Gg: AeBDietnb6gQAcId+tSzdm+/wfu99ESfz4R/u4GNdO/VhwqvkpPnf0HdZ3475sXQ+0K IZ2ZkzltqPcQYqQC/9uFWXScrDAU4e/mP+dirmehAWqScq0Mz6+b20GfZ2SbnhBqAo2T0EH7vIw UZ9FuKiH0Y/X+xl0cB11SijEuUadqMvZ2nGMXmOSDisQZMeBhmpP/c4MfC4vxKOmYqhbyJBoakc ECcwpUELwvLROb4ielcsIBK30xWa5VbsmCTBEzuz+2GfDA+sMIE7qV1DFoKv76sXvAsQppDqPSS PlDSzahS1AhCNR7GGXTAKVUF/YOzl869ijZGHBxLy6yD9WMIKxk/ X-Received: by 2002:a05:6214:76c:b0:8ac:b0d8:65f2 with SMTP id 6a1803df08f44-8b028744091mr182597836d6.19.1776674562820; Mon, 20 Apr 2026 01:42:42 -0700 (PDT) MIME-Version: 1.0 References: <22B4A33A-99F3-46F5-BE0C-426A9E1D9ABA@gmail.com> <8D1CD3EB-BF72-4C73-AF24-D88581AC01BE@gmail.com> In-Reply-To: From: Dean Rasheed Date: Mon, 20 Apr 2026 09:42:31 +0100 X-Gm-Features: AQROBzARhYkAjRIbZzj7iPkVaUFLC0ctKZFozIfbsWdu61C_jkK4B7ZP17J_ZNE Message-ID: Subject: Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value) To: Richard Guo Cc: Chao Li , SATYANARAYANA NARLAPURAM , PostgreSQL Hackers , Peter Eisentraut Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 20 Apr 2026 at 08:29, Richard Guo wrote: > > I noticed a couple of issues after a further look. > > 1. The ReplaceVarsFromTargetList call on "gen_cols" fails to handle > hasSubLinks. This can cause error if targetList contains SubLinks: > > update t set a = (select max(a) from t); > ERROR: replace_rte_variables inserted a SubLink, but has noplace to record it > Doh, yes, careless copy-and-pasting. The updates look good. > 2. The same bug fixed in this patch also exists in rule quals: > > I think we should apply the same fix to CopyAndAddInvertedQual. > Agreed. > Attached v3 fixes them. > LGTM. Regards, Dean