Re: execute incorect query and get data

Lists: pgsql-bugs
From: Marek Wróbel <mwrobel(at)icentrum(dot)pl>
To: pgsql-bugs(at)postgresql(dot)org
Subject: execute incorect query and get data
Date: 2006-12-14 10:43:03
Message-ID: 45812AB7.8090300@icentrum.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

PostgreSQL : 8.2
Operating system: fedora RC4

--------

create table a (a1 integer);
create table b (b1 integer);

insert into a (a1) values (1);
insert into a (a1) values (2);
select a1 from b;

ERROR: column "a1" does not exist at character 8

but :
select a1 from a where a1 not in (select a1 from b);

a1
----
1
2
(2 rows)

when b is not empty :

insert into b (b1) values (1);

select a1 from b;
ERROR: column "a1" does not exist at character 8

but :
select a1 from a where a1 not in (select a1 from b);
a1
----
(0 rows)

select a1 from a where a1 in (select a1 from b);
a1
----
1
2
(2 rows)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marek Wróbel <mwrobel(at)icentrum(dot)pl>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: execute incorect query and get data
Date: 2006-12-14 16:23:52
Message-ID: 21281.1166113432@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

=?ISO-8859-2?Q?Marek_Wr=F3bel?= <mwrobel(at)icentrum(dot)pl> writes:
> create table a (a1 integer);
> create table b (b1 integer);
> insert into a (a1) values (1);
> insert into a (a1) values (2);
> select a1 from b;
> ERROR: column "a1" does not exist at character 8
> but :
> select a1 from a where a1 not in (select a1 from b);

This is not a bug, it's an outer reference. Read any SQL book ...

regards, tom lane


From: Marek Wróbel <mwrobel(at)icentrum(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: execute incorect query and get data
Date: 2006-12-15 09:01:11
Message-ID: 45826457.1000804@icentrum.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Him,

Tom Lane napisał(a):
> =?ISO-8859-2?Q?Marek_Wr=F3bel?= <mwrobel(at)icentrum(dot)pl> writes:
>> create table a (a1 integer);
>> create table b (b1 integer);
>> insert into a (a1) values (1);
>> insert into a (a1) values (2);
>> select a1 from b;
>> ERROR: column "a1" does not exist at character 8
>> but :
>> select a1 from a where a1 not in (select a1 from b);
>
> This is not a bug, it's an outer reference. Read any SQL book ...

of course... so sorry... I was such startled off result off this query,
that I can't see that...