allow to use host connection parameter

This commit is contained in:
2022-04-28 06:03:40 +02:00
parent ac77abb8fd
commit d384929e75
2 changed files with 43 additions and 2 deletions

View File

@@ -74,7 +74,37 @@ public:
* https://www.postgresql.org/docs/14/libpq-connect.html#LIBPQ-CONNSTRING
*/
virtual void set_conn_param(const std::wstring & database_conn_string);
virtual void set_conn_param(const std::wstring & database_hostaddr, const std::wstring & database_port, const std::wstring & database, const std::wstring & user, const std::wstring & pass);
/*
*
* database_host - name of host to connect to (can be empty)
* database_hostaddr - numeric IP address of host to connect to (can be empty)
*
*
* meaning of this parameters is the same as described in
* https://www.postgresql.org/docs/14/libpq-connect.html#LIBPQ-CONNSTRING
*
* from above documentation:
* Using hostaddr allows the application to avoid a host name look-up, which might be important
* in applications with time constraints. However, a host name is required for GSSAPI or SSPI
* authentication methods, as well as for verify-full SSL certificate verification.
* The following rules are used:
*
* - If host is specified without hostaddr, a host name lookup occurs.
*
* - If hostaddr is specified without host, the value for hostaddr gives the server network address.
* The connection attempt will fail if the authentication method requires a host name.
*
* - If both host and hostaddr are specified, the value for hostaddr gives the server network address.
* The value for host is ignored unless the authentication method requires it, in which case it will
* be used as the host name.
*
*/
virtual void set_conn_param(const std::wstring & database_host, const std::wstring & database_hostaddr, const std::wstring & database_port,
const std::wstring & database, const std::wstring & user, const std::wstring & pass);
virtual void set_conn_param(const std::wstring & database, const std::wstring & user, const std::wstring & pass);
virtual void connect();
@@ -95,6 +125,7 @@ protected:
std::string query_str;
std::wstring db_conn_string;
std::wstring db_host;
std::wstring db_hostaddr;
std::wstring db_port;
std::wstring db_database;