-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
7f26499
commit fa6eaea
Showing
6 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
storage/spider/mysql-test/spider/bugfix/include/mdev_24523_deinit.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
31 changes: 31 additions & 0 deletions
31
storage/spider/mysql-test/spider/bugfix/include/mdev_24523_init.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 58 additions & 0 deletions
58
storage/spider/mysql-test/spider/bugfix/r/mdev_24523.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
!include include/default_mysqld.cnf | ||
!include ../my_1_1.cnf | ||
!include ../my_2_1.cnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |