mirror of
https://github.com/SOCI/soci.git
synced 2026-02-14 18:28:40 -06:00
Reuse correct connection parameters for PostgreSQL failover
If the failover callback doesn't provide the connection string to use, default to the originally used one instead of using empty connection string which is almost certainly not what we want. Note that this requires storing the original connection parameters in postgresql_session_backend, as we don't have access to the ones stored in the session object and it seems wrong to add backlinks from the backend to the session object. Closes #793.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include <soci/soci-backend.h>
|
||||
#include "soci/connection-parameters.h"
|
||||
#include <libpq-fe.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -395,6 +396,7 @@ struct postgresql_session_backend : details::session_backend
|
||||
int statementCount_;
|
||||
bool single_row_mode_;
|
||||
PGconn * conn_;
|
||||
connection_parameters connectionParameters_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -123,8 +123,11 @@ details::postgresql_result::check_for_data(char const* errMsg) const
|
||||
|
||||
if (retry)
|
||||
{
|
||||
connection_parameters parameters;
|
||||
parameters.set_connect_string(newTarget);
|
||||
connection_parameters parameters =
|
||||
sessionBackend_.connectionParameters_;
|
||||
|
||||
if (!newTarget.empty())
|
||||
parameters.set_connect_string(newTarget);
|
||||
|
||||
sessionBackend_.clean_up();
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "soci/soci-platform.h"
|
||||
#include "soci/postgresql/soci-postgresql.h"
|
||||
#include "soci/session.h"
|
||||
#include "soci/connection-parameters.h"
|
||||
#include <libpq/libpq-fs.h> // libpq
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
@@ -69,6 +68,7 @@ void postgresql_session_backend::connect(
|
||||
"Cannot set extra_float_digits parameter");
|
||||
|
||||
conn_ = conn;
|
||||
connectionParameters_ = parameters;
|
||||
}
|
||||
|
||||
postgresql_session_backend::~postgresql_session_backend()
|
||||
|
||||
Reference in New Issue
Block a user