Merge pull request #28298 from kitaisreal/odbc-connection-holder-fix-dangling-reference

ODBC connection holder fix dangling reference
This commit is contained in:
Maksim Kita 2021-08-28 15:28:23 +03:00 committed by GitHub
commit 1a6c2c78c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@
#include <common/BorrowedObjectPool.h> #include <common/BorrowedObjectPool.h>
#include <unordered_map> #include <unordered_map>
namespace DB namespace DB
{ {
namespace ErrorCodes namespace ErrorCodes
@ -28,8 +29,8 @@ class ConnectionHolder
{ {
public: public:
ConnectionHolder(PoolPtr pool_, ConnectionHolder(PoolPtr pool_,
ConnectionPtr connection_, ConnectionPtr connection_,
const String & connection_string_) const String & connection_string_)
: pool(pool_) : pool(pool_)
, connection(std::move(connection_)) , connection(std::move(connection_))
, connection_string(connection_string_) , connection_string(connection_string_)
@ -57,7 +58,7 @@ public:
private: private:
PoolPtr pool; PoolPtr pool;
ConnectionPtr connection; ConnectionPtr connection;
const String & connection_string; String connection_string;
}; };
using ConnectionHolderPtr = std::shared_ptr<ConnectionHolder>; using ConnectionHolderPtr = std::shared_ptr<ConnectionHolder>;