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

From: Tanes Sriviroolchai <tanes(at)siamscan(dot)net>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: 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-20 13:49:17
Message-ID: CABH81w6Yxt1YK15QgWDYt2L5AAKR1BqPKZ0j6_=EHdbWu8CMmw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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');

On Nov 20, 2017 20:09, "Michael Paquier" <michael(dot)paquier(at)gmail(dot)com> wrote:

On Mon, Nov 20, 2017 at 4:26 PM, <tanes(at)siamscan(dot)net> wrote:
> Not sure if this is a bug or feature but when I query with sub select
while
> sub select has invalid column the query is still valid and running. For
> example:
>
> create temp table a ( id integer, descr text);
> create temp table b ( b_id integer, descr text);
>
> # select * from a where id=(select id from b where descr='A');
>
> id | descr
> ----+-------
> (0 rows)
>
> # select id from b where descr='A';
>
> ERROR: column "id" does not exist
> LINE 1: select id from b where descr='A';
> ^

There is no bug here. The subquery should look at the column b_id
which is defined for relation b, so the error is normal.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marko Tiikkaja 2017-11-20 14:16:20 Re: BUG #14919: Invalid column in sub select is still a valid select
Previous Message Michael Paquier 2017-11-20 13:09:28 Re: BUG #14919: Invalid column in sub select is still a valid select