From: Kris Jurka <books@ejurka.com>
To: maly.velky@email.cz
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Re: [JDBC] BUG: DatabaseMetaData.getColumns isn't case insensitive
Date: Thu, 5 Feb 2009 18:19:21 -0500 (EST)
Message-ID: <Pine.BSO.4.64.0902051809030.17892@leary.csoft.net> (raw)
In-Reply-To: <1619.2522-20386-1582424767-1233656590@email.cz>
References: <1619.2522-20386-1582424767-1233656590@email.cz>
On Tue, 3 Feb 2009, maly.velky@email.cz wrote:
> Hello, thank you very much for your clarification.
>
> So there is no way how to perform case-insensitive search in getColumns() ?
Sorry, no.
>> > supportsMixedCaseIdentifiers: false
>>
>> This is reporting how the server matches up with the SQL standard, not how
>> a particular JDBC API call works.
>>
> So when does this (namely "Retrieves whether this database treats mixed case
> unquoted SQL identifiers as case sensitive" = false) apply? As you say it
> doesn't apply to the getColumns call but when does it? For
> insert/update/select statements only? If it applies for select statements,
> what happens (referring to you example) when I've "select t1 from ...", does
> it select t1, T1, or fail?
jurka=# create table t ("c1" int, "C1" int);
CREATE TABLE
jurka=# insert into t values (1, 2);
INSERT 0 1
jurka=# select c1, C1 from t;
c1 | c1
----+----
1 | 1
(1 row)
This is actually against the SQL spec, the spec says unquoted identifiers
should be folded to upper case rather than postgresql's behavior of
folding to upper case. So a spec complaint database would have retrieved
C1's value of 2. If you look further at DatabaseMetaData you can see this
called out by storesLowerCaseIdentifiers returning true.
To get both values out the column names must be quoted.
jurka=# SELECT "c1", "C1" from t;
c1 | C1
----+----
1 | 2
(1 row)
Supporting that in getColumns would be odd because requiring a column name
to be quoted there isn't something that would happen naturally. It's
would be especially bad if you also consider that column names can have
quotes in them:
jurka=# alter table t add column """" int;
ALTER TABLE
jurka=# \d t
Table "public.t"
Column | Type | Modifiers
--------+---------+-----------
c1 | integer |
C1 | integer |
" | integer |
Kris Jurka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com, maly.velky@email.cz
Subject: Re: [JDBC] BUG: DatabaseMetaData.getColumns isn't case insensitive
In-Reply-To: <Pine.BSO.4.64.0902051809030.17892@leary.csoft.net>
References: <1619.2522-20386-1582424767-1233656590@email.cz> <Pine.BSO.4.64.0902051809030.17892@leary.csoft.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox