From eeef80d09f8045d99963a2bf2fa92595c55bb26d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sat, 6 Dec 2014 20:13:38 +0300 Subject: EXPLAIN FORMAT=JSON : Fix MDEV-7266, bug in pretty-printer - Single_line_formatting_helper should not accidentally exit the DISABLED state. No JSON construct should be able to move the Single_line_formatting_helper from DISABLED state. --- sql/my_json_writer.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql/my_json_writer.cc') diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index 4f933583347..7a3dc776093 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -218,7 +218,8 @@ bool Single_line_formatting_helper::on_start_array() } else { - state= INACTIVE; + if (state != DISABLED) + state= INACTIVE; // TODO: what if we have accumulated some stuff already? shouldn't we // flush it? return false; // not handled @@ -313,6 +314,9 @@ void Single_line_formatting_helper::flush_on_one_line() void Single_line_formatting_helper::disable_and_flush() { + if (state == DISABLED) + return; + bool start_array= (state == IN_ARRAY); state= DISABLED; // deactivate ourselves and flush all accumulated calls. -- cgit v1.2.1