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

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bursch
Posts: 20
Joined: Tue 25 Sep 2018 07:45

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

Post by bursch » Mon 09 May 2022 10:02

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

evgeniym
Devart Team
Posts: 103
Joined: Thu 13 May 2021 07:08

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

Post by evgeniym » Wed 11 May 2022 11:11

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

Post Reply