From b91b4e0b970381603b42e52d701a4f5a176ccfd6 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 1 Dec 2022 15:04:59 +0400 Subject: MDEV-28696 View created as "select b''; " references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them --- sql/item.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index 012dcebdaee..757f09dec01 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7409,6 +7409,25 @@ Item_bin_string::Item_bin_string(THD *thd, const char *str, size_t str_length): } +void Item_bin_string::print(String *str, enum_query_type query_type) +{ + if (!str_value.length()) + { + /* + Historically a bit string such as b'01100001' + prints itself in the hex hybrid notation: 0x61 + In case of an empty bit string b'', the hex hybrid + notation would result in a bad syntax: 0x + So let's print empty bit strings using bit string notation: b'' + */ + static const LEX_CSTRING empty_bit_string= {STRING_WITH_LEN("b''")}; + str->append(empty_bit_string); + } + else + Item_hex_hybrid::print(str, query_type); +} + + bool Item_temporal_literal::eq(const Item *item, bool binary_cmp) const { return -- cgit v1.2.1