Re: Missing update of all_hasnulls in BRIN opclasses

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-10-22T08:00:36Z
Lists: pgsql-hackers
On 2022-Oct-22, Tomas Vondra wrote:

> I wonder how to do this in a back-patchable way - we can't add
> parameters to the opclass procedure, and the other solution seems to be
> storing it right in the BrinMemTuple, somehow. But that's likely an ABI
> break :-(

Hmm, I don't see the ABI incompatibility.  BrinMemTuple is an in-memory
structure, so you can add new members at the end of the struct and it
will pose no problems to existing code.

> The only solution I can think of is actually passing it using all_nulls
> and has_nulls - we could set both flags to true (which we never do now)
> and teach the opclass that it signifies "empty" (and thus not to update
> has_nulls after resetting all_nulls).
> 
> Something like the attached (I haven't added any more tests, not sure
> what would those look like - I can't think of a query testing this,
> although maybe we could check how the flags change using pageinspect).

I'll try to have a look at these patches tomorrow or on Monday.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"I suspect most samba developers are already technically insane...
Of course, since many of them are Australians, you can't tell." (L. Torvalds)



Commits

  1. Show empty BRIN ranges in brin_page_items

  2. Fix handling of empty ranges and NULLs in BRIN

  3. Fix handling of NULLs when merging BRIN summaries

  4. Move IS [NOT] NULL handling from BRIN support functions