TPQConnection.Close(true) doesn't work if connection to server is severed
Original Reporter info from Mantis: luca @olivluca
-
Reporter name: Luca Olivetti
Original Reporter info from Mantis: luca @olivluca
- Reporter name: Luca Olivetti
Description:
With the parameter ForceClose:=true Close should ignore errors while closing the connection, but in case of a TPQConnection (postgresql server) it raises an exception so it's impossible to reopen the connection.
Steps to reproduce:
-
Create a table test in a postgresql database
create table test(c1 integer, c2 integer);
insert into test values (1,2);
insert into test values (3,4); -
In the attached lazarus project adjust the parameters of the PQConnection1 component in order to connect to the postgresql server
-
Press the BtRefresh button to refresh the table
-
stop and restart the postgresql server
-
Now pressing the BtRefresh fails (as expected)
-
The BtReconnect button should close and reopen the connection but it raises an exception instead.
Project project1 raised exception class 'EPQDatabaseError' with message:
PQConnection1: connection pointer is NULL
(PostgreSQL:)
In file 'fcl-db/src/sqldb/postgres/pqconnection.pp' ad line 725:
raise E;
Additional information:
I tested both under win32 and linux64/qt (I don't think it's relevant).
See the mailing list thread starting here:
http://lists.lazarus-ide.org/pipermail/lazarus/2018-May/234734.html
Mantis conversion info:
- Mantis ID: 33737
- Version: 3.0.4
- Fixed in version: 3.3.1
- Target version: 3.2.0