Page 1 of 1

Postgres: "Unexpected server response" calling Ping (Unidirectional=True, Prepared=True)

Posted: Mon 09 May 2022 10:02
by bursch
Hello,

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
	
Best reagards,
Manuel Bursch

Re: Postgres: "Unexpected server response" calling Ping (Unidirectional=True, Prepared=True)

Posted: Wed 11 May 2022 11:11
by evgeniym
Hi Manuel!

We would like to inform you that we were able to reproduce the issue and fixed it. This fix will be added to the next build of our product and will be available to all customers.

Please note that as a temporary workaround until a new build is released, we can provide you with a nightly UniDAC assembly that includes this solution.

To create this build for you, please provide us with your license number and the IDE version you are interested in using the contact form: https://www.devart.com/company/contactform.html

Regards,
Evgeniy