Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Corey Huinker
On Sat, Aug 6, 2016 at 2:13 PM, Jim Nasby wrote: > On 8/6/16 12:57 PM, Andrew Gierth wrote: > >> The easy to catch case, I think, is when the targetlist of the IN or NOT >> IN subquery contains vars of the outer query level but no vars of the >> inner one and no volatile functions. This can be ch

Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Jim Nasby
On 8/6/16 12:57 PM, Andrew Gierth wrote: The easy to catch case, I think, is when the targetlist of the IN or NOT IN subquery contains vars of the outer query level but no vars of the inner one and no volatile functions. This can be checked for with a handful of lines in the parser or a couple of

Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Andrew Gierth
> "Andrew" == Andrew Gierth 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

Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Pavel Stehule
2016-08-06 20:01 GMT+02:00 Jim Nasby : > On 8/6/16 12:03 PM, Pavel Stehule wrote: > >> It would be very useful if we had some way to warn users about stuff >> like this. Emitting a NOTICE comes to mind. >> >> >> This can be valid query >> > > Right, but in my experience it's an extremely u

Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Jim Nasby
On 8/6/16 12:03 PM, Pavel Stehule wrote: It would be very useful if we had some way to warn users about stuff like this. Emitting a NOTICE comes to mind. This can be valid query Right, but in my experience it's an extremely uncommon pattern and much more likely to be a mistake (that

Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Andrew Gierth
> "Pavel" == Pavel Stehule writes: >> Well now I feel dumb... >> >> It would be very useful if we had some way to warn users about stuff >> like this. Emitting a NOTICE comes to mind. Pavel> This can be valid query It can be, but it essentially never is. The cases where you genuinely

Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Pavel Stehule
2016-08-06 18:53 GMT+02:00 Jim Nasby : > On 8/4/16 4:53 PM, Marko Tiikkaja wrote: > >> On 2016-08-04 11:23 PM, Jim Nasby wrote: >> >>> I've got a customer that discovered something odd... >>> >>> SELECT f1 FROM v1 WHERE f2 not in (SELECT bad FROM v2 WHERE f3 = 1); >>> >>> does not error, even thou

Re: [HACKERS] Oddity with NOT IN

2016-08-06 Thread Jim Nasby
On 8/4/16 4:53 PM, Marko Tiikkaja wrote: On 2016-08-04 11:23 PM, Jim Nasby wrote: I've got a customer that discovered something odd... SELECT f1 FROM v1 WHERE f2 not in (SELECT bad FROM v2 WHERE f3 = 1); does not error, even though bad doesn't exist, but I'm guessing there's a v1.bad? This

Re: [HACKERS] Oddity with NOT IN

2016-08-04 Thread Marko Tiikkaja
On 2016-08-04 11:23 PM, Jim Nasby wrote: I've got a customer that discovered something odd... SELECT f1 FROM v1 WHERE f2 not in (SELECT bad FROM v2 WHERE f3 = 1); does not error, even though bad doesn't exist, but I'm guessing there's a v1.bad? This is a common mistake, and also why I recomm

[HACKERS] Oddity with NOT IN

2016-08-04 Thread Jim Nasby
I've got a customer that discovered something odd... SELECT f1 FROM v1 WHERE f2 not in (SELECT bad FROM v2 WHERE f3 = 1); does not error, even though bad doesn't exist, but SELECT bad FROM v2 WHERE f3 = 1; gives ERROR: column "bad" does not exist Is that expected? This is on 9.4.8, and both