Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UuTKP-0006sQ-DM for pgsql-sql@arkaria.postgresql.org; Wed, 03 Jul 2013 20:07:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UuTKO-000864-TV for pgsql-sql@arkaria.postgresql.org; Wed, 03 Jul 2013 20:07:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UuTKO-00085y-7n for pgsql-sql@postgresql.org; Wed, 03 Jul 2013 20:07:00 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UuTKL-0001kT-0Z for pgsql-sql@postgresql.org; Wed, 03 Jul 2013 20:06:59 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1UuTKG-0004Qq-2D; Wed, 03 Jul 2013 16:06:52 -0400 Date: Wed, 3 Jul 2013 16:06:52 -0400 From: Bruce Momjian To: Tom Lane Cc: Alvaro Herrera , Dev Kumkar , Thomas Kellerer , pgsql-sql@postgresql.org Subject: Re: Unquoted column names fold to lower case Message-ID: <20130703200652.GD6492@momjian.us> References: <1372858894.60580.YahooMailClassic@web161605.mail.bf1.yahoo.com> <20130703152402.GA6492@momjian.us> <20130703153524.GB6492@momjian.us> <20130703190831.GG3592@eldon.alvh.no-ip.org> <24100.1372880857@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <24100.1372880857@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On Wed, Jul 3, 2013 at 03:47:37PM -0400, Tom Lane wrote: > Alvaro Herrera 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 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