pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14514: Bug in Subquery
5+ messages / 5 participants
[nested] [flat]

* BUG #14514: Bug in Subquery
@ 2017-01-25 07:23 reva.d91@gmail.com
  2017-01-25 15:23 ` Re: BUG #14514: Bug in Subquery John McKown <john.archie.mckown@gmail.com>
  2017-01-25 15:29 ` Re: BUG #14514: Bug in Subquery Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-25 15:31 ` Re: BUG #14514: Bug in Subquery David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 3 replies; 5+ messages in thread

From: reva.d91@gmail.com @ 2017-01-25 07:23 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14514
Logged by:          Revathi Dharmalingam
Email address:      reva.d91@gmail.com
PostgreSQL version: 9.3.10
Operating system:   Windows 7/Unix
Description:        

It is ignoring the invalid columns in subquery,Instead of throwing the error
'Column does not exist'.

(eg):
select * from emp where (empname,empid,empno) in(selec emname,emid,emno from
em_details)

Note:There is no emno in em_details table.


-- 
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] 5+ messages in thread

* Re: BUG #14514: Bug in Subquery
  2017-01-25 07:23 BUG #14514: Bug in Subquery reva.d91@gmail.com
@ 2017-01-25 15:23 ` John McKown <john.archie.mckown@gmail.com>
  2 siblings, 0 replies; 5+ messages in thread

From: John McKown @ 2017-01-25 15:23 UTC (permalink / raw)
  To: reva.d91@gmail.com; +Cc: pgsql-bugs

On Wed, Jan 25, 2017 at 1:23 AM, <reva.d91@gmail.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      14514
> Logged by:          Revathi Dharmalingam
> Email address:      reva.d91@gmail.com
> PostgreSQL version: 9.3.10
> Operating system:   Windows 7/Unix
> Description:
>
> It is ignoring the invalid columns in subquery,Instead of throwing the
> error
> 'Column does not exist'.
>
> (eg):
> select * from emp where (empname,empid,empno) in(selec emname,emid,emno
> from
> em_details)
>
> Note:There is no emno in em_details table.
>
>
Note: just user, not developer.

​I tried to duplicate your error​ in PostgreSQL 9.5.5 on Fedora Linux 25,
64 bit. I got the expected "column does not exist". Can you try version 9.5
or even 9.6 to see if the bug is squashed in a later Windows version?


-- 
There’s no obfuscated Perl contest because it’s pointless.

—Jeff Polk

Maranatha! <><
John McKown

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

* Re: BUG #14514: Bug in Subquery
  2017-01-25 07:23 BUG #14514: Bug in Subquery reva.d91@gmail.com
@ 2017-01-25 15:29 ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-25 16:05   ` Re: BUG #14514: Bug in Subquery Pantelis Theodosiou <ypercube@gmail.com>
  2 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2017-01-25 15:29 UTC (permalink / raw)
  To: reva.d91@gmail.com; +Cc: pgsql-bugs

reva.d91@gmail.com writes:
> It is ignoring the invalid columns in subquery,Instead of throwing the error
> 'Column does not exist'.

> (eg):
> select * from emp where (empname,empid,empno) in(selec emname,emid,emno from
> em_details)

> Note:There is no emno in em_details table.

Maybe not, but if there is one in emp, then this query is legal per
SQL spec --- emno is an outer reference.

			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] 5+ messages in thread

* Re: BUG #14514: Bug in Subquery
  2017-01-25 07:23 BUG #14514: Bug in Subquery reva.d91@gmail.com
  2017-01-25 15:29 ` Re: BUG #14514: Bug in Subquery Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-01-25 16:05   ` Pantelis Theodosiou <ypercube@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Pantelis Theodosiou @ 2017-01-25 16:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: reva.d91@gmail.com; pgsql-bugs

On Wed, Jan 25, 2017 at 3:29 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> reva.d91@gmail.com writes:
> > It is ignoring the invalid columns in subquery,Instead of throwing the
> error
> > 'Column does not exist'.
>
> > (eg):
> > select * from emp where (empname,empid,empno) in(selec emname,emid,emno
> from
> > em_details)
>
> > Note:There is no emno in em_details table.
>
> Maybe not, but if there is one in emp, then this query is legal per
> SQL spec --- emno is an outer reference.
>
>                         regards, tom lane
>

What Tom says above, the query is legal SQL if the column exists in either
table.

You should use aliases (or just prefix the columns with their table name
and dot):

select e.* from emp as e
where (e.empname, e.empid, e.empno) in
    (select ed.emname, ed.emid, ed.emno
     from em_details as ed)

This way the query will work as you expected, either give a result (if the
3 columns exist in em_details) or give you an error if not.

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

* Re: BUG #14514: Bug in Subquery
  2017-01-25 07:23 BUG #14514: Bug in Subquery reva.d91@gmail.com
@ 2017-01-25 15:31 ` David G. Johnston <david.g.johnston@gmail.com>
  2 siblings, 0 replies; 5+ messages in thread

From: David G. Johnston @ 2017-01-25 15:31 UTC (permalink / raw)
  To: reva.d91@gmail.com; +Cc: pgsql-bugs

On Wed, Jan 25, 2017 at 12:23 AM, <reva.d91@gmail.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      14514
> Logged by:          Revathi Dharmalingam
> Email address:      reva.d91@gmail.com
> PostgreSQL version: 9.3.10
> Operating system:   Windows 7/Unix
> Description:
>
> It is ignoring the invalid columns in subquery,Instead of throwing the
> error
> 'Column does not exist'.
>
> (eg):
> select * from emp where (empname,empid,empno) in(selec emname,emid,emno
> from
> em_details)
>
> Note:There is no emno in em_details table.
> ​
>

​Working as designed.  The reference to "emno" comes from the "emp" table -
this is what is called a correlated subquery.

David J.​

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


end of thread, other threads:[~2017-01-25 16:05 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-01-25 07:23 BUG #14514: Bug in Subquery reva.d91@gmail.com
2017-01-25 15:23 ` John McKown <john.archie.mckown@gmail.com>
2017-01-25 15:29 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-01-25 16:05   ` Pantelis Theodosiou <ypercube@gmail.com>
2017-01-25 15:31 ` David G. Johnston <david.g.johnston@gmail.com>

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