From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-sql@postgresql.org
Subject: bug in 9.2.2 ? subquery accepts wrong column name : upd
Date: Thu, 14 Mar 2013 17:29:07 +0200
Message-ID: <1641558.Xf5bk256pC@smadev.internal.net> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
dynacom=# SELECT DISTINCT ON (qry.setid) qry.setid, qry.arragg[1:2] FROM
(select distinct sst.setid,(array_agg(vsl.name) OVER (PARTITION BY sst.setid ORDER BY character_length(vsl.name))) as arragg
FROM sissets sst, vessels vsl WHERE vsl.id=sst.vslid ORDER BY sst.setid) as qry
WHERE array_length(qry.arragg,1)>1 AND qry.setid IN (SELECT setid from sis_oper_cons) ORDER BY qry.setid,array_length(qry.arragg,1);
setid | arragg
-------+----------------------------------
54 | {EQUZZZ,SAMZZZ}
55 | {"ZZZR","ZZZTRAVEL"}
81 | {"ZZZ SISTER","ZZZ DUMMY II"}
(3 rows)
however, there is not column setid in sis_oper_cons,
dynacom=# SELECT setid from sis_oper_cons;
ERROR: column "setid" does not exist
LINE 1: SELECT setid from sis_oper_cons;
^
9.2.2 Postgresql treats qry.setid IN (SELECT setid from sis_oper_cons) as true.
However, making subquery look like (SELECT soc.setid from sis_oper_cons soc), as in
dynacom=# SELECT DISTINCT ON (qry.setid) qry.setid, qry.arragg[1:2] FROM (select distinct sst.setid,(array_agg(vsl.name) OVER (PARTITION BY sst.setid ORDER BY character_length(vsl.name))) as arragg FROM sissets sst, vessels vsl WHERE vsl.id=sst.vslid ORDER BY sst.setid) as qry WHERE array_length(qry.arragg,1)>1 AND qry.setid NOT IN (SELECT soc.setid from sis_oper_cons soc) ORDER BY qry.setid,array_length(qry.arragg,1);
ERROR: column soc.setid does not exist
LINE 1: ...gth(qry.arragg,1)>1 AND qry.setid NOT IN (SELECT soc.setid ...
^
dynacom=#
postgresql corerctly identifies and throws the error.
-
Achilleas Mantzios
IT DEV
IT DEPT
Dynacom Tankers Mgmt
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: achill@matrix.gatewaynet.com
Subject: Re: bug in 9.2.2 ? subquery accepts wrong column name : upd
In-Reply-To: <1641558.Xf5bk256pC@smadev.internal.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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