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

Поиск
Список
Период
Сортировка
От Tanes Sriviroolchai
Тема Re: BUG #14919: Invalid column in sub select is still a valid select
Дата
Msg-id CABH81w7Z3g6s0syYV5ODFOLn_xwJ3QVvT2zxQknE1hrBCOkEyg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #14919: Invalid column in sub select is still a valid select  (Marko Tiikkaja <marko@joh.to>)
Список pgsql-bugs
Ok. Got it.


On Nov 20, 2017 21:16, "Marko Tiikkaja" <marko@joh.to> wrote:
On Mon, Nov 20, 2017 at 3:49 PM, Tanes Sriviroolchai <tanes@siamscan.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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: BUG #14917: process hang on create index
Следующее
От: AP
Дата:
Сообщение: Re: 10.1: hash index size exploding on vacuum full analyze