Skip to content

Commit

Permalink
fix returned value type for empty json objects
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Okoko <okokomichaels@outlook.com>
  • Loading branch information
idoqo authored and spetrunia committed Jan 19, 2022
1 parent 69f24c2 commit c605285
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mysql-test/main/statistics_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ERROR HY000: Failed to parse histogram, encountered JSON_TYPE '1'.
UPDATE mysql.column_stats SET histogram='{}' WHERE table_name='t1';
FLUSH TABLES;
SELECT * FROM t1;
ERROR HY000: Failed to parse histogram, encountered JSON_TYPE '32641'.
ERROR HY000: Failed to parse histogram, encountered JSON_TYPE '1'.
DELETE FROM mysql.column_stats;
DROP TABLE t1;
create schema world;
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1993,11 +1993,10 @@ bool json_get_array_items(const char *json, const char *json_end, int *value_typ

json_scan_start(&je, &my_charset_utf8mb4_bin, (const uchar *)json, (const uchar *)json_end);

if (json_read_value(&je) || je.value_type != JSON_VALUE_ARRAY)
if (json_read_value(&je) || (*value_type = je.value_type) != JSON_VALUE_ARRAY)
{
return false;
}
*value_type = je.value_type;

std::string val;
while(!json_scan_next(&je))
Expand Down

0 comments on commit c605285

Please sign in to comment.