Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 590E355C5A4 for ; Mon, 16 Jul 2012 14:37:20 -0300 (ADT) Received: from smtp102.prem.mail.ac4.yahoo.com ([76.13.13.41]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SqpEU-0004vD-4c for pgsql-jdbc@postgresql.org; Mon, 16 Jul 2012 17:37:19 +0000 Received: (qmail 64628 invoked from network); 16 Jul 2012 17:37:05 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=I6IwqhWekCn+Ud3dTWALXu3Q9McJd4EX+OUpjlKJhAwWzwwIecNzu9hhiurnDo3UlMVXtNh+6i81kCpyANOQc6h/V4+Cy6fWQfK8zQIe+l5TgFKUW70NL3gX9RX/CfpmwOR37hWQZPZ/uocLYpZRX+J0PNPTAAfxGoQ73InMp5M= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1342460225; bh=L5BrmZOtPIhQ7JKCOcl07x7IpnjaHlTimB1QUq+Q/2w=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=ikkDY60TbEZldfph5KThy1EmTQCVWaSuJz47R8/ZJMAcseHx9e1c3Qs9KnMzIBJGb6fJYWmSKr+Dm/5RSNFjtUV6ooGdMDJLzOjidInOaOg0IpccUH/H3Wxt8F6YL8t3MT6NmUpfnAEzT+voANcWfUnoeo89zXrfQO7Ed0OhjYo= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: G4eunQQVM1ktSkeJhy16tX5NnSrYNxjBv6AvCLSTgYfM178 g49THqNW874BtCtXIFQ70qY_gUSHa2XXe_27aHKXjZuAOZlSEe3yHwtmjmUD ncQfJOYbQ_XvTEVUUZCyVsZIwW56FZ9rFOyopbTbayZ9TvSU5vImZfPwupsE KtqBPa972XlK7d4xYeJiucPfcktIZ0GxYRXuzafZYewd1Y50xkMiwLm411AP O7eL5Wu33COmJSutzwIjXFz.SB4XB0fTa15T8f8ztMCA_mEJjYxDkjhxdT6_ kYcNq7.vEd48bAPUmVoLPilyPDmwyQY.eN0awGmTdvc.8gs4Qj_9BgirMJ2Y p_6yw3MFsmllu.rUcOgb_renLj2b5m5MafXBvjKDVjSy8KgxhiQUtndE_pQz YhepGf.lfS4FxT_ZoDIiO_z8QlBiFnXMM4HpGBqwwLeaW3i06tQAmA3Nu6V9 wgjmQECy6K3S7KR4y3j3kz1akMPKIpdjM8EvmE7LkPBu74Th7vdf5oeBMTpf OuA4u X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from WolfDog (polobo@24.93.23.188 with login) by smtp102.prem.mail.ac4.yahoo.com with SMTP; 16 Jul 2012 17:37:04 +0000 UTC From: "David Johnston" To: "'Dave Cramer'" Cc: "'dmp'" , "'Laurent Mazuel'" , "'PostgreSQL JDBC'" References: <5004221A.4030508@antidot.net> <50043BC9.2090401@ttc-cmc.net> <014801cd6372$e9d20850$bd7618f0$@yahoo.com> In-Reply-To: Subject: Re: Case-sensitive problem in AS clause? Date: Mon, 16 Jul 2012 13:36:39 -0400 Message-ID: <014c01cd6379$8f14a560$ad3df020$@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJYDGlH4sFG2EWecVJTMwXBfqnzQgKIdwmXAgh9oHACoa62iJXdQozw Content-Language: en-us X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/19 X-Sequence-Number: 23117 > -----Original Message----- > From: davecramer@gmail.com [mailto:davecramer@gmail.com] On Behalf > Of Dave Cramer > Sent: Monday, July 16, 2012 12:56 PM > To: David Johnston > Cc: dmp; Laurent Mazuel; PostgreSQL JDBC > Subject: Re: [JDBC] Case-sensitive problem in AS clause? > > The name of the column is not always case sensitive in fact postgresql all > names are folded to lower case unless quoted > > Dave Cramer > > dave.cramer(at)credativ(dot)ca > http://www.credativ.ca > > > On Mon, Jul 16, 2012 at 12:49 PM, David Johnston > wrote: > >> -----Original Message----- > >> From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc- > >> owner@postgresql.org] On Behalf Of dmp > >> Sent: Monday, July 16, 2012 12:05 PM > >> To: Laurent Mazuel; PostgreSQL JDBC > >> Subject: Re: [JDBC] Case-sensitive problem in AS clause? > >> > >> Again as the as identifier is not quoting it default to the default > > behavior for > >> assignment. As far as the isCaseSensitive() it is found that the > >> method in > > the > >> Pgjdbc, org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java is: > >> > >> /* > >> * Does a column's case matter? ASSUMPTION: Any field that is > >> * not obviously case insensitive is assumed to be case sensitive > >> * > >> > >> > > >> > Then, the column name is changed from StudentId to studentid, but > >> > the "isCaseSensitive" flag is "true". I think it is not correct, > >> > since it is impossible from now, when a user ask for the StudentId > >> > column to retrieve it from a resultset. The "isCaseSensitive" don't > >> > authorize to accept the string StudentId as a valid column name for > >> > the studentid column in the ResultSet. > >> > >> Recommed you quote AS "StudentID" to get the behavior you desire. > >> > >> danap. > > > > Does the "isCaseSensitive(int)" function return whether the "value" > > stored in the column is case-sensitive or does it return whether the > > "name" of the column is case-sensitive? > > > > The OP is using it to determine whether the "name" is case-sensitive - > > which it is always. > > > > My assumption is that it would indicate whether the "value" is > > case-sensitive - which is also true because varchar/text is case-sensitive. > > > > The fact that different fields may or may not be case-sensitive > > supports this since the "case-sensitive" property of a column "name" > > should be constant throughout the database/product. > > > > David J. > > Folding to lower-case does not negate the fact that the name itself is always case-sensitive. It is just when you don't put the name in quotes a pre-processing phase translates the name into lower-case. I get that this is semantics but in a true case-insensitive system it would not matter whether you used quotes or not when providing the name. So in PostgreSQL names are always case-sensitive but if the name is not quoted the case of the name is automatically converted to lower-case before the case-sensitive comparison is made. In other words - once the name is stored it no longer matters how the value was entered (i.e., with or without qutotes) its value is stored in a case-sensitive manner. There is no way to store an mixed-case value and then compare to it in a case-insensitive manner. E.G., If my field name has been stored as "ColumnA" there is no way to reference that column other than by writing: SELECT "ColumnA" ... Futhermore the system cannot distinguish between (columna) AND ("columna") - both representations are equivalent. By your logic the former should return "case-insensitive" while the later should return "case-sensitive". David J.