mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-24523 Execution of JSON_REPLACE failed on Spider
JSON_REPLACE() function executed with an error on Spider SE. This patch fixes the problem, and it also fixes the MDEV-24541. The problem is that Item_func_json_insert::func_name() returns the wrong function name "json_update". The Spider SE reconstructs a query based on the return value in some cases. Thus, if the return value is wrong, the Spider SE may generate a wrong query.
This commit is contained in:
@ -375,7 +375,7 @@ public:
|
|||||||
const char *func_name() const
|
const char *func_name() const
|
||||||
{
|
{
|
||||||
return mode_insert ?
|
return mode_insert ?
|
||||||
(mode_replace ? "json_set" : "json_insert") : "json_update";
|
(mode_replace ? "json_set" : "json_insert") : "json_replace";
|
||||||
}
|
}
|
||||||
Item *get_copy(THD *thd)
|
Item *get_copy(THD *thd)
|
||||||
{ return get_item_copy<Item_func_json_insert>(thd, this); }
|
{ return get_item_copy<Item_func_json_insert>(thd, this); }
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
--let $MASTER_1_COMMENT_P_2_1= $MASTER_1_COMMENT_P_2_1_BACKUP
|
||||||
|
--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP
|
||||||
|
--disable_warnings
|
||||||
|
--disable_query_log
|
||||||
|
--disable_result_log
|
||||||
|
--source ../t/test_deinit.inc
|
||||||
|
--enable_result_log
|
||||||
|
--enable_query_log
|
||||||
|
--enable_warnings
|
@ -0,0 +1,31 @@
|
|||||||
|
--disable_warnings
|
||||||
|
--disable_query_log
|
||||||
|
--disable_result_log
|
||||||
|
--source ../t/test_init.inc
|
||||||
|
--enable_result_log
|
||||||
|
--enable_query_log
|
||||||
|
--enable_warnings
|
||||||
|
--let $MASTER_1_COMMENT_P_2_1_BACKUP= $MASTER_1_COMMENT_P_2_1
|
||||||
|
let $MASTER_1_COMMENT_P_2_1=
|
||||||
|
PARTITION BY RANGE(i) (
|
||||||
|
PARTITION pt1 VALUES LESS THAN (5) COMMENT='srv "s_2_1", table "ta_r2"',
|
||||||
|
PARTITION pt2 VALUES LESS THAN (10) COMMENT='srv "s_2_1", table "ta_r3"',
|
||||||
|
PARTITION pt3 VALUES LESS THAN MAXVALUE COMMENT='srv "s_2_1", table "ta_r4"'
|
||||||
|
);
|
||||||
|
--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
|
||||||
|
let $CHILD2_1_CREATE_TABLES=
|
||||||
|
CREATE TABLE ta_r2 (
|
||||||
|
i INT,
|
||||||
|
j JSON,
|
||||||
|
PRIMARY KEY(i)
|
||||||
|
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
|
||||||
|
CREATE TABLE ta_r3 (
|
||||||
|
i INT,
|
||||||
|
j JSON,
|
||||||
|
PRIMARY KEY(i)
|
||||||
|
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
|
||||||
|
CREATE TABLE ta_r4 (
|
||||||
|
i INT,
|
||||||
|
j JSON,
|
||||||
|
PRIMARY KEY(i)
|
||||||
|
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
|
58
storage/spider/mysql-test/spider/bugfix/r/mdev_24523.result
Normal file
58
storage/spider/mysql-test/spider/bugfix/r/mdev_24523.result
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
for master_1
|
||||||
|
for child2
|
||||||
|
child2_1
|
||||||
|
child2_2
|
||||||
|
child2_3
|
||||||
|
for child3
|
||||||
|
|
||||||
|
this test is for MDEV-24523
|
||||||
|
|
||||||
|
drop and create databases
|
||||||
|
connection master_1;
|
||||||
|
CREATE DATABASE auto_test_local;
|
||||||
|
USE auto_test_local;
|
||||||
|
connection child2_1;
|
||||||
|
CREATE DATABASE auto_test_remote;
|
||||||
|
USE auto_test_remote;
|
||||||
|
|
||||||
|
create table and insert
|
||||||
|
connection child2_1;
|
||||||
|
CHILD2_1_CREATE_TABLES
|
||||||
|
connection master_1;
|
||||||
|
CREATE TABLE tbl_a (
|
||||||
|
i INT,
|
||||||
|
j JSON,
|
||||||
|
PRIMARY KEY(i)
|
||||||
|
) ENGINE=Spider PARTITION BY RANGE(i) (
|
||||||
|
PARTITION pt1 VALUES LESS THAN (5) COMMENT='srv "s_2_1", table "ta_r2"',
|
||||||
|
PARTITION pt2 VALUES LESS THAN (10) COMMENT='srv "s_2_1", table "ta_r3"',
|
||||||
|
PARTITION pt3 VALUES LESS THAN MAXVALUE COMMENT='srv "s_2_1", table "ta_r4"'
|
||||||
|
)
|
||||||
|
INSERT INTO tbl_a VALUES (1, '{ "a": 1, "b": [2, 3]}');
|
||||||
|
|
||||||
|
test 1
|
||||||
|
connection master_1;
|
||||||
|
UPDATE tbl_a SET j = JSON_REPLACE(j, '$.a', 10, '$.c', '[1, 2]');
|
||||||
|
SELECT * FROM tbl_a;
|
||||||
|
i j
|
||||||
|
1 {"a": 10, "b": [2, 3]}
|
||||||
|
TRUNCATE TABLE tbl_a;
|
||||||
|
INSERT INTO tbl_a VALUES (1, '{ "a": 1, "b": [2, 3]}');
|
||||||
|
UPDATE tbl_a SET j = JSON_REPLACE(j, '$.a', 10, '$.b', '[1, 2]');
|
||||||
|
SELECT * FROM tbl_a;
|
||||||
|
i j
|
||||||
|
1 {"a": 10, "b": "[1, 2]"}
|
||||||
|
|
||||||
|
deinit
|
||||||
|
connection master_1;
|
||||||
|
DROP DATABASE IF EXISTS auto_test_local;
|
||||||
|
connection child2_1;
|
||||||
|
DROP DATABASE IF EXISTS auto_test_remote;
|
||||||
|
for master_1
|
||||||
|
for child2
|
||||||
|
child2_1
|
||||||
|
child2_2
|
||||||
|
child2_3
|
||||||
|
for child3
|
||||||
|
|
||||||
|
end of test
|
3
storage/spider/mysql-test/spider/bugfix/t/mdev_24523.cnf
Normal file
3
storage/spider/mysql-test/spider/bugfix/t/mdev_24523.cnf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
!include include/default_mysqld.cnf
|
||||||
|
!include ../my_1_1.cnf
|
||||||
|
!include ../my_2_1.cnf
|
66
storage/spider/mysql-test/spider/bugfix/t/mdev_24523.test
Normal file
66
storage/spider/mysql-test/spider/bugfix/t/mdev_24523.test
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
--source ../include/mdev_24523_init.inc
|
||||||
|
--echo
|
||||||
|
--echo this test is for MDEV-24523
|
||||||
|
--echo
|
||||||
|
--echo drop and create databases
|
||||||
|
|
||||||
|
--connection master_1
|
||||||
|
--disable_warnings
|
||||||
|
CREATE DATABASE auto_test_local;
|
||||||
|
USE auto_test_local;
|
||||||
|
|
||||||
|
--connection child2_1
|
||||||
|
CREATE DATABASE auto_test_remote;
|
||||||
|
USE auto_test_remote;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
--echo
|
||||||
|
--echo create table and insert
|
||||||
|
|
||||||
|
--connection child2_1
|
||||||
|
--disable_query_log
|
||||||
|
--disable_ps_protocol
|
||||||
|
echo CHILD2_1_CREATE_TABLES;
|
||||||
|
eval $CHILD2_1_CREATE_TABLES;
|
||||||
|
--enable_ps_protocol
|
||||||
|
--enable_query_log
|
||||||
|
|
||||||
|
--connection master_1
|
||||||
|
--disable_query_log
|
||||||
|
echo CREATE TABLE tbl_a (
|
||||||
|
i INT,
|
||||||
|
j JSON,
|
||||||
|
PRIMARY KEY(i)
|
||||||
|
) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
|
||||||
|
eval CREATE TABLE tbl_a (
|
||||||
|
i INT,
|
||||||
|
j JSON,
|
||||||
|
PRIMARY KEY(i)
|
||||||
|
) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
|
||||||
|
--enable_query_log
|
||||||
|
INSERT INTO tbl_a VALUES (1, '{ "a": 1, "b": [2, 3]}');
|
||||||
|
|
||||||
|
--echo
|
||||||
|
--echo test 1
|
||||||
|
|
||||||
|
--connection master_1
|
||||||
|
UPDATE tbl_a SET j = JSON_REPLACE(j, '$.a', 10, '$.c', '[1, 2]');
|
||||||
|
SELECT * FROM tbl_a;
|
||||||
|
TRUNCATE TABLE tbl_a;
|
||||||
|
INSERT INTO tbl_a VALUES (1, '{ "a": 1, "b": [2, 3]}');
|
||||||
|
UPDATE tbl_a SET j = JSON_REPLACE(j, '$.a', 10, '$.b', '[1, 2]');
|
||||||
|
SELECT * FROM tbl_a;
|
||||||
|
--echo
|
||||||
|
--echo deinit
|
||||||
|
--disable_warnings
|
||||||
|
|
||||||
|
--connection master_1
|
||||||
|
DROP DATABASE IF EXISTS auto_test_local;
|
||||||
|
|
||||||
|
--connection child2_1
|
||||||
|
DROP DATABASE IF EXISTS auto_test_remote;
|
||||||
|
|
||||||
|
--enable_warnings
|
||||||
|
--source ../include/mdev_24523_deinit.inc
|
||||||
|
--echo
|
||||||
|
--echo end of test
|
Reference in New Issue
Block a user