diff --git a/mysql-test/suite/ctc/r/ctc_datatype.result b/mysql-test/suite/ctc/r/ctc_datatype.result index 6bfeed5ff821c73b0a445ed976309d48868ada79..a9dec0243ec87a0f320b6b83ef86e934b82d34fd 100644 --- a/mysql-test/suite/ctc/r/ctc_datatype.result +++ b/mysql-test/suite/ctc/r/ctc_datatype.result @@ -370,3 +370,269 @@ IDA 10.5 20.5 drop table t1; +create table t1(int_1 tinyint not null unique, +uint_1 tinyint unsigned not null unique, +int_2 smallint not null unique, +uint_2 smallint unsigned not null unique, +int_3 mediumint not null unique, +uint_3 mediumint unsigned not null unique, +int_4 int not null unique, +uint_4 int unsigned not null unique, +int_8 bigint not null unique, +uint_8 bigint unsigned not null unique); +insert into t1 values (-128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0); +insert into t1 values ( -2, 1, -2, 1, -2, 1, -2, 1, -2, 1); +insert into t1 values ( -1, 2, -1, 2, -1, 2, -1, 2, -1, 2); +insert into t1 values ( 0, 3, 0, 3, 0, 3, 0, 3, 0, 3); +insert into t1 values ( 1, 126, 1, 32767, 65536, 8388608, 1, 2147483648, 1, 9223372036854775808); +insert into t1 values ( 2, 127, 256, 32768, 65537, 8388609, 16777215, 2147483649, 4294967296, 9223372036854775809); +insert into t1 values ( 126, 128, 32766, 65534, 8388606, 16777214, 2147483646, 4294967294, 9223372036854775806, 18446744073709551614); +insert into t1 values ( 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615); +select * from t1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +0 3 0 3 0 3 0 3 0 3 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_1 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_1 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_1 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +select * from t1 where int_1 = -1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_1 = -128; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +select * from t1 where int_1 = 127; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_1 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +select * from t1 where uint_1 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +0 3 0 3 0 3 0 3 0 3 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_1 = 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +select * from t1 where uint_1 = 127; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +select * from t1 where uint_1 = 128; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +select * from t1 where uint_1 = 255; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_2 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_2 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_2 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +select * from t1 where int_2 = -1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_2 = -32768; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +select * from t1 where int_2 = 32767; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_2 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +select * from t1 where uint_2 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +0 3 0 3 0 3 0 3 0 3 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_2 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +select * from t1 where uint_2 = 32768; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +select * from t1 where uint_2 = 65534; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +select * from t1 where uint_2 = 65535; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_3 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_3 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_3 = -8388608; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +select * from t1 where int_3 = -1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_3 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +select * from t1 where int_3 = 8388606; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +select * from t1 where int_3 = 8388607; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_3 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +select * from t1 where uint_3 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +0 3 0 3 0 3 0 3 0 3 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_3 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +select * from t1 where uint_3 = 8388607; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +select * from t1 where uint_3 = 8388608; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +select * from t1 where uint_3 = 16777214; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +select * from t1 where uint_3 = 16777215; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_4 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_4 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_4 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +select * from t1 where int_4 = -1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_4 = -2147483648; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +select * from t1 where int_4 = 2147483647; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_4 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +select * from t1 where uint_4 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +0 3 0 3 0 3 0 3 0 3 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_4 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +select * from t1 where uint_4 = 2147483648; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +select * from t1 where uint_4 = 4294967294; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +select * from t1 where uint_4 = 4294967295; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_8 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_8 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where int_8 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +select * from t1 where int_8 = -1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-1 2 -1 2 -1 2 -1 2 -1 2 +select * from t1 where int_8 = 4294967296; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +select * from t1 where int_8 = -9223372036854775808; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-128 0 -32768 0 -8388608 0 -2147483648 0 -9223372036854775808 0 +select * from t1 where int_8 = 9223372036854775807; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_8 < 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +select * from t1 where uint_8 > 0; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +-1 2 -1 2 -1 2 -1 2 -1 2 +0 3 0 3 0 3 0 3 0 3 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +2 127 256 32768 65537 8388609 16777215 2147483649 4294967296 9223372036854775809 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +select * from t1 where uint_8 = 1; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +-2 1 -2 1 -2 1 -2 1 -2 1 +select * from t1 where uint_8 = 9223372036854775808; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +1 126 1 32767 65536 8388608 1 2147483648 1 9223372036854775808 +select * from t1 where uint_8 = 18446744073709551614; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +126 128 32766 65534 8388606 16777214 2147483646 4294967294 9223372036854775806 18446744073709551614 +select * from t1 where uint_8 = 18446744073709551615; +int_1 uint_1 int_2 uint_2 int_3 uint_3 int_4 uint_4 int_8 uint_8 +127 255 32767 65535 8388607 16777215 2147483647 4294967295 9223372036854775807 18446744073709551615 +drop table t1; diff --git a/mysql-test/suite/ctc/t/ctc_datatype.test b/mysql-test/suite/ctc/t/ctc_datatype.test index f9db9d5b937e242d8ff5064e5d286c49e77abd37..8a4a321e65862145b9f5426979a55fb73b3d2735 100644 --- a/mysql-test/suite/ctc/t/ctc_datatype.test +++ b/mysql-test/suite/ctc/t/ctc_datatype.test @@ -278,3 +278,100 @@ CREATE INDEX floatIndexTest ON t1 (IDA); select * from t1 where IDA < 20.0; select * from t1 where IDA > 10.0; drop table t1; + + +create table t1(int_1 tinyint not null unique, + uint_1 tinyint unsigned not null unique, + int_2 smallint not null unique, + uint_2 smallint unsigned not null unique, + int_3 mediumint not null unique, + uint_3 mediumint unsigned not null unique, + int_4 int not null unique, + uint_4 int unsigned not null unique, + int_8 bigint not null unique, + uint_8 bigint unsigned not null unique); + +insert into t1 values (-128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0); +insert into t1 values ( -2, 1, -2, 1, -2, 1, -2, 1, -2, 1); +insert into t1 values ( -1, 2, -1, 2, -1, 2, -1, 2, -1, 2); +insert into t1 values ( 0, 3, 0, 3, 0, 3, 0, 3, 0, 3); +insert into t1 values ( 1, 126, 1, 32767, 65536, 8388608, 1, 2147483648, 1, 9223372036854775808); +insert into t1 values ( 2, 127, 256, 32768, 65537, 8388609, 16777215, 2147483649, 4294967296, 9223372036854775809); +insert into t1 values ( 126, 128, 32766, 65534, 8388606, 16777214, 2147483646, 4294967294, 9223372036854775806, 18446744073709551614); +insert into t1 values ( 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615); + +select * from t1; +select * from t1 where int_1 < 0; +select * from t1 where int_1 > 0; +select * from t1 where int_1 = 1; +select * from t1 where int_1 = -1; +select * from t1 where int_1 = -128; +select * from t1 where int_1 = 127; + +select * from t1 where uint_1 < 0; +select * from t1 where uint_1 > 0; +select * from t1 where uint_1 = 0; +select * from t1 where uint_1 = 127; +select * from t1 where uint_1 = 128; +select * from t1 where uint_1 = 255; + +select * from t1 where int_2 < 0; +select * from t1 where int_2 > 0; +select * from t1 where int_2 = 1; +select * from t1 where int_2 = -1; +select * from t1 where int_2 = -32768; +select * from t1 where int_2 = 32767; + +select * from t1 where uint_2 < 0; +select * from t1 where uint_2 > 0; +select * from t1 where uint_2 = 1; +select * from t1 where uint_2 = 32768; +select * from t1 where uint_2 = 65534; +select * from t1 where uint_2 = 65535; + +select * from t1 where int_3 < 0; +select * from t1 where int_3 > 0; +select * from t1 where int_3 = -8388608; +select * from t1 where int_3 = -1; +select * from t1 where int_3 = 1; +select * from t1 where int_3 = 8388606; +select * from t1 where int_3 = 8388607; + +select * from t1 where uint_3 < 0; +select * from t1 where uint_3 > 0; +select * from t1 where uint_3 = 1; +select * from t1 where uint_3 = 8388607; +select * from t1 where uint_3 = 8388608; +select * from t1 where uint_3 = 16777214; +select * from t1 where uint_3 = 16777215; + +select * from t1 where int_4 < 0; +select * from t1 where int_4 > 0; +select * from t1 where int_4 = 1; +select * from t1 where int_4 = -1; +select * from t1 where int_4 = -2147483648; +select * from t1 where int_4 = 2147483647; + +select * from t1 where uint_4 < 0; +select * from t1 where uint_4 > 0; +select * from t1 where uint_4 = 1; +select * from t1 where uint_4 = 2147483648; +select * from t1 where uint_4 = 4294967294; +select * from t1 where uint_4 = 4294967295; + +select * from t1 where int_8 < 0; +select * from t1 where int_8 > 0; +select * from t1 where int_8 = 1; +select * from t1 where int_8 = -1; +select * from t1 where int_8 = 4294967296; +select * from t1 where int_8 = -9223372036854775808; +select * from t1 where int_8 = 9223372036854775807; + +select * from t1 where uint_8 < 0; +select * from t1 where uint_8 > 0; +select * from t1 where uint_8 = 1; +select * from t1 where uint_8 = 9223372036854775808; +select * from t1 where uint_8 = 18446744073709551614; +select * from t1 where uint_8 = 18446744073709551615; + +drop table t1; \ No newline at end of file diff --git a/storage/ctc/datatype_cnvrt_4_index_search.cc b/storage/ctc/datatype_cnvrt_4_index_search.cc index 5d76df06e99785491786140a553153fd6e424b56..9308135051622831cc6dc519ce3816d70850d9dd 100644 --- a/storage/ctc/datatype_cnvrt_4_index_search.cc +++ b/storage/ctc/datatype_cnvrt_4_index_search.cc @@ -72,27 +72,6 @@ static void ctc_convert_mysql_key_to_cantian(KEY_PART_INFO &key_part, const uint return; } -static void ctc_index_make_up_key_length(int *key, uint8_t **origin_key, uint32_t *origin_key_len, uint32_t length) { - int tmp_key = 0; - uint8_t *tmp_key_ptr = (uint8_t *)&tmp_key; - memcpy(tmp_key_ptr, *origin_key, *origin_key_len); - - // 通过符号位补齐高位字段 - if ((*origin_key_len == 1 && (tmp_key & 0x80)) || // 1表示MYSQL_TYPE_TINY类型,0x80用于获取origin_key的符号位 - (*origin_key_len == 2 && (tmp_key & 0x8000)) || // 2表示MYSQL_TYPE_SHORT类型,0x8000用于获取origin_key的符号位 - (*origin_key_len == 3 && (tmp_key & 0x800000))) { // 3表示MMYSQL_TYPE_INT24类型,0x800000用于获取origin_key的符号位 - *key = 0xFFFFFFFF; // 将key的bit位全赋值为1 - } else { - *key = 0; - } - - memcpy(key, *origin_key, *origin_key_len); - *origin_key = reinterpret_cast(key); - *origin_key_len = length; - - return; -} - int ctc_fill_index_key_info(TABLE *table, const uchar *key, uint key_len, const key_range *end_range, index_key_info_t *index_key_info, bool index_skip_scan) { const uchar *my_key = nullptr; @@ -145,8 +124,13 @@ int ctc_convert_key_from_mysql_to_cantian(Field *field, uint8_t **mysql_ptr, dec // 针对tiny和short类型,对应到cantian是int类型,所以key length需要按照cantian大小的存储 if (mysql_info->mysql_field_type == MYSQL_TYPE_TINY || mysql_info->mysql_field_type == MYSQL_TYPE_SHORT || mysql_info->mysql_field_type == MYSQL_TYPE_INT24) { - ctc_index_make_up_key_length(reinterpret_cast(cantian_ptr), mysql_ptr, len, sizeof(int)); - + if (convert_numeric_to_cantian(mysql_info, reinterpret_cast(*mysql_ptr), + reinterpret_cast(cantian_ptr), field, len) != CT_SUCCESS) { + ctc_log_error("convert_numeric_to_cantian: convert mysql index search key failed"); + return CT_ERROR; + } + *mysql_ptr = reinterpret_cast(cantian_ptr); + *len = sizeof(int32_t); return ret; } diff --git a/storage/ctc/ha_ctc.cc b/storage/ctc/ha_ctc.cc index fdbf312deda46489c68014db11152297f4c30505..e0844d8bdb92943ba484edbc91a508b22774365e 100644 --- a/storage/ctc/ha_ctc.cc +++ b/storage/ctc/ha_ctc.cc @@ -4031,8 +4031,10 @@ void ctc_get_sample_size_value() { } int32_t ctc_get_cluster_role() { - if (ctc_cluster_role != (int32_t)dis_cluster_role::DEFAULT) { - return ctc_cluster_role; + /* Normally, the cluster type should only be PRIMARY or STANDBY */ + if (ctc_cluster_role == (int32_t)dis_cluster_role::PRIMARY || + ctc_cluster_role == (int32_t)dis_cluster_role::STANDBY) { + return ctc_cluster_role; } lock_guard lock(m_ctc_cluster_role_mutex); bool is_slave = false;