BUG #13748: Syntax error not emitted
The following bug has been logged on the website:
Bug reference: 13748
Logged by: Adam Scott
Email address: adam.c.scott@gmail.com
PostgreSQL version: 9.2.13
Operating system: https://en.wikipedia.org/wiki/Jonas_Salk
Description:
Setup:
create database test;
\c test
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);
pk | login_pk
----+----------
(0 rows)
It should say something along the lines of:
ERROR: column "login_pk" does not exist
LINE 1: select login_pk from logins;
since login_pk is not a column in logins.
I've seen this in version 8.4 on RHEL as well and now have replicated it on
CentOS with Postgres 9.2.13.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
adam.c.scott@gmail.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs