Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2CED663275B for ; Mon, 2 Feb 2009 17:32:20 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 36245-08 for ; Mon, 2 Feb 2009 17:32:16 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from rn-out-0910.google.com (rn-out-0910.google.com [64.233.170.191]) by mail.postgresql.org (Postfix) with ESMTP id A305463272A for ; Mon, 2 Feb 2009 17:32:16 -0400 (AST) Received: by rn-out-0910.google.com with SMTP id k43so1224179rnd.0 for ; Mon, 02 Feb 2009 13:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=IjsMAYiQOc8nhsvTxjQolklBNT6Hq5dnCOkvYsT8JuE=; b=FCv44VWJeWs3gqd0YoMcIlVNkIUL2cgzO/M8zjp9uok+V1bBgAUcAq0EYKVa7QpMqp hafLyJOLGgKzoB42tigSjZmMcIkOlt8QyKR8F2SS5DzC8rE1DeEe6qK3AIwLVBUx/dz7 oIjajf4SgCocavWN0xeKOTTTQrD4QAbsiQnIw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=cueCG79a6jRGwT/i9TRTrzn6hkKLuM6zeYO2bnrSgERnbosftQUZ9n1M3paSdFE6PN we5V3+uC7knHqUCPnH+cNcmmF5UCfP+O8xfp5QHL0Ai6k/IfLD7rNDc2KhBuwrG/iXKk uZT15adTwKla65WTd+JsltDNfWbCr1FBYzIME= MIME-Version: 1.0 Received: by 10.90.96.1 with SMTP id t1mr57152agb.43.1233610335224; Mon, 02 Feb 2009 13:32:15 -0800 (PST) In-Reply-To: <1711.2738-17750-2075670179-1233581999@email.cz> References: <1711.2738-17750-2075670179-1233581999@email.cz> Date: Mon, 2 Feb 2009 16:32:13 -0500 X-Google-Sender-Auth: 81123e0955369cb1 Message-ID: <491f66a50902021332w66598e8fhe6a2ed5b3a3ad8d1@mail.gmail.com> Subject: Re: BUG: DatabaseMetaData.getColumns isn't case insensitive From: Dave Cramer To: maly.velky@email.cz Cc: pgsql-jdbc@postgresql.org Content-Type: multipart/alternative; boundary=0016362836d0d284be0461f649c1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200902/2 X-Sequence-Number: 19277 --0016362836d0d284be0461f649c1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Shouldn't you quote the column in question if you want to get a MixedCase quoted column ? Dave On Mon, Feb 2, 2009 at 8:39 AM, wrote: > Hello, > > I'was trying to get meta data of a column and discovered that the column > name is case sensitive though it should be case insensitive. I don't know if > this can be somehow determined by a configuration or environment change > because I believe that till recently it worked in a case-insensitive > manner. > > I've the table studna_monitor.mon_user_session with the column "username". > The following code wrongly returns null (notice "username".toUpperCase()): > --- > String col = null; > Class.forName("org.postgresql.Driver"); > String url = "jdbc:postgresql://localhost/mydb?user=me&password=secret"; > Connection conn = DriverManager.getConnection(url); > DatabaseMetaData databaseMetaData = conn.getMetaData(); > ResultSet columnsMD = databaseMetaData.getColumns(null, > "studna_monitor", "mon_user_session", "username".toUpperCase()); > while(columnsMD.next()) { > col = columnsMD.getString("COLUMN_NAME"); > } > return col; > --- > While the following returns the column name "username": > --- > ... > ResultSet columnsMD = databaseMetaData.getColumns(null, "studna_monitor", > "mon_user_session", "username".toLowerCase()); > ... > --- > > BTW, the metadata reports: > supportsMixedCaseIdentifiers: false > supportsMixedCaseQuotedIdentifiers: true > (which is pretty much expected) > > Driver: postgresql-8.3-604.jdbc3.jar, postgresql-jdbc3-8.2.jar (as > distributed with Ubuntu, doesn't provide build number) > Server: Postgres 8.2.6 for Solaris > > > Thank you. > Jakub Holy > maly.velky@email.cz > > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc > --0016362836d0d284be0461f649c1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Shouldn't you quote the column in question if you want to get a MixedCa= se quoted column ?

Dave

On Mon, Fe= b 2, 2009 at 8:39 AM, <maly.velky@email.cz> wrote:
Hello,

I'was trying to get meta data of a column and discovered that the colum= n name is case sensitive though it should be case insensitive. I don't = know if this can be somehow determined by a configuration or environment ch= ange because I believe that till recently it  worked in a case-insensi= tive manner.

I've the table studna_monitor.mon_user_session with the column "us= ername". The following code wrongly returns null (notice "usernam= e".toUpperCase()):
---
String col =3D null;
Class.forName("org.postgresql.Driver");
String url =3D "jdbc:postgresql://localhost/mydb?user=3Dme&passwor= d=3Dsecret";
Connection conn =3D DriverManager.getConnection(url);
       DatabaseMetaData databaseMetaData =3D conn.getM= etaData();
       ResultSet columnsMD =3D databaseMetaData.getCol= umns(null, "studna_monitor", "mon_user_session", "= username".toUpperCase());
       while(columnsMD.next()) {
               col =3D columnsMD.g= etString("COLUMN_NAME");
       }
       return col;
---
While the following returns the column name "username":
---
...
ResultSet columnsMD =3D databaseMetaData.getColumns(null, "studna_moni= tor", "mon_user_session", "username".toLowerCase()= );
...
---

BTW, the metadata reports:
supportsMixedCaseIdentifiers: false
supportsMixedCaseQuotedIdentifiers: true
(which is pretty much expected)

Driver: postgresql-8.3-604.jdbc3.jar, postgresql-jdbc3-8.2.jar (as distribu= ted with Ubuntu, doesn't provide build number)
Server:  Postgres 8.2.6 for Solaris


Thank you.
Jakub Holy
maly.velky@email.cz

--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

--0016362836d0d284be0461f649c1--