summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2022-08-15 10:11:23 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2022-08-15 10:11:23 +0200
commit8c21dc52ee4154e6326221752d70bbc309266861 (patch)
treecf7298fd50f0d2c4a17272cf550c67b09223d82d
parentfaddcf3c395da640b760c3f701f5bc1f3baae6c4 (diff)
parent6d90d2ba7f86bf95823f74ca2da433193ae84b25 (diff)
downloadmariadb-git-8c21dc52ee4154e6326221752d70bbc309266861.tar.gz
Merge branch '10.3' into bb-10.3-release
-rw-r--r--VERSION2
-rw-r--r--cmake/os/Darwin.cmake16
-rw-r--r--mysql-test/main/func_json.result27
-rw-r--r--mysql-test/main/func_json.test19
-rw-r--r--sql/item_jsonfunc.cc7
5 files changed, 53 insertions, 18 deletions
diff --git a/VERSION b/VERSION
index b229b7f95f7..92848892dc8 100644
--- a/VERSION
+++ b/VERSION
@@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=10
MYSQL_VERSION_MINOR=3
-MYSQL_VERSION_PATCH=36
+MYSQL_VERSION_PATCH=37
SERVER_MATURITY=stable
diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake
deleted file mode 100644
index 21e18360dfe..00000000000
--- a/cmake/os/Darwin.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
-
-# This file includes OSX specific options and quirks, related to system checks
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result
index 48ce7ed1b3f..4d04871c806 100644
--- a/mysql-test/main/func_json.result
+++ b/mysql-test/main/func_json.result
@@ -1016,5 +1016,32 @@ j
{"ID": "4", "Name": "Betty", "Age": 19}
drop table t1;
#
+# MDEV-27151: JSON_VALUE() does not parse NULL properties properly
+#
+#
+# It is correct for JSON_EXTRACT() to give null instead of "NULL" because
+# it returns the json literal that is put inside json.
+# Hence it should return null as in 'null' string and not SQL NULL.
+# JSON_VALUE() returns the "VALUE" so it is correct for it to return SQl NULL
+#
+SELECT NULL;
+NULL
+NULL
+SELECT JSON_VALUE('{"nulltest": null}', '$.nulltest');
+JSON_VALUE('{"nulltest": null}', '$.nulltest')
+NULL
+SELECT 1 + NULL;
+1 + NULL
+NULL
+SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest');
+1 + JSON_VALUE('{"nulltest": null}', '$.nulltest')
+NULL
+SELECT NULL;
+NULL
+NULL
+SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a');
+JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a')
+null
+#
# End of 10.3 tests
#
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test
index 9a063adc2cb..33e67d35f86 100644
--- a/mysql-test/main/func_json.test
+++ b/mysql-test/main/func_json.test
@@ -628,5 +628,24 @@ SELECT * FROM t1 WHERE JSON_EXTRACT(j, '$.Age')=19;
drop table t1;
--echo #
+--echo # MDEV-27151: JSON_VALUE() does not parse NULL properties properly
+--echo #
+--echo #
+--echo # It is correct for JSON_EXTRACT() to give null instead of "NULL" because
+--echo # it returns the json literal that is put inside json.
+--echo # Hence it should return null as in 'null' string and not SQL NULL.
+--echo # JSON_VALUE() returns the "VALUE" so it is correct for it to return SQl NULL
+--echo #
+
+SELECT NULL;
+SELECT JSON_VALUE('{"nulltest": null}', '$.nulltest');
+SELECT 1 + NULL;
+SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest');
+
+
+SELECT NULL;
+SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a');
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 011cfdc8fd0..abbff8c3e92 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -619,6 +619,12 @@ continue_search:
if (json_read_value(&je))
goto err_return;
+ if (je.value_type == JSON_VALUE_NULL)
+ {
+ null_value= 1;
+ return NULL;
+ }
+
if (unlikely(check_and_get_value(&je, str, &error)))
{
if (error)
@@ -1111,7 +1117,6 @@ my_decimal *Item_func_json_extract::val_decimal(my_decimal *to)
case JSON_VALUE_OBJECT:
case JSON_VALUE_ARRAY:
case JSON_VALUE_FALSE:
- // TODO: fix: NULL should be NULL
case JSON_VALUE_NULL:
int2my_decimal(E_DEC_FATAL_ERROR, 0, false/*unsigned_flag*/, to);
return to;