diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 0d0922b7c..ed67a60d7 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -344,8 +344,7 @@ bool RWSplitSession::route_single_stmt(GWBUF* querybuf) else { MXS_ERROR("Could not find valid server for target type %s, closing " - "connection.", - STRTARGET(route_target)); + "connection.", route_target_to_string(route_target)); } } diff --git a/server/modules/routing/readwritesplit/rwsplitsession.hh b/server/modules/routing/readwritesplit/rwsplitsession.hh index ed769b058..ddfb85a50 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.hh +++ b/server/modules/routing/readwritesplit/rwsplitsession.hh @@ -322,22 +322,35 @@ private: */ uint32_t get_internal_ps_id(RWSplitSession* rses, GWBUF* buffer); -#define STRTARGET(t) \ - (t == TARGET_ALL ? "TARGET_ALL" \ - : (t == TARGET_MASTER ? "TARGET_MASTER" \ - : (t == TARGET_SLAVE ? "TARGET_SLAVE" \ - : (t \ - == TARGET_NAMED_SERVER \ - ? "TARGET_NAMED_SERVER" \ - : (t \ - == \ - TARGET_RLAG_MAX \ - ? "TARGET_RLAG_MAX" \ - : ( \ - t \ - == \ - TARGET_UNDEFINED \ - ? \ - "TARGET_UNDEFINED" \ - : \ - "Unknown target value")))))) +static inline const char* route_target_to_string(route_target_t target) +{ + if (TARGET_IS_MASTER(target)) + { + return "TARGET_MASTER"; + } + else if (TARGET_IS_SLAVE(target)) + { + return "TARGET_SLAVE"; + } + else if (TARGET_IS_NAMED_SERVER(target)) + { + return "TARGET_NAMED_SERVER"; + } + else if (TARGET_IS_ALL(target)) + { + return "TARGET_ALL"; + } + else if (TARGET_IS_RLAG_MAX(target)) + { + return "TARGET_RLAG_MAX"; + } + else if (TARGET_IS_LAST_USED(target)) + { + return "TARGET_LAST_USED"; + } + else + { + mxb_assert(!true); + return "Unknown target value"; + } +}