From 45e5cb77075b4d131cdaba5d028647d5220a1526 Mon Sep 17 00:00:00 2001 From: "wangyunlai.wyl" Date: Wed, 10 Aug 2022 20:40:31 +0800 Subject: [PATCH] fix defer\'s bug --- deps/common/lang/defer.h | 10 +++++++--- src/observer/sql/expr/expression.cpp | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/deps/common/lang/defer.h b/deps/common/lang/defer.h index 435df05..32578e8 100644 --- a/deps/common/lang/defer.h +++ b/deps/common/lang/defer.h @@ -21,7 +21,7 @@ namespace common { class DeferHelper { public: - DeferHelper(const std::function &defer) : defer_(defer) + DeferHelper(const std::function defer) : defer_(std::move(defer)) {} ~DeferHelper() @@ -30,9 +30,13 @@ public: } private: - const std::function &defer_; + const std::function defer_; }; } // namespace common -#define DEFER(callback) common::DeferHelper defer_helper_##__LINE__(callback) +#define AA(B, C) B##C +#define BB(B, C) AA(B,C) +#define DEFER(callback) common::DeferHelper BB(defer_helper_, __LINE__)(callback) +#undef AA +#undef BB diff --git a/src/observer/sql/expr/expression.cpp b/src/observer/sql/expr/expression.cpp index dde5bb5..ed6b450 100644 --- a/src/observer/sql/expr/expression.cpp +++ b/src/observer/sql/expr/expression.cpp @@ -23,4 +23,5 @@ RC FieldExpr::get_value(const Tuple &tuple, TupleCell &cell) const RC ValueExpr::get_value(const Tuple &tuple, TupleCell & cell) const { cell = tuple_cell_; + return RC::SUCCESS; } -- GitLab