Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2 - Mailing list pgsql-bugs

From Tomas Vondra
Subject Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2
Date
Msg-id f485c85f-9796-467e-81fe-43e8127cbb35@vondra.me
Whole thread Raw
In response to BUG #18885: ERROR: corrupt MVNDistinct entry - 2  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2
List pgsql-bugs
On 4/9/25 15:46, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      18885
> Logged by:          Robins Tharakan
> Email address:      tharakan@gmail.com
> PostgreSQL version: Unsupported/Unknown
> Operating system:   Ubuntu
> Description:        
> 
> The following SQL triggers "ERROR: corrupt MVNDistinct entry", however this
> seems to be unrelated to a recent bugfix[1] for a similar issue (thus '2' in
> the $SUBJECT).
> 
> The surfacing commit appears to be 6bb6a62f3cc45624c601d5270673a17447734629
> [2].
> 

Thanks for the report. I only looked at this very briefly, but I agree
this seems to be a bug in 6bb6a62f3cc45624c601d5270673a17447734629,
because it simply ignores the possibility that multiple join clauses
could share the same Var. Which is the case in the reproducer, where the
join clause is simply

    ... ON (e.d=f.d) AND (e.d=f.d);

Which then leads to confusion when matching the MVDistinct entries.

I think estimate_multivariate_bucketsize() needs to be more careful
about building the GroupVarInfo list - in particular, it needs to do the
dance with examine_variable + add_unique_group_var + pull_var_clause,
similar to estimate_num_groups() at line ~3532.


regards

-- 
Tomas Vondra




pgsql-bugs by date:

Previous
From: Carrie Ray
Date:
Subject: Help Please!
Next
From: PG Bug reporting form
Date:
Subject: BUG #18886: identity duplicate key