Re: Unquoted column names fold to lower case

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Dev Kumkar <devdas(dot)kumkar(at)gmail(dot)com>, Thomas Kellerer <spam_eater(at)gmx(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Unquoted column names fold to lower case
Date: 2013-07-03 20:06:52
Message-ID: 20130703200652.GD6492@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Jul 3, 2013 at 03:47:37PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)2ndquadrant(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dev Kumkar 2013-07-03 20:30:24 Re: Unquoted column names fold to lower case
Previous Message Tom Lane 2013-07-03 19:47:37 Re: Unquoted column names fold to lower case