Page 1 of 1

Critical Unicode Problem in V 4.1.4 when working with Params

Posted: Fri 18 Oct 2013 11:02
by dschuch
Hy, we have some serious problems after Upgrading from 3.1.4 to 4.1.4

Can u please check out the following code, is this is working correct on your side? u need just an empty Delphi Application, Form, Button on it and paste the Following Code inside the OnClick. Perhaps u need to change Connection Parameters (esp. Port).

Code: Select all

var
    PgConnection1: TPgConnection;
    PgQuery1: TPgQuery;
begin
 PgConnection1:=TPgConnection.Create(Self);
 PgConnection1.Server:='localhost';
 PgConnection1.Port:=5433;
 PgConnection1.Username:='postgres';
 PgConnection1.Options.UseUnicode:=True;

 PgQuery1:=TPgQuery.Create(PgConnection1);
 PgQuery1.Connection:=PgConnection1;
 PgQuery1.Options.UnpreparedExecute:=True;

 PgQuery1.SQL.Text:='DROP TABLE IF EXISTS test; CREATE TABLE test (id SERIAL PRIMARY KEY, descr VARCHAR(100));';
 PgQuery1.Execute;

 PgQuery1.SQL.Text:='INSERT INTO test (descr) VALUES (''äöü'')';
 PgQuery1.Execute;

 PgQuery1.SQL.Text:='SELECT * FROM test';
 PgQuery1.Open;

 ShowMessage('this is ok: '+PgQuery1.FieldByName('descr').AsString); //result is "äöü"

 PgQuery1.Close;

 PgQuery1.SQL.Text:='DELETE FROM test';
 PgQuery1.Execute;

 PgQuery1.SQL.Text:='INSERT INTO test (descr) VALUES (:param)';
 PgQuery1.ParamByName('param').AsString:='äöü';
 PgQuery1.Execute;

 PgQuery1.SQL.Text:='SELECT * FROM test';
 PgQuery1.Open;

 ShowMessage('this is a real cirtical bug: '+PgQuery1.FieldByName('descr').AsString); //result is "äöü"
BTW: i think its a bug too, that the PGConnection implicitly uses the username as DataBaseName if no DataBase is specified (like in this test case => it connects implicit to DataBase "postgres" because of the username.

Code: Select all

-- Database: postgres

-- DROP DATABASE postgres;

CREATE DATABASE postgres
  WITH OWNER = postgres
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'German_Germany.1252'
       LC_CTYPE = 'German_Germany.1252'
       CONNECTION LIMIT = -1;

Re: Critical Unicode Problem in V 4.1.4 when working with Params

Posted: Fri 18 Oct 2013 12:13
by AlexP
Hello,

Thank you for the information, we have reproduced the problem and will try to fix it in the nearest future. For the time being, for work with unicode parameters, you should disable the UnpreparedExecute property

Re: Critical Unicode Problem in V 4.1.4 when working with Params

Posted: Tue 26 Nov 2013 11:39
by dschuch
Hey, is the problem is fixed?

Daniel

Re: Critical Unicode Problem in V 4.1.4 when working with Params

Posted: Wed 27 Nov 2013 13:13
by AlexP
Hello,

We haven't fixed this problem yet; it will be fixed in the next build.