tpgconnection Unicode Problem.

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

tpgconnection Unicode Problem.

Post by snorkel » Fri 02 Jan 2009 15:32

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.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 05 Jan 2009 09:20

In the next build we will convert Database, Username, and Password to UTF8 if UseUnicode is set to True.

Post Reply