472,328 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

PG case sensitivity

Hello,

I am running into a problem with PGs case sensitivity with regard to column and
table names. I am using program components that require the object names
returned from database metadata queries to be in uppercase. Therefore, I am
forced to use double quotes in the table creation scripts, like

create table "BLA" ();

However, after doing that, all scripts that reference objects without quotes
fail, as PG seems to internally translate to lowercase in the absence of
quotes. I am forced to touch each and every column and table name in every
script. Questions:

1) can PG be configured to operate case insensitive?
2) why in the world was case sensitivity introduced at all? AFAIK, the SQL
standard explicitly states that names are case insensitive, and it seems to me
that PG goes against that standard. In fact, if there is no solution to this
problem, my conclusion will probably be to drop PG altogether, as we need DB
interoperability on the program and script level, and this is becoming
unmaintainable..

thanks,
christian

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
14 2219

Hi,

On Tue, 14 Sep 2004, Christian Sell wrote:
I am running into a problem with PGs case sensitivity with regard to column and
table names. I am using program components that require the object names
returned from database metadata queries to be in uppercase. Therefore, I am
forced to use double quotes in the table creation scripts, like

create table "BLA" ();

<snip>

I'll not answer your question but... I wonder why people want to use
capital letters in table names... I've been developing apps for years and
I never ever needed to capitalize my table names...

Regards,
--
Devrim GUNDUZ
devrim~gunduz.org devrim.gunduz~linux.org.tr
http://www.tdmsoft.com
http://www.gunduz.org

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2
On Tue, 2004-09-14 at 12:37, Christian Sell wrote:
Hello,

I am running into a problem with PGs case sensitivity with regard to column and
table names. I am using program components that require the object names
returned from database metadata queries to be in uppercase. Therefore, I am
forced to use double quotes in the table creation scripts, like
Why do programs that interface with case-insensitive SQL require a
particular case?
create table "BLA" ();

However, after doing that, all scripts that reference objects without quotes
fail, as PG seems to internally translate to lowercase in the absence of
quotes. I am forced to touch each and every column and table name in every
script. Questions:

1) can PG be configured to operate case insensitive?
It does, but in lower case (which is a good deal more readable). Using
lower rather than upper case is a decision made many years ago.
2) why in the world was case sensitivity introduced at all? AFAIK, the SQL
standard explicitly states that names are case insensitive, and it seems to me
that PG goes against that standard.


It doesn't. It simply folds to lower case rather than upper case. If
things are truly case-insensitive, this should be of no consequence.

The fault is with your program components that are insisting on upper
case rather than accepting either case. Perhaps you need some
intermediate component to swap case on identifiers for their benefit.

--
Oliver Elphick ol**@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"But without faith it is impossible to please him; for
he that cometh to God must believe that he is, and
that he is a rewarder of them that diligently seek
him." Hebrews 11:6
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #3
Christian Sell wrote:
1) can PG be configured to operate case insensitive?
No.
2) why in the world was case sensitivity introduced at all?


Because the SQL standard specifies it.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #4

I have a table containing coordinates and I want to insert these into
another table, converting them to boxes.

I would like to use the same syntax as arrays :

INSERT INTO ... (coords) SELECT ARRAY[a,b,c] FROM ...

But I want boxes. Is there a way to do this ?

SELECT BOX[[a,b],[c,d]] FROM ...
raises a Syntax Error.
And I'd like to avoid to concatenate strings to build a box
representation like
'((1,2),(3,4))'::box;

Is there a way ?

Thanks !

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #5
> I'll not answer your question but... I wonder why people want to use
capital letters in table names... I've been developing apps for years and
I never ever needed to capitalize my table names...


as I wrote in my mail, its a matter of interoperability in a multi-DBMS
environment with existing scripts. If it was all PG, no problem.

Anyhow, I still dont see why

select * from A
-- and
select * from "A"

are different things, if the standard requires case insensitivity.
christian

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #6
Christian Sell wrote:
Anyhow, I still dont see why

select * from A
-- and
select * from "A"

are different things, if the standard requires case insensitivity.


You're operating under flawed assumptions. Please read the
documentation for the full details:
http://www.postgresql.org/docs/7.4/s...AX-IDENTIFIERS

--
Peter Eisentraut
http://developer.postgresql.org/~petere/
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #7
In article <20************************@gmx.net>,
Peter Eisentraut <pe*****@gmx.net> writes:
Christian Sell wrote:
1) can PG be configured to operate case insensitive?
No. 2) why in the world was case sensitivity introduced at all?

Because the SQL standard specifies it.


I think it's the other way round. "CREATE TABLE SHIT" and "create
table shit" are the same according to the SQL standard, and they are
the same for PostgreSQL. The 'gotcha' is that when you ask PostgreSQL
for the table name you get "shit" and not "SHIT", as opposed to many
other DBMSs.
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #8

On Tue, 14 Sep 2004, Christian Sell wrote:
Hello,

I am running into a problem with PGs case sensitivity with regard to column and
table names. I am using program components that require the object names
returned from database metadata queries to be in uppercase. Therefore, I am
forced to use double quotes in the table creation scripts, like

create table "BLA" ();

However, after doing that, all scripts that reference objects without quotes
fail, as PG seems to internally translate to lowercase in the absence of
quotes. I am forced to touch each and every column and table name in every
script. Questions:

1) can PG be configured to operate case insensitive?
2) why in the world was case sensitivity introduced at all? AFAIK, the SQL
standard explicitly states that names are case insensitive, and it seems to me
that PG goes against that standard. In fact, if there is no solution to this


No, the SQL spec says that names are case folded to uppercase, although we
currently case-fold to lowercase (and can't really wholesale change that
for backwards compatibility reasons). There's been talk about supporting a
mode which case folds the other direction. In general, however, mixing
quoted and unquoted names is dangerous in all complient databases, because
in none would "Bla" and bla or BLA be the same name.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #9
On Tue, 14 Sep 2004, Oliver Elphick wrote:
The fault is with your program components that are insisting on upper
case rather than accepting either case.


In defence of this unknown component, the sql specifications says that
identifiers should be upper cased where pg do lower case.

I would welcome a initdb setting that defines what to use.

--
/Dennis Björklund
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #10
Stephan Szabo <ss****@megazone.bigpanda.com> writes:
... There's been talk about supporting a
mode which case folds the other direction. In general, however, mixing
quoted and unquoted names is dangerous in all complient databases, because
in none would "Bla" and bla or BLA be the same name.


We have looked at this before and keep coming up with the conclusion
that (a) on-the-fly changes in the backend behavior are impractical;
and (b) if we only get to have one behavior, the current one is the best
compromise we are going to get.

I wonder though whether we could offer some tweaking on client side.
For instance consider the JDBC driver's getMetaData operations.
You could imagine a JDBC driver mode that would smash all returned
identifiers to upper case. For an application that was willing to
promise it would never explicitly quote identifiers in the SQL it
generates, this would not break anything AFAICS; and it would satisfy
app code that was expecting to see upper instead of lower case.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #11

On Tue, 14 Sep 2004, Tom Lane wrote:
Stephan Szabo <ss****@megazone.bigpanda.com> writes:
... There's been talk about supporting a
mode which case folds the other direction. In general, however, mixing
quoted and unquoted names is dangerous in all complient databases, because
in none would "Bla" and bla or BLA be the same name.
We have looked at this before and keep coming up with the conclusion
that (a) on-the-fly changes in the backend behavior are impractical;
and (b) if we only get to have one behavior, the current one is the best
compromise we are going to get.


An initdb-time flag might be okay, except that I don't know if any of the
applications (pg_dump, etc) would need to know about it and it would take
some work to get the database to initialize correctly in the first place.
I wonder though whether we could offer some tweaking on client side.
For instance consider the JDBC driver's getMetaData operations.
You could imagine a JDBC driver mode that would smash all returned
identifiers to upper case. For an application that was willing to
promise it would never explicitly quote identifiers in the SQL it
generates, this would not break anything AFAICS; and it would satisfy
app code that was expecting to see upper instead of lower case.


That's true, although it seems like in many of these cases the application
is also using quoting inconsistently.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #12
Tom Lane wrote:
I wonder though whether we could offer some tweaking on client side.
For instance consider the JDBC driver's getMetaData operations.
You could imagine a JDBC driver mode that would smash all returned
identifiers to upper case.


Then again, JDBC applications can query
DatabaseMetaData.storesUpperCaseIdentifiers().

--
Peter Eisentraut
http://developer.postgresql.org/~petere/
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #13
Please don't reply to existing threads to start a new thread. This makes the
archives less usable.

On Tue, Sep 14, 2004 at 14:00:43 +0200,
Pierre-Frédéric Caillaud <li***@boutiquenumerique.com> wrote:

I have a table containing coordinates and I want to insert these
into another table, converting them to boxes.

I would like to use the same syntax as arrays :

INSERT INTO ... (coords) SELECT ARRAY[a,b,c] FROM ...

But I want boxes. Is there a way to do this ?

SELECT BOX[[a,b],[c,d]] FROM ...
You want something like box(point(a,b),point(c,d)) .

raises a Syntax Error.
And I'd like to avoid to concatenate strings to build a box
representation like
'((1,2),(3,4))'::box;

Is there a way ?

Thanks !

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #14
> > The fault is with your program components that are insisting on upper
case rather than accepting either case.


In defence of this unknown component, the sql specifications says that
identifiers should be upper cased where pg do lower case.

I would welcome a initdb setting that defines what to use.


yes, that would do it. Sounds far better than having the JDBC driver handle
this.

Christian Sell

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: Elliot Temple | last post by:
Hi I have two questions. Could someone explain to me why Python is case sensitive? I find that annoying. Also, why aren't there multiline...
761
by: Neo-LISPer | last post by:
Hey Recently, I researched using C++ for game programming and here is what I found: C++ game developers spend a lot of their time debugging...
16
by: Starwiz | last post by:
I'm a VB.net programmer, and I'm about to start working with two C++ programmers and teach them .net. I've decided to use C# in teaching them,...
3
by: Jason Tesser | last post by:
I am converting data from Access into Postgres and ran into an issue with case sensitivity. Can I write queries in Access that will be case...
15
by: gregory_may | last post by:
Is there any options in VS 2005 to better handle case issues in C# (Similar to VB.Net)?
1
by: othellomy | last post by:
Is SQL server defaults to case insensitive? I am sure there are ways to install case sensitive SQL server instance but coming from Sybase (which is...
3
by: Anita Potekkat | last post by:
Hello, I had a question regarding Case Sensitivity in 10g & 9i. (1) Does Case Sensitivity in Oracle have to do with data only? Or does it also...
2
by: sweetpotatop | last post by:
Hi, I believe my SQL server was configured as Case sensitivity. I have a number of stored procedures which were moved from a non-Case...
2
by: Lucky | last post by:
Hi guys, I'm having problem with case sensitive collation of SQL Database. one my client is having case sensitive database. While developing the...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.