Re: BUG #13748: Syntax error not emitted

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: adam(dot)c(dot)scott(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13748: Syntax error not emitted
Date: 2015-10-30 01:22:51
Message-ID: 23596.1446168171@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

adam(dot)c(dot)scott(at)gmail(dot)com writes:
> create table administrators (pk integer, login_pk integer);
> create table logins (pk integer, name character varying(64));
> select * from administrators where login_pk in (select login_pk from
> logins);

> It should say something along the lines of:
> ERROR: column "login_pk" does not exist

Unfortunately not, because that's a perfectly SQL-standard outer reference
in a subquery.

Many people have adopted the habit of always table-qualifying column
references in subqueries to save themselves from this type of mistake.
That is, if you'd done something like

select * from administrators a where a.login_pk in
(select l.login_pk from logins l);

then you would indeed have gotten a complaint about l.login_pk not
being found in the expected table.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message digoal 2015-10-30 01:56:46 BUG #13749: PostgreSQL cann't compress random data?
Previous Message adam.c.scott 2015-10-30 00:39:24 BUG #13748: Syntax error not emitted