Re: Wrong result for whole-row IS NOT NULL with dropped columns

From: João Rito <joaovictor(dot)rito(at)gmail(dot)com>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: Sho Ito <i(dot)sho(dot)0628(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Wrong result for whole-row IS NOT NULL with dropped columns
Date: 2026-11-11 22:28:44
Message-ID: CADMs5OP14N_m9-S3qSTVTfsRqrfcriJVgJms6Z=LHPdpFGStXQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Matheus,

Thanks for v2 and for the back-branch patches.

I read the patches. v2 covers the points I raised:
- The WHERE case is now in generated_virtual.sql (gtest20e), with the
EXPLAIN of the Filter and the count(*) result, plus the CHECK
constraint case.
- The ALTER TYPE ... DROP ATTRIBUTE case and the stored view case are
in rowtypes.sql, with the EXPLAIN output showing "(x IS NOT NULL) AND
(z IS NOT NULL)".
- The back-branch patches match what you describe: REL_18 without
expr_is_nonnullable(), REL_17 and older with TupleDescAttr() and only
the rowtypes.sql tests, and REL_14 with regular tables instead of temp
tables.

I also tested them:
- v2 applies to current master (8d87367b39e), and make check passes
(all 243 tests).
- With the v2 tests but the old clauses.c, generated_virtual and
rowtypes fail (2 of 243), so the new tests catch the bug.
- The WHERE case from the report (count(*) ... WHERE t IS NOT NULL)
returns 0 on master and 2 with v2.
- The back-branch patches apply and make check passes on REL_18_STABLE
(235 tests), REL_17_STABLE (229) and REL_14_STABLE (220). I did not
test REL_15 and REL_16.

I have no remaining concerns about the code. One small optional idea:
the view test only checks the view that has the IS NOT NULL inside it.
It could also check a view that stores only the ROW(...)::type and
applies IS NOT NULL outside it, but I think the current test is
enough.

Thanks,
João

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-11-11 22:40:09 Re: Add a hook for handling logical decoding messages on subscribers.
Previous Message Michael Paquier 2026-11-11 22:24:06 Re: BGWORKER_INTERRUPTIBLE workers are never restarted after DROP/ALTER/CREATE DATABASE