From e0139617aa004e7d97771f9c2701ced66e3b7d9c Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 28 Jun 2026 12:04:11 +1000 Subject: [PATCH] MDEV-31554 Cursor protocol cuts off json boolean In Item_func_json_array_append::fix_length_and_dec, Item_bool::max_char_length() was being used to calculate the length that is required to fit a boolean. Previously it was returning 1, which doesn't fit "false". Change Item_bool to return strlen("false"), 5. --- mysql-test/main/func_json.test | 3 --- sql/item.h | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index f3271f6bd3fde..e3d98d7525702 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -24,10 +24,7 @@ select json_array(1); --disable_view_protocol select json_array(1, "text", false, null); -#enable after fix MDEV-31554 ---disable_cursor_protocol select json_array_append('["a", "b"]', '$', FALSE); ---enable_cursor_protocol --enable_view_protocol select json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2); select json_array_append('["a", ["b", "c"], "d"]', '$[0]', 2); diff --git a/sql/item.h b/sql/item.h index 55ff46c7af80a..7bad7801bbb41 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4631,10 +4631,10 @@ class Item_bool :public Item_int { public: Item_bool(THD *thd, const char *str_arg, longlong i): - Item_int(thd, str_arg, i, 1) {} - Item_bool(THD *thd, bool i) :Item_int(thd, (longlong) i, 1) { } + Item_int(thd, str_arg, i, 5) {} + Item_bool(THD *thd, bool i) :Item_int(thd, (longlong) i, 5) { } Item_bool(const char *str_arg, longlong i): - Item_int(str_arg, i, 1) {} + Item_int(str_arg, i, 5) {} bool is_bool_literal() const override { return true; } Item *neg_transformer(THD *thd) override; const Type_handler *type_handler() const override