Page 1 of 1

tpgconnection Unicode Problem.

Posted: Fri 02 Jan 2009 15:32
by snorkel
I have a variable like this:

dbname:= 'Россия';

I use this for the tpgconnection's database property like this:

myconnection.database:= format('"%s"',[dbname]);
//also note the connection component at this time cannot handle
//connection param names like database that have upper case chars
//hence the manual qouting using the format function.
myconnection.connnected:=true;

then the following error is raised:

First chance exception at $7D4E2366. Exception class EPgError with message 'database "??????" does not exist'. Process pg_lightning_admin.exe (3988)

UseUnicode is set to true and the database does exist, it was created like this:

create database "Россия";


I also have to mention again that the tpgconnection component has a buge because it is not qouting the connection param names, so if you create a database like this:
create database "MyDatabase";
And then do:
myconnection.database:= 'MyDatabase';
You will get this error:
First chance exception at $7D4E2366. Exception class EPgError with message 'database "mydatabase" does not exist'. Process pg_lightning_admin.exe (3988)

This happens because PGSQL lowercases everything sent to it at the server level, now if I do this:

myconnection.database:= format('"%s"',['MyDatabase']);

Then I don't get the error.

The solution is to either simply qoute all the connection names like databasename, username,password etc. The qouting overrides the server automaticly lower casing everthing, or add a option like in the query and table components to Qoute Names.

Posted: Mon 05 Jan 2009 09:20
by Plash
In the next build we will convert Database, Username, and Password to UTF8 if UseUnicode is set to True.