fix: the way how we test if there is a connection issue
If there is a connection issue then PQexec returns a resultset now - older versions of PostgreSQL returned null pointer.
This commit is contained in:
parent
12232bf722
commit
0ce7578de3
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2021, Tomasz Sowa
|
* Copyright (c) 2019-2022, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -97,13 +97,15 @@ bool PostgreSQLConnector::do_query(const char * query_str, PostgreSQLQueryResult
|
||||||
|
|
||||||
psql_result->psql_result = PQexec(pg_conn, query_str);
|
psql_result->psql_result = PQexec(pg_conn, query_str);
|
||||||
|
|
||||||
if( !psql_result->psql_result )
|
/*
|
||||||
|
* in older versions of PostgreSQL when there was a connection issue then the psql_result pointer would be null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if( !psql_result->psql_result || PQstatus(pg_conn) != CONNECTION_OK )
|
||||||
{
|
{
|
||||||
if( PQstatus(pg_conn) != CONNECTION_OK )
|
psql_result->clear();
|
||||||
{
|
assert_connection_is_working();
|
||||||
assert_connection_is_working();
|
psql_result->psql_result = PQexec(pg_conn, query_str);
|
||||||
psql_result->psql_result = PQexec(pg_conn, query_str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( psql_result->psql_result )
|
if( psql_result->psql_result )
|
||||||
|
|
Loading…
Reference in New Issue