This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 62990d87276 [fix](json) fix parsing fails when json key string is 
empty. (#39937)
62990d87276 is described below

commit 62990d872762d2ab9f164460a8a93a5caf0d9fa7
Author: Mryange <59914473+mrya...@users.noreply.github.com>
AuthorDate: Tue Aug 27 16:58:11 2024 +0800

    [fix](json) fix parsing fails when json key string is empty. (#39937)
    
    This is a very subtle bug that can only be reproduced in a non-AVX2
    environment.
    ```
    // USE_AVX2 = false
    mysql [(none)]>mysql [(none)]>select cast('{"":1, " ":"v1"}' as json);
    +----------------------------------+
    | cast('{"":1, " ":"v1"}' as JSON) |
    +----------------------------------+
    | NULL                             |
    +----------------------------------+
    
    //USE_AVX2 = true
    mysql [(none)]>select cast('{"":1, " ":"v1"}' as json);
    +----------------------------------+
    | cast('{"":1, " ":"v1"}' as JSON) |
    +----------------------------------+
    | {"":1," ":"v1"}                  |
    +----------------------------------+
    ```
---
 be/src/util/jsonb_parser.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/be/src/util/jsonb_parser.h b/be/src/util/jsonb_parser.h
index 1591fa563c7..c90012a4fbe 100644
--- a/be/src/util/jsonb_parser.h
+++ b/be/src/util/jsonb_parser.h
@@ -369,8 +369,8 @@ private:
                 key[key_len++] = ch;
             }
         }
-
-        if (!in.good() || in.peek() != '"' || key_len == 0) {
+        // The JSON key can be an empty string.
+        if (!in.good() || in.peek() != '"') {
             if (key_len == JsonbKeyValue::sMaxKeyLen)
                 err_ = JsonbErrType::E_INVALID_KEY_LENGTH;
             else


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to