MDEV-31554 Cursor protocol cuts off json boolean#5287
Conversation
There was a problem hiding this comment.
Code Review
This pull request enables cursor protocol tests in func_json.test and increases the length parameter from 1 to 5 in one of the Item_bool constructors in sql/item.h to prevent truncation. The reviewer recommends updating the other Item_bool constructors to consistently use a length of 5 to avoid similar truncation issues when those constructors are used.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| Item_bool(THD *thd, const char *str_arg, longlong i): | ||
| Item_int(thd, str_arg, i, 1) {} | ||
| Item_int(thd, str_arg, i, 5) {} | ||
| Item_bool(THD *thd, bool i) :Item_int(thd, (longlong) i, 1) { } | ||
| Item_bool(const char *str_arg, longlong i): | ||
| Item_int(str_arg, i, 1) {} |
There was a problem hiding this comment.
The other constructors of Item_bool still initialize Item_int with a length of 1. To prevent the same truncation issue when Item_bool is instantiated using these other constructors, all of them should be updated to use a length of 5 (to fit "false").
Item_bool(THD *thd, const char *str_arg, longlong i):
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, 5) {}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.
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.