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 1vtNGK-002WC4-0o for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Feb 2026 09:57:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vtNGJ-007R3b-0T for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Feb 2026 09:57:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vtNGI-007R3T-2v for pgsql-bugs@lists.postgresql.org; Fri, 20 Feb 2026 09:57:26 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vtNGG-00000000MVb-0UXg for pgsql-bugs@lists.postgresql.org; Fri, 20 Feb 2026 09:57:26 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-673f0b73dd3so999531eaf.2 for ; Fri, 20 Feb 2026 01:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771581443; cv=none; d=google.com; s=arc-20240605; b=hede33CxZPueEvzFTRr/zTXStbb8n43JJ3EqbF1hv4VKUXnvN9SFHaipfF02YpApmG IJMwodfft00ESqXlnULq1X0b7Cadnsz9CT/Pfyrk+dQTFpzxIiszuf/YF0mz+LkQzB/X 6+I1HhRs0MGKyKwsgnxvuNuxp5rYMqcVfnvKaRu/yYRwtDCiZFFdYK1wJqWxBlofqvTv SH4DwLYUM0Lj65tjxFmNZBZjGHmiSTJvrWzSpkctnn2w+Kyfkrg5fQZCRfmr7GOXVwJp 6rHaHjz5Q+mNA7b3XvuQtgndgNKUkSEv74kEstUrJl1UfRq10lvl4SdHN7X1x9isdBMy EfOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3Sdz/uq3aS46VV3JHdxO3QmEhQTpDvo9tI1Ha51GxiU=; fh=FtATRYe0ULnyYrjPMpFxkK+S0TUCdvEi0EZxeidq4X0=; b=McB+0XxM+47erBMwY87h57BhqCil+KZahyfco6wyzcq/jh/y8ViQObc1hh4r6AFBK/ T3iEJyFEa5G3eitTItrN6MX0cVVkkxHV7x9x9c7oJctyrTbQ4qqTpl4M/h4u7y21NROc 8WmTZQ3/zesxj6X3zDdgkkxwfH9UGD6DRJ1W6lWj5+Enw0QPcisjIvuvCa0DnL7RgnLM yFITdgF0tSDhiSw0EdzfQhFEznSVu2FNq9d3eBL7VH1cvAuSoOusF7WKH/jFYrscnfZO Su4fnF5ipBMuLh7awmNngFojqUEyTHxxdHMORhw1uk0CwKbNKsZynnG9dZW21IS+8KHE rQ2A==; 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=20230601; t=1771581443; x=1772186243; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3Sdz/uq3aS46VV3JHdxO3QmEhQTpDvo9tI1Ha51GxiU=; b=G+3pPnwodlBJ25NsXB2OvA55uomyzWcwFXCbONq2h84n23gkPx7m4jK1JcmEbo+oCd 9R72ImIh1Enzo8sqYiiRzdlDjJyM8uH6XASYIoy/YYbFJ8Hklb0IUCb0oussi3ZQs/I9 8NIFwaaAvgTLpIzxQNS5ZWbyeGWehvg0LtL4a7BUH1PpoLlYJ4nj6zASTD968prFU7L+ y/5R86UnJxv1DJHt+2tWW4e1S9YclatEkuGZNLU023xhrDdMhLnRA3NMlIO1ANSqNNJW 86JMM9JiTe5BZT6HiN+sNBlLfNbZGUX1XKZFxIJfkI2i7I/8KF1qFeffvn8muHjbI9rG b5Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771581443; x=1772186243; h=content-transfer-encoding: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=3Sdz/uq3aS46VV3JHdxO3QmEhQTpDvo9tI1Ha51GxiU=; b=kmqTHP7t/BvsfXwpxYBzTkS+m/2Vk+JyP4Iv41w0JCwPmBVELBo4dOeDpuF9y/U3+X 8i/w7XDwvayV9PEwI4nFMH9jznpV1w0OjfAaOVO0u9gKXdBZfAykmZDLS50Z/jmPKR33 6PiICfcaQzfv2mePchjz3rWGdQL5g2xRi/r5pwbFQnlKY/+ep2dIKSLWH3fqM53eZGTB 4klyI9YjL0VWh48cmFp7JL0x+aoYclAxcOiDtV3/wPIT+MCRHSiwK3xyBDI64zDvIdTU /9C8hbwfM8RH+kXZH8966tfKDBF7d3YrkCvPTXu13FzZdrmBFrUjD0gV17fKwMz8d9oa BO+g== X-Forwarded-Encrypted: i=1; AJvYcCVtPN+exb0gKiZgmfl98/iW7JkdyXbuRaBr2bCwRuqSOHXj6tLCLgKHSL6m4Og6Z6dvYnWlx1uHczcu@lists.postgresql.org X-Gm-Message-State: AOJu0Yyjjf51pgApWZjgbKQcJ4oWbuzFxviwQ73llzvytDbzt9uTxc1j utU3BM5jXOzIa1LDLvteqaLqSOPayVd1K494O9hOPVoWlfpWIQOYoDYhVD095q0K1tR9BoBR0ZZ 5pYvbdsrp8PXng6zkkne/6LQiuMxmrL8= X-Gm-Gg: AZuq6aKFR9Vd1fcf7B+Hvy3XDyRmUrXyJlWys+2m+E7hO62gMFiYZD6jlTH6e7D/asi Yqbk0c0bF6eX/WYCgi0I9kHeLHn4AhU4Gb4AVoAMVXPVOpo+IvZccxqkfUpNULUdbvUdUoXbSvx MzX0wS8Myp8pYuzXJxjOx6GoLDBm/EVjEthxtYdHHn1/WVB80IN5Q9uilqhV8eyftXxMxZnYrI7 aq7VUUovFEDgMQ+J1rh+SUu90t++6uBTkcn3hf7DP4MDhZph+qGi5TWw8DRssAnd56LL/h4/PqL Og3Vd7i5 X-Received: by 2002:a05:6820:f036:b0:679:97d5:dd25 with SMTP id 006d021491bc7-679a7444f11mr4701892eaf.56.1771581442984; Fri, 20 Feb 2026 01:57:22 -0800 (PST) MIME-Version: 1.0 References: <19412-1d0318089b86859e@postgresql.org> <60be6cb1-10de-4e24-82ce-b02650442d97@postgrespro.ru> <2663915.1771525548@sss.pgh.pa.us> In-Reply-To: <2663915.1771525548@sss.pgh.pa.us> From: Richard Guo Date: Fri, 20 Feb 2026 18:57:12 +0900 X-Gm-Features: AaiRm51dXEW9bDw9GcOqBDdnhssR9v6fC62Xq4XmwIBRSvnIkmdDTYcAsdk3JdM Message-ID: Subject: Re: BUG #19412: Wrong query result with not null constraint To: Tom Lane Cc: Sergey Shinderuk , pgsql-bugs@lists.postgresql.org, David Rowley Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Feb 20, 2026 at 3:25=E2=80=AFAM Tom Lane wrote: > I agree with this fix: I think the code is like it is simply because > it didn't occur to me that the child Vars could have any nullingrel > bits yet. However, I don't agree that that comment needs no updates. > I suggest something like > > - * Below, we just propagate var->varnullingrels into the transla= ted > - * Var. > + * Below, we just merge var->varnullingrels into the translated > + * Var. (We must merge not just copy: the child Var could have > + * some nullingrel bits set already, and we mustn't drop those.) > > Also, I think I'd then drop the comment you added adjacent to the > actual update; it seems redundant if the earlier comment says this. Thanks for taking a look. I've updated the comments as suggested, > I agree with back-patching to v16. This particular example doesn't > misbehave in versions that don't have the drop-allegedly-redundant- > NOT-NULL-tests logic, but the varnullingrels are certainly wrong > all the way back, so possibly there are other examples that do > misbehave in v16. ... and then pushed and back-patched to v16. Thank you, Sergey, for the report and the excellent self-contained repro query. This is a great catch. (I'm curious how you found this bug -- was it from a production query or a fuzzing tool?) - Richard