Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8t2l-0002vl-WB for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Feb 2013 13:52:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U8t2l-0007qE-Bt for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Feb 2013 13:52:07 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8t2k-0007q9-Le for pgsql-bugs@postgresql.org; Fri, 22 Feb 2013 13:52:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U8t2h-0000kV-1W for pgsql-bugs@postgresql.org; Fri, 22 Feb 2013 13:52:06 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r1MDpuBF027501; Fri, 22 Feb 2013 08:51:56 -0500 (EST) From: Tom Lane To: "=?ISO-8859-1?B?Sm92?=" cc: "=?ISO-8859-1?B?cGdzcWwtYnVncw==?=" Subject: Re: BUG #7899: allow key word as alias in subquery but Can't reference it in outer query In-reply-to: References: Comments: In-reply-to "=?ISO-8859-1?B?Sm92?=" message dated "Fri, 22 Feb 2013 20:05:08 +0800" Date: Fri, 22 Feb 2013 08:51:56 -0500 Message-ID: <27500.1361541116@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org "=?ISO-8859-1?B?Sm92?=" writes: > xxx=# select end from (select 1 as end) t; > ERROR: syntax error at or near "end" > LINE 1: select end from (select 1 as end) t; > ^ You need to double-quote the outer use of "end", viz regression=# select "end" from (select 1 as end) t; end ----- 1 (1 row) In the context with "as", Postgres can tell the word is meant as a column identifier not a keyword, but there's no way for it to know that in the outer usage. > I think use key word as alias should get a error message such as $key_word > is Key Word,should not be used as identifier bla bla,so for some complex > query error user can save a lot of time. Well, yours is the first complaint we've ever had in that direction, whereas we used to get a lot of complaints in the opposite direction, back when we didn't allow keywords to be used for column names. So I doubt we'll change it. It is an interesting gotcha though :-( 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