Critical Unicode Problem in V 4.1.4 when working with Params
Posted: Fri 18 Oct 2013 11:02
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).
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.
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 "äöü"
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;