Case sensitivity in ODBC ??

From: Emmanuel Charpentier <charpent(at)bacbuc(dot)dyndns(dot)org>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Case sensitivity in ODBC ??
Date: 2000-02-06 18:37:59
Message-ID: 20000206.18375900@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Dear pgsql-interface list,

I have lived that SQL database were not to be case-sensitive. However,
it seems that, at least through the ODBC interface, PostgreSQL 6.5.3
is :

Config : Linux RedHat 6.1, PostgreSQL 6.5.3 from the PostgreSQL ftp
site's RPM, unixODBC1.7 (including their PostgreSQL driver). Works
great from various interfaces (including StarOffice ...).

I'm working from the R statistical language/package through a beta
ODBC interface. Note that the interpreted R language is case-sensitive ...

Logical Setup

R user interface ---> RODBC library ---> unixODBC ---> PostgreSQL
^
|
I'm trying to enhance that---+

This interface mostly works, but has some odd behaviour :

> sqlQuery(chan1,"create table Test1 (id int4 not null primary key, val
varchar(255))") /* This creates the table test1, correctly */

> sqlColumns(chan1,"test1") /* Sanity check */
TABLE_QUALIFIER TABLE_OWNER TABLE_NAME COLUMN_NAME DATA_TYPE
TYPE_NAME
1 NA NA test1 id 4
int4
2 NA NA test1 val 12
varchar
PRECISION LENGTH SCALE RADIX NULLABLE REMARKS DISPLAY_SIZE
FIELD_TYPE
1 10 4 0 10 0 NA 11
23
2 254 254 NA NA 1 NA 254
1043
/* This is the expected answer */

> sqlTables(chan1)
TABLE_QUALIFIER TABLE_OWNER TABLE_NAME TABLE_TYPE REMARKS
1 NA NA pga_forms TABLE NA
2 NA NA pga_layout TABLE NA
3 NA NA pga_queries TABLE NA
4 NA NA pga_reports TABLE NA
5 NA NA pga_schema TABLE NA
6 NA NA pga_scripts TABLE NA
7 NA NA test1 TABLE NA
/* This also is the expected answer. Note however that the name of the
table is lowercased */

> sqlColumns(chan1,"Test1") /* Same sanity check, with the original name
*/
Error in sqlColumns(chan1, "Test1") : Test1 :table not found on
channel 0
/* This is unexpected if SQL, PostgreSQL and ODBC are case-insensitive
*/

Furthermore : debugging shows that the initial request for table
creation seds the name with its capital, as shown in the next example
:

> sqlSave(chan1,USArrests,rownames="State") /* The sqlSave function
creates the necessary table if it does not exists */
[1] "CREATE TABLE USArrests (State varchar(255) ,Murder varchar(255)
,Assault varchar(255) ,UrbanPop varchar(255) ,Rape varchar(255) )"
/* This is a debugging output showing the exact request sent to
PosstgreSQL, minus the ending semicolumn. Yes the types are
ridiculous, and that's what I'm trying to fix ... */
Error in sqlColumns(channel, tablename) : USArrests :table not found
on channel 0
/* This is an (unexpected) error message*/
> sqlTables(chan1)
TABLE_QUALIFIER TABLE_OWNER TABLE_NAME TABLE_TYPE REMARKS
1 NA NA pga_forms TABLE NA
2 NA NA pga_layout TABLE NA
3 NA NA pga_queries TABLE NA
4 NA NA pga_reports TABLE NA
5 NA NA pga_schema TABLE NA
6 NA NA pga_scripts TABLE NA
7 NA NA usarrests TABLE NA
/* A table « usarrests » has been created, but querying « USArrests »
does not work. However :*/

> sqlColumns(chan1,"usarrests")
TABLE_QUALIFIER TABLE_OWNER TABLE_NAME COLUMN_NAME DATA_TYPE
TYPE_NAME
1 NA NA usarrests state 12
varchar
2 NA NA usarrests murder 12
varchar
3 NA NA usarrests assault 12
varchar
4 NA NA usarrests urbanpop 12
varchar
5 NA NA usarrests rape 12
varchar
PRECISION LENGTH SCALE RADIX NULLABLE REMARKS DISPLAY_SIZE
FIELD_TYPE
1 254 254 NA NA 1 NA 254
1043
2 254 254 NA NA 1 NA 254
1043
3 254 254 NA NA 1 NA 254
1043
4 254 254 NA NA 1 NA 254
1043
5 254 254 NA NA 1 NA 254
1043
>
/* Querying « usarrests » does ! Note that column names have been
lowercased as well ... */

This seems to me proof enough that the behaviour of PostgreSQL (or
ODBC driver) related to case sensitivity is not coherent.

Could some kind soul shed some light on this ?

Thanks in advance,

Emmanuel Charpentier

Browse pgsql-interfaces by date

  From Date Subject
Next Message Gavrie Philipson 2000-02-07 07:53:23 [Fwd: Re: pgsql-interfaces-digest V1 #628]
Previous Message Gavrie Philipson 2000-02-06 07:34:03 Re: pgsql-interfaces-digest V1 #628