Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 6F3F555C5A4 for ; Mon, 16 Jul 2012 11:16:15 -0300 (ADT) Received: from bigmail.antidot.net ([62.210.155.249] helo=mail.antidot.net) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sqm5t-00018W-MK for pgsql-jdbc@postgresql.org; Mon, 16 Jul 2012 14:16:14 +0000 Received: from [92.103.9.178] (helo=[10.61.8.29]) by mail.antidot.net with esmtpa (Exim 4.72) (envelope-from ) id 1Sqm5f-00007t-9w; Mon, 16 Jul 2012 16:15:59 +0200 Message-ID: <5004221A.4030508@antidot.net> Date: Mon, 16 Jul 2012 16:15:54 +0200 From: Laurent Mazuel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110805 Icedove/5.0 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Case-sensitive problem in AS clause? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/13 X-Sequence-Number: 23111 Dear all, I maybe found a problem with the "isCaseSensitive" method in the "ResultSetMetadata" class when using it on a "AS" clause. With the following test DB: > test=> CREATE TABLE "Student" ("ID" INTEGER,"Name" VARCHAR(15)); > CREATE TABLE > test=> INSERT INTO "Student" ("ID", "Name") VALUES(10,'Venus'); > INSERT 0 1 I execute the query with the "AS" clause: > test=> Select ('Student' || "ID" ) AS StudentId, "ID", "Name" from > "Student" ; > studentid | ID | Name > -----------+----+------- > Student10 | 10 | Venus > (1 ligne) The StudentId regular identifier becomes studentid, but this kind of transformation is not a problem, since a regular identifier is not case sensitive. The problem is where I execute my query in JDBC: > @Test > public void testAsCaseSensitive() throws Exception { > Connection conn = > DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test","root","root"); > java.sql.Statement s = conn.createStatement( > ResultSet.HOLD_CURSORS_OVER_COMMIT, ResultSet.CONCUR_READ_ONLY); > s.executeQuery("Select ('Student' || \"ID\" ) AS StudentId from > \"Student\";"); > ResultSet rs = s.getResultSet(); > ResultSetMetaData metaData = rs.getMetaData(); > int n = metaData.getColumnCount(); > for (int i = 1; i <= n; i++) { > System.out.println("Column: "+metaData.getColumnLabel(i)+" > "+metaData.isCaseSensitive(i)); > } > } I obtain the output: > Column: studentid true 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. This on: psql (PostgreSQL) 9.1.4 (debian-squeeze backport packages), with Maven dependency on JDBC plugin: > > postgresql > postgresql > 9.1-901.jdbc4 > I hope that I don't have miss something and I don't bother you.... Best regards, Laurent Mazuel -- Laurent Mazuel (lmazuel@antidot.net) Ingénieur R&D, Web Sémantique Antidot - Solutions de recherche d'information 29 avenue Jean Monnet, 13410 LAMBESC (FRANCE) Tel: (33) 4 42 63 67 90 / Fax: (33) 4 42 28 61 03