there is an infinite loop in TPgSQLReadStream.FetchStmt when there is an exception on reading.
You only need a postgres database with UTF8 encoding and you have to ensure that UseUnicode=False in the connection component.
Example project:
Code: Select all
try
Con := TUniConnection.Create(nil);
try
Con.Database := 'xxxx';
Con.Username := 'xxxx';
Con.Password := 'xxxx';
Con.Options.EnableBCD := True;
Con.Options.EnableFMTBCD := True;
Con.ProviderName := TPostgreSQLUniProvider.GetProviderName();
Con.SpecificOptions.Values['ProtocolVersion'] := 'pv30';
Con.SpecificOptions.Values['MultipleConnections'] := 'False';
Con.Connect;
Query := TUniQuery.Create(nil);
try
Query.Connection := Con;
Query.SQL.Text := 'CREATE TEMP TABLE xyz (dummy VARCHAR(20))';
Query.ExecSQL;
for i := 1 to 100 do begin
Query.SQL.Text := 'INSERT INTO xyz (dummy) VALUES (''test'')';
Query.ExecSQL;
end;
Query.SQL.Text := 'INSERT INTO xyz (dummy) VALUES (CONCAT(E''\u4f60'', E''\u597d'', E''\uff0c'', E''\u4e16'', E''\u754c''))';
Query.ExecSQL;
for i := 1 to 100 do begin
Query.SQL.Text := 'INSERT INTO xyz (dummy) VALUES (''test'')';
Query.ExecSQL;
end;
Query.SQL.Text := 'SELECT * FROM xyz';
Query.Open;
while not Query.Eof do begin
Writeln(Query.FieldByName('dummy').AsString);
Query.Next;
end;
finally
Query.Free();
end;
finally
Con.Free();
end;
except
on E : Exception do
Writeln(E.ClassName, ': ', E.Message);
end;