Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3396138

Browse files
committed
Check we don't misoptimize a NOT IN where the subquery returns no rows.
Future-proofing against a common mistake in attempts to optimize NOT IN.We don't have such an optimization right now, but attempts to do soare in the works, and some of 'em are buggy. Add a regression test casecovering the point.David RowleyDiscussion:https://postgr.es/m/CAKJS1f90E9agVZryVyUpbHQbjTt5ExqS2Fsodmt5_A7E_cEyVA@mail.gmail.com
1 parent65ce07e commit3396138

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎src/test/regress/expected/subselect.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,19 @@ explain (verbose, costs off)
830830
One-Time Filter: ("*VALUES*".column1 = "*VALUES*".column1)
831831
(8 rows)
832832

833+
--
834+
-- Check we don't misoptimize a NOT IN where the subquery returns no rows.
835+
--
836+
create temp table notinouter (a int);
837+
create temp table notininner (b int not null);
838+
insert into notinouter values (null), (1);
839+
select * from notinouter where a not in (select b from notininner);
840+
a
841+
---
842+
843+
1
844+
(2 rows)
845+
833846
--
834847
-- Check we behave sanely in corner case of empty SELECT list (bug #8648)
835848
--

‎src/test/regress/sql/subselect.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,15 @@ explain (verbose, costs off)
466466
select x, xfrom
467467
(select (select random()where y=y)as xfrom (values(1),(2)) v(y)) ss;
468468

469+
--
470+
-- Check we don't misoptimize a NOT IN where the subquery returns no rows.
471+
--
472+
create temp table notinouter (aint);
473+
create temp table notininner (bintnot null);
474+
insert into notinoutervalues (null), (1);
475+
476+
select*from notinouterwhere a notin (select bfrom notininner);
477+
469478
--
470479
-- Check we behave sanely in corner case of empty SELECT list (bug #8648)
471480
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp