From dcf2f8d56092285381be2acbf8f04b8aeeb7ad79 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Tue, 2 Jan 2024 22:37:55 -0800 Subject: [PATCH] Add copy constructor to ColumnFamilyHandleImpl (#353) * Add copy constructor for ColumnFamilyHandleImpl Signed-off-by: Yang Zhang --- db/column_family.cc | 8 ++++++++ db/column_family.h | 1 + 2 files changed, 9 insertions(+) diff --git a/db/column_family.cc b/db/column_family.cc index df1c8434a4b..a0e66e7e5ce 100644 --- a/db/column_family.cc +++ b/db/column_family.cc @@ -50,6 +50,14 @@ ColumnFamilyHandleImpl::ColumnFamilyHandleImpl( } } +ColumnFamilyHandleImpl::ColumnFamilyHandleImpl( + const ColumnFamilyHandleImpl& other) + : cfd_(other.cfd_), db_(other.db_), mutex_(other.mutex_) { + if (cfd_ != nullptr) { + cfd_->Ref(); + } +} + ColumnFamilyHandleImpl::~ColumnFamilyHandleImpl() { if (cfd_ != nullptr) { #ifndef ROCKSDB_LITE diff --git a/db/column_family.h b/db/column_family.h index 897084477e3..1a3ca3797dd 100644 --- a/db/column_family.h +++ b/db/column_family.h @@ -162,6 +162,7 @@ class ColumnFamilyHandleImpl : public ColumnFamilyHandle { // create while holding the mutex ColumnFamilyHandleImpl( ColumnFamilyData* cfd, DBImpl* db, InstrumentedMutex* mutex); + ColumnFamilyHandleImpl(const ColumnFamilyHandleImpl& other); // destroy without mutex virtual ~ColumnFamilyHandleImpl(); virtual ColumnFamilyData* cfd() const { return cfd_; }