Page 1 of 1

database name case

Posted: 08.01.2013, 14:00
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.

Posted: 08.01.2013, 22:36
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?

Posted: 09.01.2013, 08:08
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

Posted: 09.01.2013, 13:57
by WorldWalker
tintinux,
It's not an issue it's the case sensitive mechanisme.
Regards.

Posted: 09.01.2013, 14:08
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