Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4FD039FB1F5; Tue, 31 Oct 2006 13:56:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 48149-05; Tue, 31 Oct 2006 13:55:57 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from community1.commandprompt.com (host-130.commandprompt.net [207.173.203.130]) by postgresql.org (Postfix) with ESMTP id BA3029FA0FF; Tue, 31 Oct 2006 13:55:56 -0400 (AST) Received: from [192.168.27.150] ([12.38.10.44]) (authenticated bits=0) by community1.commandprompt.com (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id k9VHtk1Y028197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 31 Oct 2006 09:55:49 -0800 Message-ID: <45478E22.8060805@dunslane.net> Date: Tue, 31 Oct 2006 12:55:46 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.6) Gecko/20060804 Fedora/1.0.4-0.5.1.fc5 SeaMonkey/1.0.4 MIME-Version: 1.0 To: Chuck McDevitt CC: Tom Lane , beau hargis , pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [HACKERS] Case Preservation disregarding case References: <200610271623.37525.beauh@bluefrogmobile.com> <1162003132.687.8.camel@pampa> <200610301928.51255.beauh@bluefrogmobile.com> <23177.1162265010@sss.pgh.pa.us> <24861.1162276496@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/59 X-Sequence-Number: 26711 There was some discussion a couple of years ago on the -hackers list about it, so you might like to review the archives. The consensus seemed to be that behaviour would need to be set no later than createdb time. The options I thought of were: . current postgres behaviour (we need to do this for legacy reasons, of course, as well as to keep happy the legions who hate using upper case for anything) . strictly spec compliant (same as current behaviour, but folding to upper case for unquoted identifiers rather than lower) . fully case sensitive even for unquoted identifiers (not spec compliant at all, but nevertheless possibly attractive especially for people migrating from MS SQLServer, where it is an option, IIRC). To this you propose, as I understand it, to have a fourth possibility which would be spec compliant for comparison purposes but would label result set columns with the case preserved name originally used (or would you use the casing used in the query?). These could be accomplished I think with a second catalog column like you suggest, in a number of places, but making sure all the code paths were covered might be somewhat laborious. We could probably add the second option without being nearly so invasive, though, and some people might feel that that would be sufficient. cheers andrew Chuck McDevitt wrote: > We treated quoted identifiers as case-specific, as the spec requires. > > In the catalog, we stored TWO columns... The column name with case > converted as appropriate (as PostgreSQL already does), used for looking > up the attribute, > And a second column, which was the column name with the case exactly as > entered by the user. > > So, your example would work just fine. > > > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: Monday, October 30, 2006 10:35 PM > To: Chuck McDevitt > Cc: beau hargis; pgsql-sql@postgresql.org; pgsql-hackers@postgresql.org > Subject: Re: [HACKERS] [SQL] Case Preservation disregarding case > sensitivity? > > "Chuck McDevitt" writes: > >> At Teradata, we certainly interpreted the spec to allow >> > case-preserving, > >> but case-insensitive, identifiers. >> > > Really? > > As I see it, the controlling parts of the SQL spec are (SQL99 sec 5.2) > > 26) A and a are > equivalent if the of the identifier> > (with every letter that is a lower-case letter replaced by > the > corresponding upper-case letter or letters) and the > identifier body> of the (with all > occurrences of replaced by and all > occurrences of replaced by quote>), > considered as the repetition of a > that specifies a of > SQL_IDENTIFIER > and an implementation-defined collation that is sensitive to > case, compare equally according to the comparison rules in > Subclause 8.2, "". > > 27) Two s are equivalent if their > identifier body>s, considered as the repetition of a > string literal> that specifies a specification> > of SQL_IDENTIFIER and an implementation-defined collation > that is sensitive to case, compare equally according to the > comparison rules in Subclause 8.2, "". > > Note well the "sensitive to case" bits there. Now consider > > CREATE TABLE tab ( > "foobar" int, > "FooBar" timestamp, > "FOOBAR" varchar(3) > ); > > We can *not* reject this as containing duplicate column names, else we > have certainly violated rule 27. Now what will you do with > > SELECT fooBar FROM tab; > > ? The spec is unquestionably on the side of "you selected the varchar > column"; historical Postgres practice is on the side of "you selected > the int column". AFAICS a case-insensitive approach would have to > fail with some "I can't identify which column you mean" error. I am > interested to see where you find support for that in the spec... > >