we are checking the connection state with TUniConnection.Ping. With Unidirectional=True and Prepared=True we can't call the Ping-method because it raises an exception. The connection is not usable after the Ping call.
Here is an example to reproduce the issue:
Code: Select all
var
Connection : TUniConnection;
Query : TUniQuery;
i : integer;
begin
Connection := TUniConnection.Create(nil);
Connection.ProviderName := TPostgreSQLUniProvider.GetProviderName();
Connection.SpecificOptions.Values['CharSet'] := 'UTF8';
Connection.SpecificOptions.Values['UseUnicode'] := 'True';
Connection.SpecificOptions.Values['ProtocolVersion'] := 'pv30';
// multiconnection must be False
Connection.SpecificOptions.Values['MultipleConnections'] := 'False';
Connection.Server := 'localhost';
Connection.Database := 'XXX';
Connection.Username := 'XXX';
Connection.Password := 'XXX';
Connection.Connect;
// create temp table with records
Query := TUniQuery.Create(nil);
Query.Connection := Connection;
Query.SQL.Text := 'CREATE TEMP TABLE FOOBAR (Key INTEGER)';
Query.ExecSQL;
for i := 0 to 100 do begin
Query.SQL.Text := 'INSERT INTO FOOBAR (Key) VALUES (' + i.ToString + ')';
Query.ExecSQL;
end;
// setup unidirectional, prepared query
Query.SQL.Text := 'SELECT * FROM FOOBAR';
Query.Prepared := True;
Query.UniDirectional := True;
Query.Open;
Query.First;
Query.Close;
if Connection.Connected then
Connection.Ping; // check connection state -> raises exception
Manuel Bursch