Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
MDEV-24760 SELECT..CASE statement syntax error at Spider Engine table
The root cause of the bug is in `spider_db_mbase_util::open_item_func()`. The function handles an instance of the `Item_func` class based on its `Item_func::Functype`. The `Functype` of `CASE WHEN ... THEN` is `CASE_SEARCHED_FUNC`. However, the Spider SE doesn't recognize this `Functype` because `CASE_SEARCHED_FUNC` is newly added by 4de0d92. This results in the wrong handling of `CASE WHEN ... THEN`. The above also applies to `CASE_SIMPLE_FUNC`.
- Loading branch information
1 parent
efa311a
commit cf6d83e
Showing
4 changed files
with
176 additions
and
79 deletions.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # | ||
| # MDEV-24760 SELECT..CASE statement syntax error at Spider Engine table | ||
| # | ||
| for master_1 | ||
| for child2 | ||
| child2_1 | ||
| child2_2 | ||
| child2_3 | ||
| for child3 | ||
| connection child2_1; | ||
| CREATE DATABASE auto_test_remote; | ||
| USE auto_test_remote; | ||
| DROP TABLE IF EXISTS tbl_a; | ||
| Warnings: | ||
| Note 1051 Unknown table 'auto_test_remote.tbl_a' | ||
| CREATE TABLE tbl_a ( | ||
| id int NOT NULL AUTO_INCREMENT, | ||
| name varchar(255) DEFAULT NULL, | ||
| PRIMARY KEY (id) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| INSERT INTO tbl_a (name) VALUES ('Alice'), ('Bob'); | ||
| connection master_1; | ||
| CREATE DATABASE auto_test_local; | ||
| USE auto_test_local; | ||
| CREATE TABLE tbl_a ( | ||
| id int NOT NULL AUTO_INCREMENT, | ||
| name varchar(255) DEFAULT NULL, | ||
| PRIMARY KEY (id) | ||
| ) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a"' | ||
| PARTITION BY HASH(id) ( | ||
| PARTITION pt1 COMMENT='srv "s_2_1"' | ||
| ); | ||
| SELECT id, CASE WHEN name='Alice' THEN "A" WHEN name='Bob' THEN "B" END FROM tbl_a; | ||
| id CASE WHEN name='Alice' THEN "A" WHEN name='Bob' THEN "B" END | ||
| 1 A | ||
| 2 B | ||
| SELECT id, CASE name WHEN 'Alice' THEN "A" WHEN 'Bob' THEN "B" END FROM tbl_a; | ||
| id CASE name WHEN 'Alice' THEN "A" WHEN 'Bob' THEN "B" END | ||
| 1 A | ||
| 2 B | ||
| DROP DATABASE auto_test_local; | ||
| connection child2_1; | ||
| DROP DATABASE auto_test_remote; | ||
| for master_1 | ||
| for child2 | ||
| child2_1 | ||
| child2_2 | ||
| child2_3 | ||
| for child3 |
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,49 @@ | ||
| --echo # | ||
| --echo # MDEV-24760 SELECT..CASE statement syntax error at Spider Engine table | ||
| --echo # | ||
|
|
||
| --disable_query_log | ||
| --disable_result_log | ||
| --source ../t/test_init.inc | ||
| --enable_query_log | ||
| --enable_result_log | ||
|
|
||
| --connection child2_1 | ||
| CREATE DATABASE auto_test_remote; | ||
| USE auto_test_remote; | ||
|
|
||
| DROP TABLE IF EXISTS tbl_a; | ||
| eval CREATE TABLE tbl_a ( | ||
| id int NOT NULL AUTO_INCREMENT, | ||
| name varchar(255) DEFAULT NULL, | ||
| PRIMARY KEY (id) | ||
| ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; | ||
|
|
||
| INSERT INTO tbl_a (name) VALUES ('Alice'), ('Bob'); | ||
|
|
||
| --connection master_1 | ||
| CREATE DATABASE auto_test_local; | ||
| USE auto_test_local; | ||
|
|
||
| eval CREATE TABLE tbl_a ( | ||
| id int NOT NULL AUTO_INCREMENT, | ||
| name varchar(255) DEFAULT NULL, | ||
| PRIMARY KEY (id) | ||
| ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a"' | ||
| PARTITION BY HASH(id) ( | ||
| PARTITION pt1 COMMENT='srv "s_2_1"' | ||
| ); | ||
|
|
||
| SELECT id, CASE WHEN name='Alice' THEN "A" WHEN name='Bob' THEN "B" END FROM tbl_a; | ||
| SELECT id, CASE name WHEN 'Alice' THEN "A" WHEN 'Bob' THEN "B" END FROM tbl_a; | ||
|
|
||
| DROP DATABASE auto_test_local; | ||
|
|
||
| --connection child2_1 | ||
| DROP DATABASE auto_test_remote; | ||
|
|
||
| --disable_query_log | ||
| --disable_result_log | ||
| --source ../t/test_deinit.inc | ||
| --enable_query_log | ||
| --enable_result_log |
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