Re: Oddity with NOT IN

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Oddity with NOT IN
Date: 2016-08-06 18:09:52
Message-ID: 87k2ftdb3e.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Andrew" == Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:

Andrew> The easy to catch case, I think, is when the targetlist of the
Andrew> IN or NOT IN subquery contains vars of the outer query level
Andrew> but no vars of the inner one and no volatile functions. This
Andrew> can be checked for with a handful of lines in the parser or a
Andrew> couple of dozen lines in a plugin module (though one would have
Andrew> to invent an error code, none of the existing WARNING sqlstates
Andrew> would do).

Actually thinking about this, if you did it in a module, you'd probably
want to make it an ERROR not a WARNING, because you'd want to actually
stop queries like

delete from t1 where x in (select x from table_with_no_column_x);

rather than let them run.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2016-08-06 18:13:04 Re: Oddity with NOT IN
Previous Message Pavel Stehule 2016-08-06 18:08:04 Re: Oddity with NOT IN