Fix div expr precision deducing is not idempotent

This commit is contained in:
hezuojiao
2024-03-13 08:12:22 +00:00
committed by ob-robot
parent 17f7a2f819
commit a88b712c55
4 changed files with 116 additions and 0 deletions

View File

@ -1,4 +1,5 @@
drop table if exists div_sb;
drop table if exists table1000_key_pk_parts_2;
create table div_sb(c1 int,c2 int(255) zerofill,c3 bigint,c4 bigint unsigned,c5 bigint(255) zerofill,c6 decimal,c7 decimal(35, 15),c8 decimal(35, 7) zerofill,c9 varchar(123) collate utf8mb4_general_ci,c10 date,c11 datetime(5),c12 timestamp(5),c13 year(4),c14 char(24),c15 binary(24),c16 varchar(123) collate utf8mb4_bin);
set @tmp_sql_mode = @@sql_mode;
set @@sql_mode = '';
@ -198537,3 +198538,94 @@ select (18446744073709551615 div 18446744073709551615) from div_sb;
1
1
drop table div_sb;
CREATE TABLE `table1000_key_pk_parts_2` (
`col_bigint` bigint(20) DEFAULT NULL,
`col_timestamp` timestamp NULL DEFAULT NULL,
`col_decimal_20_0` decimal(20,0) DEFAULT NULL,
`col_varchar_20` varchar(20) DEFAULT NULL,
`col_double` double DEFAULT NULL,
`pk` int(11) DEFAULT NULL,
KEY `in_expr_idx22` (`col_timestamp`) BLOCK_SIZE 16384 LOCAL
) partition by key(pk) (partition `p0`, partition `p1`);
INSERT INTO `table1000_key_pk_parts_2` VALUES (NULL,NULL,NULL,'g',0,0),(-28,NULL,-15,'deymectqhjvkffumhd',0,NULL),(NULL,'2005-12-10 12:25:37',0,'o',0,7),(-94,NULL,24,'p',-85,0),(-17364,'2000-09-09 14:51:21',0,'b',0,-28),(NULL,NULL,-18404,'english',0,-85),(6109695844481499136,'2005-01-24 20:03:07',-8330,'xodeymec',0,0),(-115,'2001-11-06 06:51:25',NULL,'q',0,-96),(0,'2000-02-10 08:39:54',-1781,'',-11995,0),(-681169443639787520,'2007-02-07 01:00:10',27309,'english',0,54),(NULL,NULL,-62,'english',3,NULL),(7,'2000-05-06 14:11:51',26954,'english',109,-378667008),(4,'2007-10-08 20:32:29',0,NULL,10456,1967783936),(0,NULL,0,'',0,0);
explain SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > ALL (VALUES ROW((SELECT Floor(-360448000 / 1458241536) FROM dual)));
Query Plan
===================================================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-----------------------------------------------------------------------------------
|0 |SCALAR GROUP BY | |1 |6 |
|1 |└─PX COORDINATOR | |1 |6 |
|2 | └─EXCHANGE OUT DISTR |:EX10000 |1 |6 |
|3 | └─MERGE GROUP BY | |1 |6 |
|4 | └─NESTED-LOOP ANTI JOIN | |14 |5 |
|5 | ├─PX PARTITION ITERATOR| |14 |5 |
|6 | │ └─TABLE FULL SCAN |table1000_key_pk_parts_2|14 |5 |
|7 | └─MATERIAL | |1 |1 |
|8 | └─SUBPLAN SCAN |VIEW2 |1 |1 |
|9 | └─SUBPLAN FILTER | |1 |1 |
|10| ├─EXPRESSION |VALUES_TABLE1 |1 |1 |
|11| └─EXPRESSION | |1 |1 |
===================================================================================
Outputs & filters:
-------------------------------------
0 - output([T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil), rowset=16
group(nil), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT(*))])
1 - output([T_FUN_COUNT(*)]), filter(nil), rowset=16
2 - output([T_FUN_COUNT(*)]), filter(nil), rowset=16
dop=1
3 - output([T_FUN_COUNT(*)]), filter(nil), rowset=16
group(nil), agg_func([T_FUN_COUNT(*)])
4 - output(nil), filter(nil), rowset=16
conds([(T_OP_OR, table1000_key_pk_parts_2.col_double <= VIEW2.column_0, table1000_key_pk_parts_2.col_double IS NULL, VIEW2.column_0 IS NULL)]), nl_params_(nil),
use_batch=false
5 - output([table1000_key_pk_parts_2.col_double]), filter(nil), rowset=16
force partition granule
6 - output([table1000_key_pk_parts_2.col_double]), filter(nil), rowset=16
access([table1000_key_pk_parts_2.col_double]), partitions(p[0-1])
is_index_back=false, is_global_index=false,
range_key([table1000_key_pk_parts_2.__pk_increment]), range(MIN ; MAX)always true
7 - output([VIEW2.column_0]), filter(nil), rowset=16
8 - output([VIEW2.column_0]), filter(nil), rowset=16
access([VIEW2.column_0])
9 - output([cast(VALUES_TABLE1.column_0, DOUBLE(-1, -1))]), filter(nil), rowset=16
exec_params_(nil), onetime_exprs_([subquery(1)(:1)]), init_plan_idxs_(nil), use_batch=false
10 - output([VALUES_TABLE1.column_0]), filter(nil)
values({:1})
11 - output([Floor(cast(-360448000, DECIMAL(20, 0)) / cast(1458241536, DECIMAL(20, 0)))]), filter(nil)
values({Floor(cast(-360448000, DECIMAL(20, 0)) / cast(1458241536, DECIMAL(20, 0)))})
SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > ALL (VALUES ROW((SELECT Floor(-360448000 / 1458241536) FROM dual)));
count(*)
12
explain SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > Floor(-360448000 / 1458241536);
Query Plan
=================================================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
---------------------------------------------------------------------------------
|0 |SCALAR GROUP BY | |1 |6 |
|1 |└─PX COORDINATOR | |1 |6 |
|2 | └─EXCHANGE OUT DISTR |:EX10000 |1 |6 |
|3 | └─MERGE GROUP BY | |1 |6 |
|4 | └─PX PARTITION ITERATOR| |12 |5 |
|5 | └─TABLE FULL SCAN |table1000_key_pk_parts_2|12 |5 |
=================================================================================
Outputs & filters:
-------------------------------------
0 - output([T_FUN_COUNT_SUM(T_FUN_COUNT_SUM(T_FUN_COUNT(*)))]), filter(nil), rowset=16
group(nil), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT_SUM(T_FUN_COUNT(*)))])
1 - output([T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil), rowset=16
2 - output([T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil), rowset=16
dop=1
3 - output([T_FUN_COUNT_SUM(T_FUN_COUNT(*))]), filter(nil), rowset=16
group(nil), agg_func([T_FUN_COUNT_SUM(T_FUN_COUNT(*))])
4 - output([T_FUN_COUNT(*)]), filter(nil), rowset=16
force partition granule
5 - output([T_FUN_COUNT(*)]), filter([table1000_key_pk_parts_2.col_double > cast(Floor(cast(-360448000, DECIMAL(20, 0)) / cast(1458241536, DECIMAL(20,
0))), DOUBLE(-1, -1))]), rowset=16
access([table1000_key_pk_parts_2.col_double]), partitions(p[0-1])
is_index_back=false, is_global_index=false, filter_before_indexback[false],
range_key([table1000_key_pk_parts_2.__pk_increment]), range(MIN ; MAX)always true,
pushdown_aggregation([T_FUN_COUNT(*)])
SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > Floor(-360448000 / 1458241536);
count(*)
12
drop table table1000_key_pk_parts_2;

View File

@ -3,6 +3,8 @@
#### description: test
--disable_warnings
drop table if exists div_sb;
--disable_warnings
drop table if exists table1000_key_pk_parts_2;
create table div_sb(c1 int,c2 int(255) zerofill,c3 bigint,c4 bigint unsigned,c5 bigint(255) zerofill,c6 decimal,c7 decimal(35, 15),c8 decimal(35, 7) zerofill,c9 varchar(123) collate utf8mb4_general_ci,c10 date,c11 datetime(5),c12 timestamp(5),c13 year(4),c14 char(24),c15 binary(24),c16 varchar(123) collate utf8mb4_bin);
set @tmp_sql_mode = @@sql_mode;
set @@sql_mode = '';
@ -1701,3 +1703,22 @@ select (18446744073709551615 div -9223372036854775808) from div_sb;
select (18446744073709551615 div 9223372036854775807) from div_sb;
select (18446744073709551615 div 18446744073709551615) from div_sb;
drop table div_sb;
CREATE TABLE `table1000_key_pk_parts_2` (
`col_bigint` bigint(20) DEFAULT NULL,
`col_timestamp` timestamp NULL DEFAULT NULL,
`col_decimal_20_0` decimal(20,0) DEFAULT NULL,
`col_varchar_20` varchar(20) DEFAULT NULL,
`col_double` double DEFAULT NULL,
`pk` int(11) DEFAULT NULL,
KEY `in_expr_idx22` (`col_timestamp`) BLOCK_SIZE 16384 LOCAL
) partition by key(pk) (partition `p0`, partition `p1`);
INSERT INTO `table1000_key_pk_parts_2` VALUES (NULL,NULL,NULL,'g',0,0),(-28,NULL,-15,'deymectqhjvkffumhd',0,NULL),(NULL,'2005-12-10 12:25:37',0,'o',0,7),(-94,NULL,24,'p',-85,0),(-17364,'2000-09-09 14:51:21',0,'b',0,-28),(NULL,NULL,-18404,'english',0,-85),(6109695844481499136,'2005-01-24 20:03:07',-8330,'xodeymec',0,0),(-115,'2001-11-06 06:51:25',NULL,'q',0,-96),(0,'2000-02-10 08:39:54',-1781,'',-11995,0),(-681169443639787520,'2007-02-07 01:00:10',27309,'english',0,54),(NULL,NULL,-62,'english',3,NULL),(7,'2000-05-06 14:11:51',26954,'english',109,-378667008),(4,'2007-10-08 20:32:29',0,NULL,10456,1967783936),(0,NULL,0,'',0,0);
explain SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > ALL (VALUES ROW((SELECT Floor(-360448000 / 1458241536) FROM dual)));
SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > ALL (VALUES ROW((SELECT Floor(-360448000 / 1458241536) FROM dual)));
explain SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > Floor(-360448000 / 1458241536);
SELECT count(*) FROM table1000_key_pk_parts_2 WHERE col_double > Floor(-360448000 / 1458241536);
drop table table1000_key_pk_parts_2;