Replace STRTARGET macro
The macro was extremely unwieldly to update and made the addition of debug assertions harder. Rewriting it as an inline function makes this possible.
This commit is contained in:
parent
9f1619f4da
commit
2c95119a3b
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user