agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Dev Kumkar <devdas.kumkar@gmail.com>
Cc: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Unquoted column names fold to lower case
Date: Wed, 3 Jul 2013 16:06:52 -0400
Message-ID: <20130703200652.GD6492@momjian.us> (raw)
In-Reply-To: <24100.1372880857@sss.pgh.pa.us>
References: <1372858894.60580.YahooMailClassic@web161605.mail.bf1.yahoo.com>
	<kr1bl9$96d$1@ger.gmane.org>
	<20130703152402.GA6492@momjian.us>
	<CALSLE1N-WnxujTjD+ED9u4pjFrUnHbm8zr9+SmMvu5NPAMGw1g@mail.gmail.com>
	<20130703153524.GB6492@momjian.us>
	<CALSLE1Pxn7aL1P4tW5vL6GL7h9V1YrZU2KmFeTaHQ2ok4hb_xg@mail.gmail.com>
	<kr1i4m$s2o$1@ger.gmane.org>
	<CALSLE1Ofnbp=3WqrNQCG8g36w1h5ndwk4o4Vj9ruUHepzsMLHQ@mail.gmail.com>
	<20130703190831.GG3592@eldon.alvh.no-ip.org>
	<24100.1372880857@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On Wed, Jul  3, 2013 at 03:47:37PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> > Dev Kumkar escribió:
> >> But what I am asking here is if an alias name is provided be it upper case,
> >> lower case, or a mix then shouldn't it be preserved as as it is given. All
> >> this talk is when alias names are unquoted, when quoted then its standard
> >> behavior as seen in other databases.
> 
> > Aliases are treated just like any other identifier.  The downcasing
> > happens in the lexer (src/backend/parser/scan.l), which is totally
> > unaware of the context in which this is happening; so there's no way to
> > tweak the downcasing behavior for only aliases and not other
> > identifiers.
> 
> Quite aside from implementation difficulty, restricting the change to
> just column aliases doesn't make it more palatable.  You'd entirely lose
> the argument that the change increases spec compliance, because the spec
> is perfectly clear that a column alias is an identifier just like any
> other.  And you'd still be paying a large part of the application
> breakage costs, because the identifiers coming back in query descriptors
> are one of the main ways applications would notice such a change.

And let's not forget that column aliases can be used as indentifiers in
queries:

	test=> SELECT 1 AS x
	test-> ORDER BY x;
	 x
	---
	 1
	(1 row)

	test=> SELECT 1 AS "X"
	ORDER BY x;
	ERROR:  column "x" does not exist
	LINE 2: ORDER BY x;

Changing this would mean that the same identifier would have different
case-folding rules depending on where it appeared in the query.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (23+ messages)  latest in thread

Message-ID: <20130703200652.GD6492@momjian.us>
Permalink:  ../20130703200652.GD6492@momjian.us/
Also on:    postgresql.org/message-id/20130703200652.GD6492@momjian.us

reply

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: bruce@momjian.us, tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, devdas.kumkar@gmail.com, spam_eater@gmx.net
  Subject: Re: Unquoted column names fold to lower case
  In-Reply-To: <20130703200652.GD6492@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox