Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vGUgy-00GO8r-1d for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Nov 2025 04:00:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vGUgu-000CQg-Nq for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Nov 2025 04:00:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vGUgu-000CQX-C0 for pgsql-hackers@lists.postgresql.org; Wed, 05 Nov 2025 04:00:11 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vGUgr-0063E7-03 for pgsql-hackers@lists.postgresql.org; Wed, 05 Nov 2025 04:00:10 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-37a33b06028so32922131fa.2 for ; Tue, 04 Nov 2025 20:00:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762315203; x=1762920003; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=a6qL1QY+6nX9SsTpPAeCTQN2HziObeeAqfL0fNO/+oI=; b=V6DZEYVmLtCYAn7AiZDFhmcsAUyYMPsveVnFrG72Kmy642r/obY75Fk3GDuOE7fROH VlLv2xy5XizqLfwEZ1u+YmGXZkdP8eXkJkyuTgTancnm8WlmelUUeEEOX9OY44piJ/pn 5Q+v8STSOUB8nlttmn2PJDLLCH34JVl+MAOd/uDYmzMCgdpMLWkuZ51bl2HEkNOZaO31 T22Pd90RQyeHdsRh4wvqxtnhnEfkh7n4WgN8S7rcezw/sGS2/8980cgBmHcJNjm1EhSj DZFk0LTAmwo8pWvoMDfVQAAUIQ9dDm1IBzjML+jJdpJECAtr/94oF+JcqhHLWsOM6jBP 2kyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762315203; x=1762920003; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=a6qL1QY+6nX9SsTpPAeCTQN2HziObeeAqfL0fNO/+oI=; b=w26bCAis6V+iUHlpraz4UtONeh6b3JRxNvDiwUUJmf6tblpqpCcl8diHEJIgWBL2Rd wOGr1Yg5M5pwF4zxynYLUygSkH+eyHmc3lJ5nKowyf81yuJVFGuyNYIcg5SMovci6JTy 5QAvhF+tRFvxjXl+se59uD38P1jznp95LATnCLt4XtqAA+cl0tNTUu4w/6BoNj/Te0XE wtYnwjwucLPb9NxrN9A/SwFyLhreDQ5WSrEfiqkocWI3+huuEbsk0CeEltXJ/it6tYHs WKA7j7Wv+vMjZ2cSkSBmrV63xerhjYwConIUclbFaVk7OXSNi1xXv5VpZ2MoQVZ3YI9s 7RJQ== X-Forwarded-Encrypted: i=1; AJvYcCV5eZdFjkb8IbQXq/KH4DfBPi+uBfrxgXnBH94lsJEoPZ8n2R8TaIzIweoBQNBRlHLA3sLPH/Ex2vST95JE@lists.postgresql.org X-Gm-Message-State: AOJu0YyuOtvRRjLEP5f66qKRcwsS0wZOXyzIVjF7N/zsDJNtb8fPB7XO FZs8ibXTIRNRxlLmWdzAM0uuyiTEdzMQ/0/vAKIGTQiNhmubweTIjkk/ X-Gm-Gg: ASbGnctsG8GoplBpmd4zPbQ3lkfk7pWkNpxTwkh+T2y8ISi3sinAn9tnkpKws248kAd dy8WCyKCJtF6vQdbrXgogrU90rLuWOOj7yd/fWVnTWEinFdwdNRNInjBQVV/JQuHLPCj0yOF2Yo QaiZlxd3+AEdDjHfWj6zOInBpy0fG3trhxEG/kQM6YQY4selGPFFN2wJxXff0Tle664RPIzqSjM 7H5W5MYTaK6VVpK1jM3GuSSM+pcztzX0TG5+0ZwchVsT8QUmsLUkN6rpRAtmXIfSGxG/0VJgaMR J4oAqma90c70NmtAYvPDZrca+4822vkOWy/Zr1xbcLb/T65mG9AfKAk9nXyXwtexU9f2NqyMAWG xK3GbghF4eOO3kVvcUNNXuSdVTIK/CxuZfPIv81dJU6Bd6TvRznBjC2cdZeIrBtV1MJpCAq7iCM k9r+I= X-Google-Smtp-Source: AGHT+IFEyfmZRjKofMeBLySUA6tmJhV/bO5nWczLh4x8xXu+OnBPVBABwCsdaUoIL7+8+sPo1DA3ew== X-Received: by 2002:a2e:9051:0:b0:37a:2fa7:53af with SMTP id 38308e7fff4ca-37a514c1821mr3787861fa.40.1762315202493; Tue, 04 Nov 2025 20:00:02 -0800 (PST) Received: from [192.168.0.50] ([89.149.120.198]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-37a415cb69fsm12296531fa.32.2025.11.04.20.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Nov 2025 20:00:01 -0800 (PST) Content-Type: multipart/alternative; boundary="------------mNWZgQ28aC6GNIY0nNrEkjSI" Message-ID: Date: Wed, 5 Nov 2025 06:00:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs To: David Rowley Cc: Tom Lane , PostgreSQL Developers References: <976130.1759375308@sss.pgh.pa.us> <1064547.1759418336@sss.pgh.pa.us> <1196118.1759438964@sss.pgh.pa.us> Content-Language: en-US From: Alexander Lakhin In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------mNWZgQ28aC6GNIY0nNrEkjSI Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello David! 05.11.2025 00:55, David Rowley wrote: > I finally decided that it was a bit too obscure a scenario to test to > verify that the same silly mistake didn't reappear. > > Thanks again for the report and the simple recreation steps. Thank you for the fix! But while playing around, I've just discovered another interesting error: SET enable_seqscan = 'off'; SELECT * FROM t EXCEPT SELECT * FROM t UNION SELECT * FROM pt; leads to: ERROR:  XX000: no relation entry for relid 0 LOCATION:  find_base_rel, relnode.c:541 Best regards, Alexander --------------mNWZgQ28aC6GNIY0nNrEkjSI Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello David!

05.11.2025 00:55, David Rowley wrote:
I finally decided that it was a bit too obscure a scenario to test to
verify that the same silly mistake didn't reappear.

Thanks again for the report and the simple recreation steps.

Thank you for the fix!

But while playing around, I've just discovered another interesting error:

SET enable_seqscan = 'off';
SELECT * FROM t EXCEPT SELECT * FROM t
UNION SELECT * FROM pt;

leads to:
ERROR:  XX000: no relation entry for relid 0
LOCATION:  find_base_rel, relnode.c:541

Best regards,
Alexander

--------------mNWZgQ28aC6GNIY0nNrEkjSI--