pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13748: Syntax error not emitted
2+ messages / 2 participants
[nested] [flat]

* BUG #13748: Syntax error not emitted
@ 2015-10-30 00:39  adam.c.scott@gmail.com
  0 siblings, 1 reply; 2+ messages in thread

From: adam.c.scott@gmail.com @ 2015-10-30 00:39 UTC (permalink / raw)
  To: pgsql-bugs

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #13748: Syntax error not emitted
@ 2015-10-30 01:22  Tom Lane <tgl@sss.pgh.pa.us>
  parent: adam.c.scott@gmail.com
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2015-10-30 01:22 UTC (permalink / raw)
  To: adam.c.scott@gmail.com; +Cc: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-10-30 01:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 00:39 BUG #13748: Syntax error not emitted adam.c.scott@gmail.com
2015-10-30 01:22 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox