From 825c8d793d6828bdb4d38ae6dea53ba1363852cf Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 12 Sep 2017 17:30:46 +0400 Subject: [PATCH] MDEV-12774 JSON_EXTRACT fails with some escaped unicode as key. Tests added. --- mysql-test/r/func_json.result | 10 ++++++++++ mysql-test/t/func_json.test | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index fc4eb16a067..5aca3c21936 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -686,3 +686,13 @@ JSON_SET('{}', '$.age', 87) SELECT JSON_MERGE('[]', '{"c":"d"}'); JSON_MERGE('[]', '{"c":"d"}') [{"c": "d"}] +SET @str = "{\"\\u00e4\\u00f6\":\"yes\"}"; +SET @path = "$.\"\\u00e4\\u00f6\""; +select @str, @path, JSON_EXTRACT(@str, @path); +@str @path JSON_EXTRACT(@str, @path) +{"\u00e4\u00f6":"yes"} $."\u00e4\u00f6" "yes" +SET @str = "{\"\\u00e4\":\"yes\"}"; +SET @path = "$.\"\\u00e4\""; +select @str, @path, JSON_EXTRACT(@str, @path); +@str @path JSON_EXTRACT(@str, @path) +{"\u00e4":"yes"} $."\u00e4" "yes" diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index 8fc1f321928..f561a2cda8f 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -338,3 +338,14 @@ SELECT JSON_SET('{}', '$.age', 87); # SELECT JSON_MERGE('[]', '{"c":"d"}'); +# +# MDEV-12774 JSON_EXTRACT fails with some escaped unicode as key. +# + +SET @str = "{\"\\u00e4\\u00f6\":\"yes\"}"; +SET @path = "$.\"\\u00e4\\u00f6\""; +select @str, @path, JSON_EXTRACT(@str, @path); +SET @str = "{\"\\u00e4\":\"yes\"}"; +SET @path = "$.\"\\u00e4\""; +select @str, @path, JSON_EXTRACT(@str, @path); +