Re: BUG #14919: Invalid column in sub select is still a valid select

From: Tanes Sriviroolchai <tanes(at)siamscan(dot)net>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14919: Invalid column in sub select is still a valid select
Date: 2017-11-21 00:46:10
Message-ID: CABH81w7Z3g6s0syYV5ODFOLn_xwJ3QVvT2zxQknE1hrBCOkEyg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Ok. Got it.

On Nov 20, 2017 21:16, "Marko Tiikkaja" <marko(at)joh(dot)to> wrote:

> On Mon, Nov 20, 2017 at 3:49 PM, Tanes Sriviroolchai <tanes(at)siamscan(dot)net>
> wrote:
>
>> Really? The fact that 1st statement doen't end in exception throwing is
>> ok? (While the same sub select executes with exception throwing.)
>>
>> select * from a where id=(select id from b where descr='A');
>>
>
> Because "b" doesn't have a column called "id", this is the same as:
>
> select * from a where id=(select a.id from b where descr='A');
>
> and that's a valid, though slightly silly, query. In other words, you
> accidentally wrote a correlated subquery. Some people consider it good
> practice to qualify column references with the name of the table when
> there's more than one column in scope. If you had written:
>
> select * from a where id=(select b.id from b where b.descr='A');
>
> you would have noticed that you made a mistake, due to the exception this
> query raises.
>
>
> .m
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message AP 2017-11-21 02:25:43 Re: 10.1: hash index size exploding on vacuum full analyze
Previous Message Peter Geoghegan 2017-11-20 18:17:08 Re: BUG #14917: process hang on create index