diff --git a/src/modelenv.h b/src/modelenv.h index a4ca60e..3361e04 100644 --- a/src/modelenv.h +++ b/src/modelenv.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2019-2021, Tomasz Sowa + * Copyright (c) 2019-2022, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/postgresqlconnector.cpp b/src/postgresqlconnector.cpp index 0dbd6bc..a077134 100644 --- a/src/postgresqlconnector.cpp +++ b/src/postgresqlconnector.cpp @@ -97,13 +97,15 @@ bool PostgreSQLConnector::do_query(const char * query_str, PostgreSQLQueryResult 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 ) - { - assert_connection_is_working(); - psql_result->psql_result = PQexec(pg_conn, query_str); - } + psql_result->clear(); + assert_connection_is_working(); + psql_result->psql_result = PQexec(pg_conn, query_str); } if( psql_result->psql_result )