From 26f3efc83406d6397ee4e4f06c8f328ad61ddf06 Mon Sep 17 00:00:00 2001 From: hwx Date: Mon, 22 Jul 2024 16:23:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AF=B9=E6=8E=A5mysql=20bit=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql-test/enableCases.list | 1 + .../suite/tianchi/r/ctc_bit_analyze.result | 221 ++++++++++++++++++ .../suite/tianchi/t/ctc_bit_analyze.test | 124 ++++++++++ storage/tianchi/datatype_cnvrtr.cc | 8 +- storage/tianchi/datatype_cnvrtr.h | 2 +- storage/tianchi/tse_cbo.cc | 11 + 6 files changed, 362 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/tianchi/r/ctc_bit_analyze.result create mode 100644 mysql-test/suite/tianchi/t/ctc_bit_analyze.test diff --git a/mysql-test/enableCases.list b/mysql-test/enableCases.list index c76deb7..59b2b90 100644 --- a/mysql-test/enableCases.list +++ b/mysql-test/enableCases.list @@ -13,6 +13,7 @@ tianchi.ctc_read_only subselect.test #test_services ctc_datetime_analyze +ctc_bit_analyze # ------ END TEST CASES OF DML ------ # ------ TEST CASES FROM suite/engines/funcs ------ diff --git a/mysql-test/suite/tianchi/r/ctc_bit_analyze.result b/mysql-test/suite/tianchi/r/ctc_bit_analyze.result new file mode 100644 index 0000000..8701d40 --- /dev/null +++ b/mysql-test/suite/tianchi/r/ctc_bit_analyze.result @@ -0,0 +1,221 @@ +drop table if exists tbl_bit; +create table tbl_bit (a bit(4), index idx_a(a)); +insert into tbl_bit values (b'0000'), (b'0001'), (b'0010'), (b'0011'); +insert into tbl_bit values (b'0100'), (b'0101'), (b'0110'), (b'0111'); +insert into tbl_bit values (b'1000'), (b'1001'), (b'1010'), (b'1011'); +insert into tbl_bit values (b'1100'), (b'1101'), (b'1110'), (b'1111'); +analyze table tbl_bit; +Table Op Msg_type Msg_text +test.tbl_bit analyze status OK +explain select * from tbl_bit where a < b'0000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x00) +explain select * from tbl_bit where a > b'1111'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x0f) +explain select * from tbl_bit where a < b'0001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x01) +explain select * from tbl_bit where a > b'1110'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x0e) +explain select * from tbl_bit where a <= b'0001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` <= 0x01) +explain select * from tbl_bit where a >= b'1110'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` >= 0x0e) +explain select * from tbl_bit where a > b'0010' and a < b'1101'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` > 0x02) and (`test`.`tbl_bit`.`a` < 0x0d)) +explain select * from tbl_bit where a >= b'0010' and a <= b'1101'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL index idx_a idx_a 2 NULL 16 75.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` >= 0x02) and (`test`.`tbl_bit`.`a` <= 0x0d)) +drop table tbl_bit; +create table tbl_bit (a bit(15), index idx_a(a)); +insert into tbl_bit values (b'000000000000000'); +insert into tbl_bit values (b'000000000000001'); +insert into tbl_bit values (b'000000000000010'); +insert into tbl_bit values (b'000000000000100'); +insert into tbl_bit values (b'000000000001000'); +insert into tbl_bit values (b'000000000010000'); +insert into tbl_bit values (b'000000000100000'); +insert into tbl_bit values (b'000000001000000'); +insert into tbl_bit values (b'000000010000000'); +insert into tbl_bit values (b'000000100000000'); +insert into tbl_bit values (b'000001000000000'); +insert into tbl_bit values (b'000010000000000'); +insert into tbl_bit values (b'000100000000000'); +insert into tbl_bit values (b'001000000000000'); +insert into tbl_bit values (b'010000000000000'); +insert into tbl_bit values (b'100000000000000'); +analyze table tbl_bit; +Table Op Msg_type Msg_text +test.tbl_bit analyze status OK +explain select * from tbl_bit where a < b'000000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0000) +explain select * from tbl_bit where a > b'100000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x4000) +explain select * from tbl_bit where a < b'000000000000001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0001) +explain select * from tbl_bit where a > b'010000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x2000) +explain select * from tbl_bit where a <= b'000000000000001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` <= 0x0001) +explain select * from tbl_bit where a >= b'010000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` >= 0x2000) +explain select * from tbl_bit where a > b'000000000000010' and a < b'001000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 10 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` > 0x0002) and (`test`.`tbl_bit`.`a` < 0x1000)) +explain select * from tbl_bit where a >= b'000000000000010' and a <= b'001000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL index idx_a idx_a 3 NULL 16 75.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` >= 0x0002) and (`test`.`tbl_bit`.`a` <= 0x1000)) +drop table tbl_bit; +create table tbl_bit (a bit(64), index idx_a(a)); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000001'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000010'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000100'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000001000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000010000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000100000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000001000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000010000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000100000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000001000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000010000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000100000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000001000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000010000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000100000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000001000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000010000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000100000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000001000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000010000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000100000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000001000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000010000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000100000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000001000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000010000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000100000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000001000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000010000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000100000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000001000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000010000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000100000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000001000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000010000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000100000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000001000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000010000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000100000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000001000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000010000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000100000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000001000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000010000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000100000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000001000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000010000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000100000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000001000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000010000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000100000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000001000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000010000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000100000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000001000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000010000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000100000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000001000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000010000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000100000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0001000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0010000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0100000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'1000000000000000000000000000000000000000000000000000000000000000'); +analyze table tbl_bit; +Table Op Msg_type Msg_text +test.tbl_bit analyze status OK +explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0000000000000000) +explain select * from tbl_bit where a > b'1000000000000000000000000000000000000000000000000000000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x8000000000000000) +explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0000000000000001) +explain select * from tbl_bit where a > b'0100000000000000000000000000000000000000000000000000000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x4000000000000000) +explain select * from tbl_bit where a <= b'0000000000000000000000000000000000000000000000000000000000000001'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` <= 0x0000000000000001) +explain select * from tbl_bit where a >= b'0100000000000000000000000000000000000000000000000000000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 2 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` >= 0x4000000000000000) +explain select * from tbl_bit where a > b'0000000000000000000000000000000000000000000000000000000000000010' and a < b'0010000000000000000000000000000000000000000000000000000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL index idx_a idx_a 9 NULL 65 90.77 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` > 0x0000000000000002) and (`test`.`tbl_bit`.`a` < 0x2000000000000000)) +explain select * from tbl_bit where a >= b'0000000000000000000000000000000000000000000000000000000000000010' and a <= b'0010000000000000000000000000000000000000000000000000000000000000'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_bit NULL index idx_a idx_a 9 NULL 65 93.85 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` >= 0x0000000000000002) and (`test`.`tbl_bit`.`a` <= 0x2000000000000000)) +drop table tbl_bit; diff --git a/mysql-test/suite/tianchi/t/ctc_bit_analyze.test b/mysql-test/suite/tianchi/t/ctc_bit_analyze.test new file mode 100644 index 0000000..ce92e6d --- /dev/null +++ b/mysql-test/suite/tianchi/t/ctc_bit_analyze.test @@ -0,0 +1,124 @@ +--disable_warnings +drop table if exists tbl_bit; +--enable_warnings + +create table tbl_bit (a bit(4), index idx_a(a)); +insert into tbl_bit values (b'0000'), (b'0001'), (b'0010'), (b'0011'); +insert into tbl_bit values (b'0100'), (b'0101'), (b'0110'), (b'0111'); +insert into tbl_bit values (b'1000'), (b'1001'), (b'1010'), (b'1011'); +insert into tbl_bit values (b'1100'), (b'1101'), (b'1110'), (b'1111'); +analyze table tbl_bit; +explain select * from tbl_bit where a < b'0000'; +explain select * from tbl_bit where a > b'1111'; +explain select * from tbl_bit where a < b'0001'; +explain select * from tbl_bit where a > b'1110'; +explain select * from tbl_bit where a <= b'0001'; +explain select * from tbl_bit where a >= b'1110'; +explain select * from tbl_bit where a > b'0010' and a < b'1101'; +explain select * from tbl_bit where a >= b'0010' and a <= b'1101'; +drop table tbl_bit; + +create table tbl_bit (a bit(15), index idx_a(a)); +insert into tbl_bit values (b'000000000000000'); +insert into tbl_bit values (b'000000000000001'); +insert into tbl_bit values (b'000000000000010'); +insert into tbl_bit values (b'000000000000100'); +insert into tbl_bit values (b'000000000001000'); +insert into tbl_bit values (b'000000000010000'); +insert into tbl_bit values (b'000000000100000'); +insert into tbl_bit values (b'000000001000000'); +insert into tbl_bit values (b'000000010000000'); +insert into tbl_bit values (b'000000100000000'); +insert into tbl_bit values (b'000001000000000'); +insert into tbl_bit values (b'000010000000000'); +insert into tbl_bit values (b'000100000000000'); +insert into tbl_bit values (b'001000000000000'); +insert into tbl_bit values (b'010000000000000'); +insert into tbl_bit values (b'100000000000000'); +analyze table tbl_bit; +explain select * from tbl_bit where a < b'000000000000000'; +explain select * from tbl_bit where a > b'100000000000000'; +explain select * from tbl_bit where a < b'000000000000001'; +explain select * from tbl_bit where a > b'010000000000000'; +explain select * from tbl_bit where a <= b'000000000000001'; +explain select * from tbl_bit where a >= b'010000000000000'; +explain select * from tbl_bit where a > b'000000000000010' and a < b'001000000000000'; +explain select * from tbl_bit where a >= b'000000000000010' and a <= b'001000000000000'; +drop table tbl_bit; + +create table tbl_bit (a bit(64), index idx_a(a)); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000001'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000010'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000100'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000001000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000010000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000100000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000001000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000010000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000100000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000001000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000010000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000100000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000001000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000010000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000100000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000001000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000010000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000000100000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000001000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000010000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000000100000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000001000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000010000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000000100000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000001000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000010000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000000100000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000001000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000010000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000000100000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000001000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000010000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000000100000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000001000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000010000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000000100000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000001000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000010000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000000100000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000001000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000010000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000000100000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000001000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000010000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000000100000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000001000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000010000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000000100000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000001000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000010000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000000100000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000001000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000010000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000000100000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000001000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000010000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000000100000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000001000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000010000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0000100000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0001000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0010000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'0100000000000000000000000000000000000000000000000000000000000000'); +insert into tbl_bit values (b'1000000000000000000000000000000000000000000000000000000000000000'); +analyze table tbl_bit; +explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000000'; +explain select * from tbl_bit where a > b'1000000000000000000000000000000000000000000000000000000000000000'; +explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000001'; +explain select * from tbl_bit where a > b'0100000000000000000000000000000000000000000000000000000000000000'; +explain select * from tbl_bit where a <= b'0000000000000000000000000000000000000000000000000000000000000001'; +explain select * from tbl_bit where a >= b'0100000000000000000000000000000000000000000000000000000000000000'; +explain select * from tbl_bit where a > b'0000000000000000000000000000000000000000000000000000000000000010' and a < b'0010000000000000000000000000000000000000000000000000000000000000'; +explain select * from tbl_bit where a >= b'0000000000000000000000000000000000000000000000000000000000000010' and a <= b'0010000000000000000000000000000000000000000000000000000000000000'; +drop table tbl_bit; diff --git a/storage/tianchi/datatype_cnvrtr.cc b/storage/tianchi/datatype_cnvrtr.cc index 85705d9..fcf1949 100644 --- a/storage/tianchi/datatype_cnvrtr.cc +++ b/storage/tianchi/datatype_cnvrtr.cc @@ -81,7 +81,7 @@ static field_cnvrt_aux_t g_field_cnvrt_aux_array[] = { {MYSQL_TYPE_YEAR, CANTIAN_COL_BITS_8, DATETIME_DATA, TSE_DDL_TYPE_YEAR }, {MYSQL_TYPE_NEWDATE, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_NEWDATE }, {MYSQL_TYPE_VARCHAR, CANTIAN_COL_BITS_VAR, STRING_DATA, TSE_DDL_TYPE_VARCHAR }, - {MYSQL_TYPE_BIT, CANTIAN_COL_BITS_8, NUMERIC_DATA, TSE_DDL_TYPE_LONGLONG }, + {MYSQL_TYPE_BIT, CANTIAN_COL_BITS_8, NUMERIC_DATA, TSE_DDL_TYPE_BIT }, {MYSQL_TYPE_TIMESTAMP2, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_TIMESTAMP2 }, {MYSQL_TYPE_DATETIME2, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_DATETIME2 }, {MYSQL_TYPE_TIME2, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_TIME2 }, @@ -668,7 +668,7 @@ void cal_gcol_cnts_for_update(Field **field, uint column_id, uint32_t *virtual_g } } -longlong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field) +ulonglong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field) { ulonglong bits = 0; Field_bit *field = dynamic_cast(mysql_field); @@ -699,7 +699,7 @@ longlong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field) case 7: return bits | mi_uint7korr(ptr); default: - return mi_uint8korr(ptr + bytes_in_rec - sizeof(longlong)); + return mi_uint8korr(ptr + bytes_in_rec - sizeof(ulonglong)); } } @@ -775,7 +775,7 @@ int convert_numeric_to_cantian(const field_cnvrt_aux_t *mysql_info, const uchar *(double *)cantian_ptr = *(const double *)mysql_ptr; break; case MYSQL_TYPE_BIT: - *(int64_t *)cantian_ptr = bit_cnvt_mysql_cantian(mysql_ptr, mysql_field); + *(uint64_t *)cantian_ptr = bit_cnvt_mysql_cantian(mysql_ptr, mysql_field); break; case MYSQL_TYPE_LONGLONG: *(int64_t *)cantian_ptr = *(const int64_t *)mysql_ptr; diff --git a/storage/tianchi/datatype_cnvrtr.h b/storage/tianchi/datatype_cnvrtr.h index 76f4f59..1b1e5e2 100644 --- a/storage/tianchi/datatype_cnvrtr.h +++ b/storage/tianchi/datatype_cnvrtr.h @@ -65,7 +65,7 @@ typedef int64 date_t; #define VARCHAR_AS_BLOB(len) ((len) > TSE_DDL_MAX_VARCHAR_COLUMN_SIZE) #define CM_ALL_ZERO_DATETIME ((date_t)-63113904000000000LL) /* == cm_encode_date(00-00-00 00:00:00.000000) */ -longlong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field); +ulonglong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field); void bit_cnvt_cantian_mysql(const uchar *cantian_ptr, uchar *mysql_ptr, Field *mysql_field); enum enum_sql_data_types { diff --git a/storage/tianchi/tse_cbo.cc b/storage/tianchi/tse_cbo.cc index c378e6d..1de6e48 100644 --- a/storage/tianchi/tse_cbo.cc +++ b/storage/tianchi/tse_cbo.cc @@ -45,6 +45,9 @@ void r_key2variant(tse_key *rKey, KEY_PART_INFO *cur_index_part, cache_variant_t uchar tmp_ptr[TSE_BYTE_8] = {0}; const field_cnvrt_aux_t *mysql_info = get_auxiliary_for_field_convert(field, field->type()); switch(field->real_type()) { + case MYSQL_TYPE_BIT: + ret_val->v_ubigint = bit_cnvt_mysql_cantian(key, field); + break; case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -106,10 +109,18 @@ double datetime_compare(const uchar *datetime1, const uchar *datetime2) return datetime1_int - datetime2_int; } +static inline en_tse_compare_type uint64_t_compare(uint64_t a, uint64_t b) { + if (a > b) { return GREAT; } + if (a < b) { return LESS; } + return EQUAL; +} + en_tse_compare_type compare(cache_variant_t *right, cache_variant_t *left, enum_field_types field_type) { double compare_value = 0; switch(field_type) { + case MYSQL_TYPE_BIT: + return uint64_t_compare(right->v_ubigint, left->v_ubigint); case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: -- Gitee From e109b86239c5f3c99d913d816610ed368e971b7d Mon Sep 17 00:00:00 2001 From: hwx Date: Thu, 25 Jul 2024 20:16:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AF=B9=E6=8E=A5mysql=20enum=20=E5=92=8C?= =?UTF-8?q?=20set=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mysql-test/enableCases.list | 3 +- .../suite/tianchi/r/ctc_bit_analyze.result | 221 ------------------ .../suite/tianchi/r/ctc_enum_analyze.result | 40 ++++ .../suite/tianchi/r/ctc_set_analyze.result | 40 ++++ .../suite/tianchi/t/ctc_bit_analyze.test | 124 ---------- .../suite/tianchi/t/ctc_enum_analyze.test | 27 +++ .../suite/tianchi/t/ctc_set_analyze.test | 27 +++ storage/tianchi/datatype_cnvrtr.cc | 8 +- storage/tianchi/datatype_cnvrtr.h | 2 +- storage/tianchi/tse_cbo.cc | 23 +- 10 files changed, 156 insertions(+), 359 deletions(-) delete mode 100644 mysql-test/suite/tianchi/r/ctc_bit_analyze.result create mode 100644 mysql-test/suite/tianchi/r/ctc_enum_analyze.result create mode 100644 mysql-test/suite/tianchi/r/ctc_set_analyze.result delete mode 100644 mysql-test/suite/tianchi/t/ctc_bit_analyze.test create mode 100644 mysql-test/suite/tianchi/t/ctc_enum_analyze.test create mode 100644 mysql-test/suite/tianchi/t/ctc_set_analyze.test diff --git a/mysql-test/enableCases.list b/mysql-test/enableCases.list index 59b2b90..54b8b11 100644 --- a/mysql-test/enableCases.list +++ b/mysql-test/enableCases.list @@ -13,7 +13,8 @@ tianchi.ctc_read_only subselect.test #test_services ctc_datetime_analyze -ctc_bit_analyze +ctc_enum_analyze +ctc_set_analyze # ------ END TEST CASES OF DML ------ # ------ TEST CASES FROM suite/engines/funcs ------ diff --git a/mysql-test/suite/tianchi/r/ctc_bit_analyze.result b/mysql-test/suite/tianchi/r/ctc_bit_analyze.result deleted file mode 100644 index 8701d40..0000000 --- a/mysql-test/suite/tianchi/r/ctc_bit_analyze.result +++ /dev/null @@ -1,221 +0,0 @@ -drop table if exists tbl_bit; -create table tbl_bit (a bit(4), index idx_a(a)); -insert into tbl_bit values (b'0000'), (b'0001'), (b'0010'), (b'0011'); -insert into tbl_bit values (b'0100'), (b'0101'), (b'0110'), (b'0111'); -insert into tbl_bit values (b'1000'), (b'1001'), (b'1010'), (b'1011'); -insert into tbl_bit values (b'1100'), (b'1101'), (b'1110'), (b'1111'); -analyze table tbl_bit; -Table Op Msg_type Msg_text -test.tbl_bit analyze status OK -explain select * from tbl_bit where a < b'0000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x00) -explain select * from tbl_bit where a > b'1111'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x0f) -explain select * from tbl_bit where a < b'0001'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x01) -explain select * from tbl_bit where a > b'1110'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x0e) -explain select * from tbl_bit where a <= b'0001'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 2 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` <= 0x01) -explain select * from tbl_bit where a >= b'1110'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 2 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` >= 0x0e) -explain select * from tbl_bit where a > b'0010' and a < b'1101'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 2 NULL 10 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` > 0x02) and (`test`.`tbl_bit`.`a` < 0x0d)) -explain select * from tbl_bit where a >= b'0010' and a <= b'1101'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL index idx_a idx_a 2 NULL 16 75.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` >= 0x02) and (`test`.`tbl_bit`.`a` <= 0x0d)) -drop table tbl_bit; -create table tbl_bit (a bit(15), index idx_a(a)); -insert into tbl_bit values (b'000000000000000'); -insert into tbl_bit values (b'000000000000001'); -insert into tbl_bit values (b'000000000000010'); -insert into tbl_bit values (b'000000000000100'); -insert into tbl_bit values (b'000000000001000'); -insert into tbl_bit values (b'000000000010000'); -insert into tbl_bit values (b'000000000100000'); -insert into tbl_bit values (b'000000001000000'); -insert into tbl_bit values (b'000000010000000'); -insert into tbl_bit values (b'000000100000000'); -insert into tbl_bit values (b'000001000000000'); -insert into tbl_bit values (b'000010000000000'); -insert into tbl_bit values (b'000100000000000'); -insert into tbl_bit values (b'001000000000000'); -insert into tbl_bit values (b'010000000000000'); -insert into tbl_bit values (b'100000000000000'); -analyze table tbl_bit; -Table Op Msg_type Msg_text -test.tbl_bit analyze status OK -explain select * from tbl_bit where a < b'000000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0000) -explain select * from tbl_bit where a > b'100000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x4000) -explain select * from tbl_bit where a < b'000000000000001'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0001) -explain select * from tbl_bit where a > b'010000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x2000) -explain select * from tbl_bit where a <= b'000000000000001'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 2 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` <= 0x0001) -explain select * from tbl_bit where a >= b'010000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 2 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` >= 0x2000) -explain select * from tbl_bit where a > b'000000000000010' and a < b'001000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 3 NULL 10 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` > 0x0002) and (`test`.`tbl_bit`.`a` < 0x1000)) -explain select * from tbl_bit where a >= b'000000000000010' and a <= b'001000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL index idx_a idx_a 3 NULL 16 75.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` >= 0x0002) and (`test`.`tbl_bit`.`a` <= 0x1000)) -drop table tbl_bit; -create table tbl_bit (a bit(64), index idx_a(a)); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000001'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000010'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000100'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000001000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000010000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000100000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000001000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000010000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000100000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000001000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000010000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000100000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000001000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000010000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000100000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000001000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000010000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000100000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000001000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000010000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000100000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000001000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000010000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000100000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000001000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000010000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000100000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000001000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000010000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000100000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000001000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000010000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000100000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000001000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000010000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000100000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000001000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000010000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000100000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000001000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000010000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000100000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000001000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000010000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000100000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000001000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000010000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000100000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000001000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000010000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000100000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000001000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000010000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000100000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000001000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000010000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000100000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000001000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000010000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000100000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0001000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0010000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0100000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'1000000000000000000000000000000000000000000000000000000000000000'); -analyze table tbl_bit; -Table Op Msg_type Msg_text -test.tbl_bit analyze status OK -explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0000000000000000) -explain select * from tbl_bit where a > b'1000000000000000000000000000000000000000000000000000000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x8000000000000000) -explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000001'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` < 0x0000000000000001) -explain select * from tbl_bit where a > b'0100000000000000000000000000000000000000000000000000000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 1 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` > 0x4000000000000000) -explain select * from tbl_bit where a <= b'0000000000000000000000000000000000000000000000000000000000000001'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 2 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` <= 0x0000000000000001) -explain select * from tbl_bit where a >= b'0100000000000000000000000000000000000000000000000000000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL range idx_a idx_a 9 NULL 2 100.00 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where (`test`.`tbl_bit`.`a` >= 0x4000000000000000) -explain select * from tbl_bit where a > b'0000000000000000000000000000000000000000000000000000000000000010' and a < b'0010000000000000000000000000000000000000000000000000000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL index idx_a idx_a 9 NULL 65 90.77 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` > 0x0000000000000002) and (`test`.`tbl_bit`.`a` < 0x2000000000000000)) -explain select * from tbl_bit where a >= b'0000000000000000000000000000000000000000000000000000000000000010' and a <= b'0010000000000000000000000000000000000000000000000000000000000000'; -id select_type table partitions type possible_keys key key_len ref rows filtered Extra -1 SIMPLE tbl_bit NULL index idx_a idx_a 9 NULL 65 93.85 Using where; Using index -Warnings: -Note 1003 /* select#1 */ select `test`.`tbl_bit`.`a` AS `a` from `test`.`tbl_bit` where ((`test`.`tbl_bit`.`a` >= 0x0000000000000002) and (`test`.`tbl_bit`.`a` <= 0x2000000000000000)) -drop table tbl_bit; diff --git a/mysql-test/suite/tianchi/r/ctc_enum_analyze.result b/mysql-test/suite/tianchi/r/ctc_enum_analyze.result new file mode 100644 index 0000000..574ae0a --- /dev/null +++ b/mysql-test/suite/tianchi/r/ctc_enum_analyze.result @@ -0,0 +1,40 @@ +drop table if exists tbl_enum; +create table tbl_enum (a enum('参天插件','参天引擎','参天插件&参天引擎'), index idx_a(a)); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +analyze table tbl_enum; +Table Op Msg_type Msg_text +test.tbl_enum analyze status OK +analyze table tbl_enum; +Table Op Msg_type Msg_text +test.tbl_enum analyze status OK +explain select * from tbl_enum where a = '参天插件'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_enum NULL ref idx_a idx_a 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`a` AS `a` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`a` = '参天插件') +explain select * from tbl_enum where a = '参天引擎'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_enum NULL ref idx_a idx_a 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`a` AS `a` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`a` = '参天引擎') +explain select * from tbl_enum where a = '参天插件&参天引擎'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_enum NULL ref idx_a idx_a 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_enum`.`a` AS `a` from `test`.`tbl_enum` where (`test`.`tbl_enum`.`a` = '参天插件&参天引擎') +drop table tbl_enum; diff --git a/mysql-test/suite/tianchi/r/ctc_set_analyze.result b/mysql-test/suite/tianchi/r/ctc_set_analyze.result new file mode 100644 index 0000000..a037852 --- /dev/null +++ b/mysql-test/suite/tianchi/r/ctc_set_analyze.result @@ -0,0 +1,40 @@ +drop table if exists tbl_set; +create table tbl_set (a set('CanTian','Gauss100','MySQL'), index idx_a(a)); +insert into tbl_set values ('CanTian'); +insert into tbl_set values ('Gauss100'); +insert into tbl_set values ('MySQL'); +insert into tbl_set values ('CanTian,Gauss100'); +insert into tbl_set values ('CanTian,Gauss100'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +analyze table tbl_set; +Table Op Msg_type Msg_text +test.tbl_set analyze status OK +analyze table tbl_set; +Table Op Msg_type Msg_text +test.tbl_set analyze status OK +explain select * from tbl_set where a = 'CanTian,Gauss100,MySQL'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_set NULL ref idx_a idx_a 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`a` AS `a` from `test`.`tbl_set` where (`test`.`tbl_set`.`a` = 'CanTian,Gauss100,MySQL') +explain select * from tbl_set where a = 'CanTian,Gauss100'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_set NULL ref idx_a idx_a 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`a` AS `a` from `test`.`tbl_set` where (`test`.`tbl_set`.`a` = 'CanTian,Gauss100') +explain select * from tbl_set where a = 'Gauss100,MySQL'; +id select_type table partitions type possible_keys key key_len ref rows filtered Extra +1 SIMPLE tbl_set NULL ref idx_a idx_a 2 const 1 100.00 Using where; Using index +Warnings: +Note 1003 /* select#1 */ select `test`.`tbl_set`.`a` AS `a` from `test`.`tbl_set` where (`test`.`tbl_set`.`a` = 'Gauss100,MySQL') +drop table tbl_set; diff --git a/mysql-test/suite/tianchi/t/ctc_bit_analyze.test b/mysql-test/suite/tianchi/t/ctc_bit_analyze.test deleted file mode 100644 index ce92e6d..0000000 --- a/mysql-test/suite/tianchi/t/ctc_bit_analyze.test +++ /dev/null @@ -1,124 +0,0 @@ ---disable_warnings -drop table if exists tbl_bit; ---enable_warnings - -create table tbl_bit (a bit(4), index idx_a(a)); -insert into tbl_bit values (b'0000'), (b'0001'), (b'0010'), (b'0011'); -insert into tbl_bit values (b'0100'), (b'0101'), (b'0110'), (b'0111'); -insert into tbl_bit values (b'1000'), (b'1001'), (b'1010'), (b'1011'); -insert into tbl_bit values (b'1100'), (b'1101'), (b'1110'), (b'1111'); -analyze table tbl_bit; -explain select * from tbl_bit where a < b'0000'; -explain select * from tbl_bit where a > b'1111'; -explain select * from tbl_bit where a < b'0001'; -explain select * from tbl_bit where a > b'1110'; -explain select * from tbl_bit where a <= b'0001'; -explain select * from tbl_bit where a >= b'1110'; -explain select * from tbl_bit where a > b'0010' and a < b'1101'; -explain select * from tbl_bit where a >= b'0010' and a <= b'1101'; -drop table tbl_bit; - -create table tbl_bit (a bit(15), index idx_a(a)); -insert into tbl_bit values (b'000000000000000'); -insert into tbl_bit values (b'000000000000001'); -insert into tbl_bit values (b'000000000000010'); -insert into tbl_bit values (b'000000000000100'); -insert into tbl_bit values (b'000000000001000'); -insert into tbl_bit values (b'000000000010000'); -insert into tbl_bit values (b'000000000100000'); -insert into tbl_bit values (b'000000001000000'); -insert into tbl_bit values (b'000000010000000'); -insert into tbl_bit values (b'000000100000000'); -insert into tbl_bit values (b'000001000000000'); -insert into tbl_bit values (b'000010000000000'); -insert into tbl_bit values (b'000100000000000'); -insert into tbl_bit values (b'001000000000000'); -insert into tbl_bit values (b'010000000000000'); -insert into tbl_bit values (b'100000000000000'); -analyze table tbl_bit; -explain select * from tbl_bit where a < b'000000000000000'; -explain select * from tbl_bit where a > b'100000000000000'; -explain select * from tbl_bit where a < b'000000000000001'; -explain select * from tbl_bit where a > b'010000000000000'; -explain select * from tbl_bit where a <= b'000000000000001'; -explain select * from tbl_bit where a >= b'010000000000000'; -explain select * from tbl_bit where a > b'000000000000010' and a < b'001000000000000'; -explain select * from tbl_bit where a >= b'000000000000010' and a <= b'001000000000000'; -drop table tbl_bit; - -create table tbl_bit (a bit(64), index idx_a(a)); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000001'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000010'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000000100'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000001000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000010000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000000100000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000001000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000010000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000000100000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000001000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000010000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000000100000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000001000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000010000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000000100000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000001000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000010000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000000100000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000001000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000010000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000000100000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000001000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000010000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000000100000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000001000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000010000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000000100000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000001000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000010000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000000100000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000001000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000010000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000000100000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000001000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000010000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000000100000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000001000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000010000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000000100000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000001000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000010000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000000100000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000001000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000010000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000000100000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000001000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000010000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000000100000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000001000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000010000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000000100000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000001000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000010000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000000100000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000001000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000010000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000000100000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000001000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000010000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0000100000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0001000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0010000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'0100000000000000000000000000000000000000000000000000000000000000'); -insert into tbl_bit values (b'1000000000000000000000000000000000000000000000000000000000000000'); -analyze table tbl_bit; -explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000000'; -explain select * from tbl_bit where a > b'1000000000000000000000000000000000000000000000000000000000000000'; -explain select * from tbl_bit where a < b'0000000000000000000000000000000000000000000000000000000000000001'; -explain select * from tbl_bit where a > b'0100000000000000000000000000000000000000000000000000000000000000'; -explain select * from tbl_bit where a <= b'0000000000000000000000000000000000000000000000000000000000000001'; -explain select * from tbl_bit where a >= b'0100000000000000000000000000000000000000000000000000000000000000'; -explain select * from tbl_bit where a > b'0000000000000000000000000000000000000000000000000000000000000010' and a < b'0010000000000000000000000000000000000000000000000000000000000000'; -explain select * from tbl_bit where a >= b'0000000000000000000000000000000000000000000000000000000000000010' and a <= b'0010000000000000000000000000000000000000000000000000000000000000'; -drop table tbl_bit; diff --git a/mysql-test/suite/tianchi/t/ctc_enum_analyze.test b/mysql-test/suite/tianchi/t/ctc_enum_analyze.test new file mode 100644 index 0000000..b22db60 --- /dev/null +++ b/mysql-test/suite/tianchi/t/ctc_enum_analyze.test @@ -0,0 +1,27 @@ +--disable_warnings +drop table if exists tbl_enum; +--enable_warnings + +create table tbl_enum (a enum('参天插件','参天引擎','参天插件&参天引擎'), index idx_a(a)); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +analyze table tbl_enum; +analyze table tbl_enum; +explain select * from tbl_enum where a = '参天插件'; +explain select * from tbl_enum where a = '参天引擎'; +explain select * from tbl_enum where a = '参天插件&参天引擎'; +drop table tbl_enum; \ No newline at end of file diff --git a/mysql-test/suite/tianchi/t/ctc_set_analyze.test b/mysql-test/suite/tianchi/t/ctc_set_analyze.test new file mode 100644 index 0000000..95f1af6 --- /dev/null +++ b/mysql-test/suite/tianchi/t/ctc_set_analyze.test @@ -0,0 +1,27 @@ +--disable_warnings +drop table if exists tbl_set; +--enable_warnings + +create table tbl_set (a set('CanTian','Gauss100','MySQL'), index idx_a(a)); +insert into tbl_set values ('CanTian'); +insert into tbl_set values ('Gauss100'); +insert into tbl_set values ('MySQL'); +insert into tbl_set values ('CanTian,Gauss100'); +insert into tbl_set values ('CanTian,Gauss100'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +analyze table tbl_set; +analyze table tbl_set; +explain select * from tbl_set where a = 'CanTian,Gauss100,MySQL'; +explain select * from tbl_set where a = 'CanTian,Gauss100'; +explain select * from tbl_set where a = 'Gauss100,MySQL'; +drop table tbl_set; diff --git a/storage/tianchi/datatype_cnvrtr.cc b/storage/tianchi/datatype_cnvrtr.cc index fcf1949..85705d9 100644 --- a/storage/tianchi/datatype_cnvrtr.cc +++ b/storage/tianchi/datatype_cnvrtr.cc @@ -81,7 +81,7 @@ static field_cnvrt_aux_t g_field_cnvrt_aux_array[] = { {MYSQL_TYPE_YEAR, CANTIAN_COL_BITS_8, DATETIME_DATA, TSE_DDL_TYPE_YEAR }, {MYSQL_TYPE_NEWDATE, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_NEWDATE }, {MYSQL_TYPE_VARCHAR, CANTIAN_COL_BITS_VAR, STRING_DATA, TSE_DDL_TYPE_VARCHAR }, - {MYSQL_TYPE_BIT, CANTIAN_COL_BITS_8, NUMERIC_DATA, TSE_DDL_TYPE_BIT }, + {MYSQL_TYPE_BIT, CANTIAN_COL_BITS_8, NUMERIC_DATA, TSE_DDL_TYPE_LONGLONG }, {MYSQL_TYPE_TIMESTAMP2, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_TIMESTAMP2 }, {MYSQL_TYPE_DATETIME2, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_DATETIME2 }, {MYSQL_TYPE_TIME2, CANTIAN_COL_BITS_NULL, UNKNOW_DATA, TSE_DDL_TYPE_TIME2 }, @@ -668,7 +668,7 @@ void cal_gcol_cnts_for_update(Field **field, uint column_id, uint32_t *virtual_g } } -ulonglong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field) +longlong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field) { ulonglong bits = 0; Field_bit *field = dynamic_cast(mysql_field); @@ -699,7 +699,7 @@ ulonglong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field) case 7: return bits | mi_uint7korr(ptr); default: - return mi_uint8korr(ptr + bytes_in_rec - sizeof(ulonglong)); + return mi_uint8korr(ptr + bytes_in_rec - sizeof(longlong)); } } @@ -775,7 +775,7 @@ int convert_numeric_to_cantian(const field_cnvrt_aux_t *mysql_info, const uchar *(double *)cantian_ptr = *(const double *)mysql_ptr; break; case MYSQL_TYPE_BIT: - *(uint64_t *)cantian_ptr = bit_cnvt_mysql_cantian(mysql_ptr, mysql_field); + *(int64_t *)cantian_ptr = bit_cnvt_mysql_cantian(mysql_ptr, mysql_field); break; case MYSQL_TYPE_LONGLONG: *(int64_t *)cantian_ptr = *(const int64_t *)mysql_ptr; diff --git a/storage/tianchi/datatype_cnvrtr.h b/storage/tianchi/datatype_cnvrtr.h index 1b1e5e2..76f4f59 100644 --- a/storage/tianchi/datatype_cnvrtr.h +++ b/storage/tianchi/datatype_cnvrtr.h @@ -65,7 +65,7 @@ typedef int64 date_t; #define VARCHAR_AS_BLOB(len) ((len) > TSE_DDL_MAX_VARCHAR_COLUMN_SIZE) #define CM_ALL_ZERO_DATETIME ((date_t)-63113904000000000LL) /* == cm_encode_date(00-00-00 00:00:00.000000) */ -ulonglong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field); +longlong bit_cnvt_mysql_cantian(const uchar *ptr, Field *mysql_field); void bit_cnvt_cantian_mysql(const uchar *cantian_ptr, uchar *mysql_ptr, Field *mysql_field); enum enum_sql_data_types { diff --git a/storage/tianchi/tse_cbo.cc b/storage/tianchi/tse_cbo.cc index 1de6e48..31c39c9 100644 --- a/storage/tianchi/tse_cbo.cc +++ b/storage/tianchi/tse_cbo.cc @@ -45,6 +45,14 @@ void r_key2variant(tse_key *rKey, KEY_PART_INFO *cur_index_part, cache_variant_t uchar tmp_ptr[TSE_BYTE_8] = {0}; const field_cnvrt_aux_t *mysql_info = get_auxiliary_for_field_convert(field, field->type()); switch(field->real_type()) { + case MYSQL_TYPE_SET: + case MYSQL_TYPE_ENUM: + if (field->pack_length() <= 4) { + ret_val->v_int = *(int32_t *)const_cast(key); + } else { + ret_val->v_bigint = *(int64_t *)const_cast(key); + } + break; case MYSQL_TYPE_BIT: ret_val->v_ubigint = bit_cnvt_mysql_cantian(key, field); break; @@ -109,18 +117,10 @@ double datetime_compare(const uchar *datetime1, const uchar *datetime2) return datetime1_int - datetime2_int; } -static inline en_tse_compare_type uint64_t_compare(uint64_t a, uint64_t b) { - if (a > b) { return GREAT; } - if (a < b) { return LESS; } - return EQUAL; -} - en_tse_compare_type compare(cache_variant_t *right, cache_variant_t *left, enum_field_types field_type) { double compare_value = 0; switch(field_type) { - case MYSQL_TYPE_BIT: - return uint64_t_compare(right->v_ubigint, left->v_ubigint); case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -479,6 +479,13 @@ double calc_density_by_cond(tse_cbo_stats_table_t *cbo_stats, KEY_PART_INFO cur_ r_key2variant(min_key, &cur_index_part, &min_key_val, low_val, key_offset); r_key2variant(max_key, &cur_index_part, &max_key_val, high_val, key_offset); enum_field_types field_type = cur_index_part.field->real_type(); + if (field_type == MYSQL_TYPE_ENUM || field_type == MYSQL_TYPE_SET) { + if (cur_index_part.field->pack_length() <= 4) { + field_type = MYSQL_TYPE_LONG; + } else { + field_type = MYSQL_TYPE_LONGLONG; + } + } if (compare(&max_key_val, low_val, field_type) == LESS || compare(&min_key_val, high_val, field_type) == GREAT) { return 0; } -- Gitee From 6369930674962dc7b9dc55c033eeab6d4eda334a Mon Sep 17 00:00:00 2001 From: hwx Date: Thu, 1 Aug 2024 09:39:30 +0800 Subject: [PATCH 3/3] enum && set --- .../suite/tianchi/t/ctc_enum_analyze.test | 18 ++++++++++++++++++ .../suite/tianchi/t/ctc_set_analyze.test | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/mysql-test/suite/tianchi/t/ctc_enum_analyze.test b/mysql-test/suite/tianchi/t/ctc_enum_analyze.test index b22db60..c4efadf 100644 --- a/mysql-test/suite/tianchi/t/ctc_enum_analyze.test +++ b/mysql-test/suite/tianchi/t/ctc_enum_analyze.test @@ -20,6 +20,24 @@ insert into tbl_enum values ('参天插件&参天引擎'); insert into tbl_enum values ('参天插件&参天引擎'); insert into tbl_enum values ('参天插件&参天引擎'); analyze table tbl_enum; +drop table tbl_enum; +create table tbl_enum (a enum('参天插件','参天引擎','参天插件&参天引擎'), index idx_a(a)); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天插件'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); +insert into tbl_enum values ('参天插件&参天引擎'); analyze table tbl_enum; explain select * from tbl_enum where a = '参天插件'; explain select * from tbl_enum where a = '参天引擎'; diff --git a/mysql-test/suite/tianchi/t/ctc_set_analyze.test b/mysql-test/suite/tianchi/t/ctc_set_analyze.test index 95f1af6..c467f80 100644 --- a/mysql-test/suite/tianchi/t/ctc_set_analyze.test +++ b/mysql-test/suite/tianchi/t/ctc_set_analyze.test @@ -20,6 +20,24 @@ insert into tbl_set values ('Gauss100,MySQL'); insert into tbl_set values ('Gauss100,MySQL'); insert into tbl_set values ('Gauss100,MySQL'); analyze table tbl_set; +drop table tbl_set; +create table tbl_set (a set('CanTian','Gauss100','MySQL'), index idx_a(a)); +insert into tbl_set values ('CanTian'); +insert into tbl_set values ('Gauss100'); +insert into tbl_set values ('MySQL'); +insert into tbl_set values ('CanTian,Gauss100'); +insert into tbl_set values ('CanTian,Gauss100'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('CanTian,Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); +insert into tbl_set values ('Gauss100,MySQL'); analyze table tbl_set; explain select * from tbl_set where a = 'CanTian,Gauss100,MySQL'; explain select * from tbl_set where a = 'CanTian,Gauss100'; -- Gitee