diff options
author | Alexander Barkov <bar@mariadb.com> | 2022-09-28 18:49:09 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2022-09-30 11:08:49 +0400 |
commit | 1118e979c2ce7cbd05f4a33dbefcde63bb500b63 (patch) | |
tree | 7170dddb4a5ba63e748eccd917ede2532a3ce84c /sql/sql_string.h | |
parent | e3fdabd501d9b8efaf0ca65f930af438f7fe993f (diff) | |
download | mariadb-git-1118e979c2ce7cbd05f4a33dbefcde63bb500b63.tar.gz |
MDEV-29672 Add MTR tests covering key and key segment flags and types
Diffstat (limited to 'sql/sql_string.h')
-rw-r--r-- | sql/sql_string.h | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/sql/sql_string.h b/sql/sql_string.h index ff29e98bfd9..8020e3cf7b5 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -348,6 +348,7 @@ public: } void qs_append(const char *str, size_t len); void qs_append_hex(const char *str, uint32 len); + void qs_append_hex_uint32(uint32 num); void qs_append(double d); void qs_append(double *d); inline void qs_append(const char c) @@ -571,7 +572,13 @@ public: } return false; } - + bool append_hex_uint32(uint32 num) + { + if (reserve(8)) + return true; + qs_append_hex_uint32(num); + return false; + } bool append_with_step(const char *s, uint32 arg_length, uint32 step_alloc) { uint32 new_length= arg_length + str_length; @@ -916,6 +923,17 @@ public: { return append(&ls); } + bool append_name_value(const LEX_CSTRING &name, + const LEX_CSTRING &value, + uchar quot= '\0') + { + return + append(name) || + append('=') || + (quot && append(quot)) || + append(value) || + (quot && append(quot)); + } bool append(const char *s, size_t size); bool append_with_prefill(const char *s, uint32 arg_length, uint32 full_length, char fill_char); @@ -928,6 +946,37 @@ public: return append(s.str, s.length, cs); } + /* + Append a bitmask in an uint32 with a translation into a + C-style human readable representation, e.g.: + 0x05 -> "(flag04|flag01)" + + @param flags - the flags to translate + @param names - an array of flag names + @param count - the number of available elements in "names" + */ + bool append_flag32_names(uint32 flags, const char *names[], size_t count) + { + bool added= false; + if (flags && append('(')) + return true; + for (ulong i= 0; i <= 31; i++) + { + ulong bit= 31 - i; + if (flags & (1 << bit)) + { + if (added && append('|')) + return true; + if (append(bit < count ? names[bit] : "?")) + return true; + added= true; + } + } + if (flags && append(')')) + return true; + return false; + } + void strip_sp(); friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); friend int stringcmp(const String *a,const String *b); |