database name case

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
tintinux
Junior Boarder
Junior Boarder
Posts: 44
Joined: 19.05.2010, 10:39

database name case

Post by tintinux »

Hi

According to Postgresql documentation, the database object names are not case sensitive unless they are surrounded by quotes. If I execute the Sql : "Create database Test [...] ", a database test (in lowercase) is actually created, from ZeosLib like from any other tool. Fine. :D

But if I connect using Zeos (7.0.3) after having assigned the string "Test" (without quotes) to the database name of TZconnection, it raises : "database doesn't exists".

BuildConnectStr in ZDbcPostgreSql makes a connection string with double quotes surrounding the dbname, so it might be normal that the dbname is case sensitive.

However, I tried to change it without quotes surrounding the dbname, but I have the same error in ConnectDatabase which calls POSTGRESQL_API.PQconnectdb(ConnInfo), so I don't know what I can do ! It looks like the API is case sensitive. Is there a parameter to set ?

For now I will force to lowercase database names (maybe excepted those not surrounded by quotes), in my applications, but don't you think this should be done in Zeos ?

If someone has a better idea, he is welcome !

By the way, I do not remember that this problem existed in Zeos 6.6.6 (if someone has still it, can he say or test ?).

Thanks for any input.
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

tintinux,
"Create database Test [...] ", a database test (in lowercase) is actually created, from ..
AFIAK you've created now an UpperCase DB: "TEST". I guess you should connect now with "TEST" not with "Test".

By the way, I do not remember that this problem existed in Zeos 6.6.6 (if someone has still it, can he say or test ?).
I don't know many things about the 6.6-series but i know we had loads of bug-report accordingly case sensitive item-names. AFAIK do we make an identifier-quoting for all properties we have. So if you connect to "TEST" it will simply fail.

Can you check my UperCased suggestions please?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
tintinux
Junior Boarder
Junior Boarder
Posts: 44
Joined: 19.05.2010, 10:39

Post by tintinux »

Hi
I guess you should connect now with "TEST" not with "Test".
No, when I use Test not surrounded with quotes the database test (lowercase) is created (according to pg documentation), but I can connect only with test (lowercase).

It looks like Postgresql convert to lowercase in a SQL instruction, but not at the API level.

I think we need a PostgresSql guru to be sure that there is nothing better to do than converting the database name to lowercase before connect.

Also, it would be interesting to know how it works with php or other languages.

Regards
Tintinux
WorldWalker
Junior Boarder
Junior Boarder
Posts: 25
Joined: 10.10.2009, 18:57

Post by WorldWalker »

tintinux,
It's not an issue it's the case sensitive mechanisme.
Regards.
tintinux
Junior Boarder
Junior Boarder
Posts: 44
Joined: 19.05.2010, 10:39

Post by tintinux »

I agree that this is not a ZeosLib bug or issue.

But it is not normal that the same given database name (Test) works in a create query and not when assigned to a TZConnection.

We must change the case before opening, since Postgres API apparently don't. Every application can do this, but I just suggest that it could be done once by ZeosLib.

Regards,
Tintinux
Post Reply