pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
To: Andrei Lepikhov <lepihov@gmail.com>
Cc: Greg Sabino Mullane <htamfids@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Correction of RowMark Removal During Sel-Join Elimination
Date: Sat, 30 Aug 2025 16:00:01 +0300
Message-ID: <9b10b847-067e-45cf-bbf7-7802b6303fc0@gmail.com> (raw)
In-Reply-To: <CAPpHfdsP_abX5hjnxiRJ6guU9P1FH4EdNTMksoGD05tTG1o9vA@mail.gmail.com>
References: <18c6bd6c-6d2a-419a-b0da-dfedef34b585@gmail.com>
	<CAKAnmmJzSGzTRaLATNZPErByO3-j6MwsK--qPSiRLJi4kB05HQ@mail.gmail.com>
	<e7c8173c-91be-41a3-a390-2ca84fbc5147@gmail.com>
	<CAPpHfdsP_abX5hjnxiRJ6guU9P1FH4EdNTMksoGD05tTG1o9vA@mail.gmail.com>

Hello Alexander,

24.08.2025 03:44, Alexander Korotkov wrote:
> Thank you for catching this.  And thank you for the fix.  I think it
> worth separating fix and refactoring.  This helps to understand what
> exactly the fix is by looking at the patch.  I also edited commit
> message.  I'm going to push this if no objections.

Please try the following script:
create table t1(i1 int primary key);
create table t2 (i2 int, check (i2 is not null));

set constraint_exclusion = 'on';

select 1 from t1 right join t2 on i1 = i2 where (select true);

which triggers (starting from 5f6f951f8):
Core was generated by `postgres: law regression [local] SELECT                                       '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000058dd6a7b6014 in var_is_nonnullable (root=0x58dd78d505f8, var=0x58dd78d75610, use_rel_info=false) at clauses.c:4242
4242                    if (rte->inh && rte->relkind != RELKIND_PARTITIONED_TABLE)
(gdb) bt
#0  0x000058dd6a7b6014 in var_is_nonnullable (root=0x58dd78d505f8, var=0x58dd78d75610, use_rel_info=false) at clauses.c:4242
#1  0x000058dd6a7b4f74 in eval_const_expressions_mutator (node=0x58dd78d75590, context=0x7fff875a9f00) at clauses.c:3556
#2  0x000058dd6a7b2935 in eval_const_expressions (root=0x58dd78d505f8, node=0x58dd78d75590) at clauses.c:2272
#3  0x000058dd6a7c857d in get_relation_constraints (root=0x58dd78d505f8, relationObjectId=16385, rel=0x58dd78d738e0, 
include_noinherit=true, include_notnull=true, include_partition=true) at plancat.c:1419
#4  0x000058dd6a7c8fdb in relation_excluded_by_constraints (root=0x58dd78d505f8, rel=0x58dd78d738e0, rte=0x58dd78c6b968) 
at plancat.c:1808
#5  0x000058dd6a73675e in set_rel_size (root=0x58dd78d505f8, rel=0x58dd78d738e0, rti=2, rte=0x58dd78c6b968) at 
allpaths.c:364
#6  0x000058dd6a73664c in set_base_rel_sizes (root=0x58dd78d505f8) at allpaths.c:322
#7  0x000058dd6a73631e in make_one_rel (root=0x58dd78d505f8, joinlist=0x58dd78d74a90) at allpaths.c:183
...

Discovered with SQLsmith.

Best regards,
Alexander

view thread (16+ messages)  latest in thread

Message-ID: <9b10b847-067e-45cf-bbf7-7802b6303fc0@gmail.com>
Permalink:  ../9b10b847-067e-45cf-bbf7-7802b6303fc0@gmail.com/
Also on:    postgresql.org/message-id/9b10b847-067e-45cf-bbf7-7802b6303fc0@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: exclusion@gmail.com, aekorotkov@gmail.com, lepihov@gmail.com, htamfids@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Correction of RowMark Removal During Sel-Join Elimination
  In-Reply-To: <9b10b847-067e-45cf-bbf7-7802b6303fc0@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox