pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jinhui Lai <jh.lai@qq.com>
To: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #18904: INTERSECT with an impossible where should eliminateboth from the query plan
Date: Tue, 29 Apr 2025 20:13:31 +0800
Message-ID: <tencent_F22C20E3310DEC4D88B1BA086FD1DA5DFF0A@qq.com> (raw)
In-Reply-To: <CAApHDvrH7U=jDci=uyPx_TK8bPo4Xfy41q6LvqS6n-5QNO7_sQ@mail.gmail.com>
References: <18904-c5fea7892f4d26ed@postgresql.org>
	<CAKFQuwYDxYLNEODZhBL=7iR-7gGfrcFCz=AUBaw2=WEYrjMbhA@mail.gmail.com>
	<435085.1745776956@sss.pgh.pa.us>
	<CAApHDvrH7U=jDci=uyPx_TK8bPo4Xfy41q6LvqS6n-5QNO7_sQ@mail.gmail.com>

Dear PostgreSQL Developer,


My point is that this kind of query, which is always logically empty, should not be executed at all. Executing it not only wastes time, but more concerningly, it can lead to incorrect results. I have discovered bugs in MySQL, MariaDB, and TiDB where such queries, which should have returned empty result sets, instead produced incorrect non-empty results due to being actually executed. Since I’ve only recently started working with PostgreSQL in the past two days, I haven’t yet tested whether it exhibits similar bugs. If I do find any such cases, I will provide concrete examples. Therefore, my additional point is that avoiding the execution of such queries can fundamentally eliminate these types of logical bugs at their source.

Best regrerds,
         原始邮件
         
       
发件人:David Rowley <dgrowleyml@gmail.com&gt;
发件时间:2025年4月29日 19:57
收件人:Tom Lane <tgl@sss.pgh.pa.us&gt;
抄送:David G. Johnston <david.g.johnston@gmail.com&gt;, jh.lai@qq.com <jh.lai@qq.com&gt;, pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org&gt;
主题:Re: BUG #18904: INTERSECT with an impossible where should eliminateboth from the query plan



       On&nbsp;Mon,&nbsp;28&nbsp;Apr&nbsp;2025&nbsp;at&nbsp;06:02,&nbsp;Tom&nbsp;Lane&nbsp;<tgl@sss.pgh.pa.us&gt;&nbsp;wrote:
&gt;&nbsp;Anyway,&nbsp;as&nbsp;David&nbsp;said,&nbsp;this&nbsp;is&nbsp;not&nbsp;a&nbsp;bug.&nbsp;&nbsp;If&nbsp;it's&nbsp;something&nbsp;you
&gt;&nbsp;really&nbsp;want&nbsp;to&nbsp;see&nbsp;happen,&nbsp;try&nbsp;writing&nbsp;a&nbsp;patch&nbsp;yourself.

This&nbsp;is&nbsp;already&nbsp;somewhat&nbsp;better&nbsp;in&nbsp;v18&nbsp;thanks&nbsp;to&nbsp;[1].
generate_nonunion_paths()&nbsp;already&nbsp;has&nbsp;some&nbsp;code&nbsp;to&nbsp;put&nbsp;the&nbsp;smallest
child&nbsp;on&nbsp;the&nbsp;left,&nbsp;and&nbsp;the&nbsp;recent&nbsp;changes&nbsp;in&nbsp;nodeSetOp.c&nbsp;means&nbsp;very
little&nbsp;work&nbsp;will&nbsp;be&nbsp;done&nbsp;when&nbsp;the&nbsp;left&nbsp;side&nbsp;is&nbsp;empty.

David

[1]&nbsp;https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=276279295

view thread (7+ messages)  latest in thread

Message-ID: <tencent_F22C20E3310DEC4D88B1BA086FD1DA5DFF0A@qq.com>
Permalink:  ../tencent_F22C20E3310DEC4D88B1BA086FD1DA5DFF0A@qq.com/
Also on:    postgresql.org/message-id/tencent_F22C20E3310DEC4D88B1BA086FD1DA5DFF0A@qq.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-bugs@postgresql.org
  Cc: jh.lai@qq.com, dgrowleyml@gmail.com, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18904: INTERSECT with an impossible where should eliminateboth from the query plan
  In-Reply-To: <tencent_F22C20E3310DEC4D88B1BA086FD1DA5DFF0A@qq.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