Re: conditional query in where has name collision. bug?

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: bill wilson <bill(dot)wilson(dot)home(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: conditional query in where has name collision. bug?
Date: 2014-09-21 00:08:59
Message-ID: 87oau9n8lz.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "bill" == bill wilson <bill(dot)wilson(dot)home(at)gmail(dot)com> writes:

bill> This a toy example from a 'upsert' script that appends new data:
bill> select a from (select 1 as a) as t1 where not exists (select
bill> true from (select 2 as a) t2 where a=a) ;
bill> a
bill> ───
bill> (0 rows)

bill> Please tell me this a bug. We can see in the first query
bill> without naming the tables that 'a=a' uses table t2 for both
bill> columns.

Of course it's not a bug. The column "a" in the inner scope hides the
column "a" in the outer scope, as explicitly required by the spec
(6.6 <identifier chain> in sql2008).

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2014-09-21 01:15:17 Re: Minor improvement in lock.sgml
Previous Message bill wilson 2014-09-20 21:03:18 conditional query in where has name collision. bug?