diff --git a/mysql-test/suite/ctc/r/ctc_cond_pushdown.result b/mysql-test/suite/ctc/r/ctc_cond_pushdown.result index 7cf7ded6177377df65e155a1fa48d9fea21b23ad..ccc56175753bb6319d834a474e44e21bf46b7e44 100644 --- a/mysql-test/suite/ctc/r/ctc_cond_pushdown.result +++ b/mysql-test/suite/ctc/r/ctc_cond_pushdown.result @@ -1812,6 +1812,26 @@ a b 2 1 select * from t16 where a = NULL; a b +select * from t16 where a is true; +a b +1 2 +2 1 +1 NULL +select * from t16 where a is NOT true; +a b +NULL NULL +NULL 1 +select * from t16 where a like 1; +a b +1 2 +1 NULL +select * from t16 where a not like 1; +a b +2 1 +select * from t16 where a like NULL; +a b +select * from t16 where a NOT like NULL; +a b select * from t16 where a + b > 1; a b 1 2 @@ -1866,28 +1886,133 @@ select * from t16 where a + (-2) >= 0; a b 2 1 create table t17 (a int, b int GENERATED ALWAYS AS (a + 1)); -insert into t17(a) values (NULL),(1),(2); +insert into t17(a) values (NULL),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10); select * from t17 where a > 1; a b 2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 select * from t17 where b > 1; a b 1 2 2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 select * from t17 where (a > 1) AND (b > 1); a b 2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 select * from t17 where (a > 1) OR (b > 1); a b 1 2 2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 select * from t17 where ((a > 1) AND (b > 1)) = 1; a b 2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 select * from t17 where ((a > 1) OR (b > 1)) = 1; a b 1 2 2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 +select * from t17 where (a < 5) AND (a > 1) AND (b > 1); +a b +2 3 +3 4 +4 5 +select * from t17 where (a < 5) AND (a > 1) OR (b > 1); +a b +1 2 +2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 +select * from t17 where (a < 5) AND ((a > 1) OR (b > 1)); +a b +1 2 +2 3 +3 4 +4 5 +select * from t17 where (a < 2) OR (a > 8) OR (b > 1); +a b +1 2 +2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 +select * from t17 where (a < 2) OR (a > 8) AND (b > 1); +a b +1 2 +9 10 +10 11 +select * from t17 where ((a < 2) OR (a > 8)) AND (b > 1); +a b +1 2 +9 10 +10 11 +select * from t17 where (a < 2) OR ((a > 8) OR (b > 1)); +a b +1 2 +2 3 +3 4 +4 5 +5 6 +6 7 +7 8 +8 9 +9 10 +10 11 CREATE TABLE t18(c1 int, c2 int, key(c1,c2)); INSERT INTO t18 VALUES (94,94),(64,64),(69,69),(97,97); select * from t18; diff --git a/mysql-test/suite/ctc/r/ctc_cond_pushdown_explain.result b/mysql-test/suite/ctc/r/ctc_cond_pushdown_explain.result index b3294218bb1a91aa1ac6090bab983869b0368927..182a8a184f3b3dac2fb3732bb2f8094461b03f04 100644 --- a/mysql-test/suite/ctc/r/ctc_cond_pushdown_explain.result +++ b/mysql-test/suite/ctc/r/ctc_cond_pushdown_explain.result @@ -1139,6 +1139,36 @@ id select_type table partitions type possible_keys key key_len ref rows filtered 1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using pushed condition (`test`.`t16`.`a` = NULL) Warnings: Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where (`test`.`t16`.`a` = NULL) +explain select * from t16 where a is true; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where ((0 <> `test`.`t16`.`a`) is true) +explain select * from t16 where a is NOT true; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where ((0 <> `test`.`t16`.`a`) is not true) +explain select * from t16 where a like 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where (`test`.`t16`.`a` like 1) +explain select * from t16 where a not like 1; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where (not((`test`.`t16`.`a` like 1))) +explain select * from t16 where a like NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where (`test`.`t16`.`a` like NULL) +explain select * from t16 where a NOT like NULL; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 66.67 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where (not((`test`.`t16`.`a` like NULL))) explain select * from t16 where a + b > 1; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using pushed condition ((`test`.`t16`.`a` + `test`.`t16`.`b`) > 1) @@ -1217,7 +1247,7 @@ id select_type table partitions type possible_keys key key_len ref rows filtered Warnings: Note 1003 /* select#1 */ select `test`.`t16`.`a` AS `a`,`test`.`t16`.`b` AS `b` from `test`.`t16` where ((`test`.`t16`.`a` + (-(2))) >= 0) create table t17 (a int, b int GENERATED ALWAYS AS (a + 1)); -insert into t17(a) values (NULL),(1),(2); +insert into t17(a) values (NULL),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10); explain select * from t17 where a > 1; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using pushed condition (`test`.`t17`.`a` > 1) @@ -1248,6 +1278,41 @@ id select_type table partitions type possible_keys key key_len ref rows filtered 1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where (((`test`.`t17`.`a` > 1) or (`test`.`t17`.`b` > 1)) = 1) +explain select * from t17 where (a < 5) AND (a > 1) AND (b > 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using pushed condition ((`test`.`t17`.`a` < 5) and (`test`.`t17`.`a` > 1)) +Warnings: +Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where ((`test`.`t17`.`a` < 5) and (`test`.`t17`.`a` > 1) and (`test`.`t17`.`b` > 1)) +explain select * from t17 where (a < 5) AND (a > 1) OR (b > 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 40.74 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where (((`test`.`t17`.`a` < 5) and (`test`.`t17`.`a` > 1)) or (`test`.`t17`.`b` > 1)) +explain select * from t17 where (a < 5) AND ((a > 1) OR (b > 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using pushed condition (`test`.`t17`.`a` < 5) +Warnings: +Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where ((`test`.`t17`.`a` < 5) and ((`test`.`t17`.`a` > 1) or (`test`.`t17`.`b` > 1))) +explain select * from t17 where (a < 2) OR (a > 8) OR (b > 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 70.37 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where ((`test`.`t17`.`a` < 2) or (`test`.`t17`.`a` > 8) or (`test`.`t17`.`b` > 1)) +explain select * from t17 where (a < 2) OR (a > 8) AND (b > 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 40.74 Using where; Using pushed condition ((`test`.`t17`.`a` < 2) or (`test`.`t17`.`a` > 8)) +Warnings: +Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where ((`test`.`t17`.`a` < 2) or ((`test`.`t17`.`a` > 8) and (`test`.`t17`.`b` > 1))) +explain select * from t17 where ((a < 2) OR (a > 8)) AND (b > 1); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using pushed condition ((`test`.`t17`.`a` < 2) or (`test`.`t17`.`a` > 8)) +Warnings: +Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where (((`test`.`t17`.`a` < 2) or (`test`.`t17`.`a` > 8)) and (`test`.`t17`.`b` > 1)) +explain select * from t17 where (a < 2) OR ((a > 8) OR (b > 1)); +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t17 NULL ALL NULL NULL NULL NULL 3 70.37 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t17`.`a` AS `a`,`test`.`t17`.`b` AS `b` from `test`.`t17` where ((`test`.`t17`.`a` < 2) or (`test`.`t17`.`a` > 8) or (`test`.`t17`.`b` > 1)) CREATE TABLE t18(c1 int, c2 int, key(c1,c2)); INSERT INTO t18 VALUES (94,94),(64,64),(69,69),(97,97); explain select * from t18; diff --git a/mysql-test/suite/ctc/t/ctc_cond_pushdown.test b/mysql-test/suite/ctc/t/ctc_cond_pushdown.test index 3daf59f54158356073d42673208f0f0887cac072..f4c93f1f2d3613a7c830203f54444939c3c05511 100644 --- a/mysql-test/suite/ctc/t/ctc_cond_pushdown.test +++ b/mysql-test/suite/ctc/t/ctc_cond_pushdown.test @@ -551,15 +551,15 @@ select * from t16 where a = 2; select * from t16 where a = NULL; ## unsupported IS / IS NOT -#select * from t16 where a is true; -#select * from t16 where a is NOT true; +select * from t16 where a is true; +select * from t16 where a is NOT true; ## unsupported LIKE / NOT -#select * from t16 where a like 1; -#select * from t16 where a not like 1; -#select * from t16 where a like NULL; -#select * from t16 where a NOT like NULL; +select * from t16 where a like 1; +select * from t16 where a not like 1; +select * from t16 where a like NULL; +select * from t16 where a NOT like NULL; select * from t16 where a + b > 1; select * from t16 where 1 < a; @@ -582,13 +582,20 @@ select * from t16 where a <=> NULL = 1; select * from t16 where a + (-2) >= 0; create table t17 (a int, b int GENERATED ALWAYS AS (a + 1)); -insert into t17(a) values (NULL),(1),(2); +insert into t17(a) values (NULL),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10); select * from t17 where a > 1; select * from t17 where b > 1; select * from t17 where (a > 1) AND (b > 1); select * from t17 where (a > 1) OR (b > 1); select * from t17 where ((a > 1) AND (b > 1)) = 1; select * from t17 where ((a > 1) OR (b > 1)) = 1; +select * from t17 where (a < 5) AND (a > 1) AND (b > 1); +select * from t17 where (a < 5) AND (a > 1) OR (b > 1); +select * from t17 where (a < 5) AND ((a > 1) OR (b > 1)); +select * from t17 where (a < 2) OR (a > 8) OR (b > 1); +select * from t17 where (a < 2) OR (a > 8) AND (b > 1); +select * from t17 where ((a < 2) OR (a > 8)) AND (b > 1); +select * from t17 where (a < 2) OR ((a > 8) OR (b > 1)); CREATE TABLE t18(c1 int, c2 int, key(c1,c2)); INSERT INTO t18 VALUES (94,94),(64,64),(69,69),(97,97); @@ -632,4 +639,4 @@ execute stmt1 using @arg2; set @arg3 = 'a'; execute stmt1 using @arg3; -drop table tb_cache; \ No newline at end of file +drop table tb_cache; diff --git a/mysql-test/suite/ctc/t/ctc_cond_pushdown_explain.test b/mysql-test/suite/ctc/t/ctc_cond_pushdown_explain.test index d82b265c7b2ff0f3ffae0489537c2eff0cad4bd0..429a4481bc8a84da7958f5243a7690494aa62554 100644 --- a/mysql-test/suite/ctc/t/ctc_cond_pushdown_explain.test +++ b/mysql-test/suite/ctc/t/ctc_cond_pushdown_explain.test @@ -341,15 +341,15 @@ explain select * from t16 where a = 2; explain select * from t16 where a = NULL; ## unsupported IS / IS NOT -#explain select * from t16 where a is true; -#explain select * from t16 where a is NOT true; +explain select * from t16 where a is true; +explain select * from t16 where a is NOT true; ## unsupported LIKE / NOT -#explain select * from t16 where a like 1; -#explain select * from t16 where a not like 1; -#explain select * from t16 where a like NULL; -#explain select * from t16 where a NOT like NULL; +explain select * from t16 where a like 1; +explain select * from t16 where a not like 1; +explain select * from t16 where a like NULL; +explain select * from t16 where a NOT like NULL; explain select * from t16 where a + b > 1; explain select * from t16 where 1 < a; @@ -372,13 +372,20 @@ explain select * from t16 where a <=> NULL = 1; explain select * from t16 where a + (-2) >= 0; create table t17 (a int, b int GENERATED ALWAYS AS (a + 1)); -insert into t17(a) values (NULL),(1),(2); +insert into t17(a) values (NULL),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10); explain select * from t17 where a > 1; explain select * from t17 where b > 1; explain select * from t17 where (a > 1) AND (b > 1); explain select * from t17 where (a > 1) OR (b > 1); explain select * from t17 where ((a > 1) AND (b > 1)) = 1; explain select * from t17 where ((a > 1) OR (b > 1)) = 1; +explain select * from t17 where (a < 5) AND (a > 1) AND (b > 1); +explain select * from t17 where (a < 5) AND (a > 1) OR (b > 1); +explain select * from t17 where (a < 5) AND ((a > 1) OR (b > 1)); +explain select * from t17 where (a < 2) OR (a > 8) OR (b > 1); +explain select * from t17 where (a < 2) OR (a > 8) AND (b > 1); +explain select * from t17 where ((a < 2) OR (a > 8)) AND (b > 1); +explain select * from t17 where (a < 2) OR ((a > 8) OR (b > 1)); CREATE TABLE t18(c1 int, c2 int, key(c1,c2)); INSERT INTO t18 VALUES (94,94),(64,64),(69,69),(97,97); @@ -408,4 +415,4 @@ execute stmt1 using @arg2; set @arg3 = 'a'; execute stmt1 using @arg3; -drop table tb_cache; \ No newline at end of file +drop table tb_cache; diff --git a/storage/ctc/CMakeLists.txt b/storage/ctc/CMakeLists.txt index 90289c4afc2588f5b88ddd95fb53a19e164135c8..6703afce555fef71afed4525fee41cd18b061cb8 100644 --- a/storage/ctc/CMakeLists.txt +++ b/storage/ctc/CMakeLists.txt @@ -68,14 +68,14 @@ IF (WITH_CANTIAN) ${CTC_SOURCES} STORAGE_ENGINE MANDATORY - LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy libcantian.so libmessage_queue.so + LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy libcantian.so ) ELSEIF (NOT WITHOUT_CTC_STORAGE_ENGINE) MYSQL_ADD_PLUGIN(ctc ${CTC_SOURCES} STORAGE_ENGINE MODULE_ONLY - LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy libcantian.so libmessage_queue.so + LINK_LIBRARIES libzecommon.so libzeclient.so libzeprotocol.so libprotobuf-c.a pcre2-8 ctc_proxy libcantian.so ) ENDIF () ELSE () diff --git a/storage/ctc/ctc_srv.h b/storage/ctc/ctc_srv.h index 6cd3b2eea57351ef3bcdf1665c98c2bc288f7b9f..9918bd9821a2a304205ead94befc0f4880a463a4 100644 --- a/storage/ctc/ctc_srv.h +++ b/storage/ctc/ctc_srv.h @@ -233,10 +233,6 @@ typedef struct { int err_code; } ctc_invalidate_broadcast_request; -typedef struct { - int result; -} mysql_init_lib_request; - typedef struct { bool is_key_null; // 该列数据是否为null uint8_t *left_key; // 指向索引查询条件的左值 @@ -348,7 +344,6 @@ enum CTC_FUNC_TYPE { CTC_FUNC_TYPE_GET_MAX_SESSIONS, CTC_FUNC_LOCK_INSTANCE, CTC_FUNC_UNLOCK_INSTANCE, - CTC_FUNC_INIT_MYSQL_LIB, CTC_FUNC_CHECK_TABLE_EXIST, CTC_FUNC_SEARCH_METADATA_SWITCH, CTC_FUNC_QUERY_SHM_USAGE, @@ -615,9 +610,6 @@ typedef struct en_ctcpart_scan_range { int srv_wait_instance_startuped(void); int ctc_alloc_inst_id(uint32_t *inst_id); int ctc_release_inst_id(uint32_t inst_id); -#ifdef WITH_CANTIAN -int init_mysql_lib(void); -#endif int ctc_open_table(ctc_handler_t *tch, const char *table_name, const char *user_name); int ctc_close_table(ctc_handler_t *tch); diff --git a/storage/ctc/ctc_util.cc b/storage/ctc/ctc_util.cc index 67368369869dbdb2104407971734d1cd14930933..a3c2c4b4dec4d5df2c1b516b2f3467d9387ee30e 100644 --- a/storage/ctc/ctc_util.cc +++ b/storage/ctc/ctc_util.cc @@ -1120,7 +1120,7 @@ void cond_push_boolean_term(Item *term, Item *&pushed_cond, Item *&remainder_con while ((operand = li++)) { Item *pushed = nullptr, *remainder = nullptr; cond_push_term(operand, pushed, remainder, cond->functype()); - if (remainder != nullptr && !is_and_condition) { + if (pushed == nullptr && !is_and_condition) { remain_all_cond_item(cond, pushed_cond, remainder_cond); return; } diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index e0844d8bdb92943ba484edbc91a508b22774365e..722771d9ad94a7b397819b2247236bc256607491 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -542,12 +542,6 @@ static int ctc_reg_instance() { CTC_START_TIMEOUT); sleep(1); } -#ifdef WITH_CANTIAN - ret = (ct_errno_t)init_mysql_lib(); - if (ret == CT_SUCCESS) { - ctc_log_system("[CTC_INIT]:ctc reg mysql proxy lib in cantian success"); - } -#endif return convert_ctc_error_code_to_mysql(ret); }