summaryrefslogtreecommitdiff
path: root/sql/item_jsonfunc.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2017-03-14 17:31:14 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2017-03-14 17:31:14 +0400
commitaf6eee1fc5c40c73edb65c08d16929ccfdc1f5f0 (patch)
treeba3597232b6c1b9f3a3c2508ff38c0cff6209c93 /sql/item_jsonfunc.cc
parentd0e8b427a1877392f3b90e00f2c7606608bac996 (diff)
downloadmariadb-git-af6eee1fc5c40c73edb65c08d16929ccfdc1f5f0.tar.gz
MDEV-11833 JSON functions don't seem to respect max_allowed_packet.
Now let's check JSON length to fit the max_allowed packet.
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r--sql/item_jsonfunc.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 7909c605136..f3090a4097f 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -1407,6 +1407,7 @@ void Item_func_json_array::fix_length_and_dec()
fix_char_length_ulonglong(char_length);
tmp_val.set_charset(collation.collation);
+ result_limit= 0;
}
@@ -1431,7 +1432,16 @@ String *Item_func_json_array::val_str(String *str)
if (str->append("]", 1))
goto err_return;
- return str;
+ if (result_limit == 0)
+ result_limit= current_thd->variables.max_allowed_packet;
+
+ if (str->length() <= result_limit)
+ return str;
+
+ push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_WARN_ALLOWED_PACKET_OVERFLOWED,
+ ER_THD(current_thd, ER_WARN_ALLOWED_PACKET_OVERFLOWED),
+ func_name(), result_limit);
err_return:
/*TODO: Launch out of memory error. */
@@ -1749,7 +1759,16 @@ String *Item_func_json_object::val_str(String *str)
if (str->append("}", 1))
goto err_return;
- return str;
+ if (result_limit == 0)
+ result_limit= current_thd->variables.max_allowed_packet;
+
+ if (str->length() <= result_limit)
+ return str;
+
+ push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_WARN_ALLOWED_PACKET_OVERFLOWED,
+ ER_THD(current_thd, ER_WARN_ALLOWED_PACKET_OVERFLOWED),
+ func_name(), result_limit);
err_return:
/*TODO: Launch out of memory error. */