Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor, planner: Pushing down having causes errors #15302

Closed
fzhedu opened this issue Mar 11, 2020 · 0 comments · Fixed by #15411
Closed

executor, planner: Pushing down having causes errors #15302

fzhedu opened this issue Mar 11, 2020 · 0 comments · Fixed by #15411
Assignees
Labels
priority/P1 The issue has P1 priority. sig/execution SIG execution sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@fzhedu
Copy link
Contributor

fzhedu commented Mar 11, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?

Modify the source code to set

diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go

-       DefInitChunkSize                   = 32
-       DefMaxChunkSize                    = 1024
+       DefInitChunkSize                   = 2
+       DefMaxChunkSize                    = 2

diff --git a/sessionctx/variable/varsutil.go b/sessionctx/variable/varsutil.go
-       maxChunkSizeLowerBound = 32
+       maxChunkSizeLowerBound = 1

CREATE TABLE `A` (
  `col_int` int(11) DEFAULT NULL,
  `col_varchar_1024_utf8_not_null` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_varchar_10_utf8_not_null` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_varchar_1024_utf8` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `col_varchar_10_utf8` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `col_varchar_10_utf8_not_null_key` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_varchar_10_latin1_key` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `col_varchar_1024_utf8_not_null_key` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_varchar_1024_latin1_key` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `col_varchar_10_latin1` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `col_varchar_10_latin1_not_null` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `col_varchar_1024_utf8_key` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `col_varchar_1024_latin1_not_null_key` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `pk` int(11) NOT NULL AUTO_INCREMENT,
  `col_int_key` int(11) DEFAULT NULL,
  `col_varchar_10_utf8_key` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `col_int_not_null` int(11) NOT NULL,
  `col_int_not_null_key` int(11) NOT NULL,
  `col_varchar_10_latin1_not_null_key` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `col_varchar_1024_latin1_not_null` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `col_varchar_1024_latin1` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  PRIMARY KEY (`pk`),
  KEY `col_varchar_10_utf8_not_null_key` (`col_varchar_10_utf8_not_null_key`),
  KEY `col_varchar_10_latin1_key` (`col_varchar_10_latin1_key`),
  KEY `col_varchar_1024_utf8_not_null_key` (`col_varchar_1024_utf8_not_null_key`(333)),
  KEY `col_varchar_1024_latin1_key` (`col_varchar_1024_latin1_key`(1000)),
  KEY `col_varchar_1024_utf8_key` (`col_varchar_1024_utf8_key`(333)),
  KEY `col_varchar_1024_latin1_not_null_key` (`col_varchar_1024_latin1_not_null_key`(1000)),
  KEY `col_int_key` (`col_int_key`),
  KEY `col_varchar_10_utf8_key` (`col_varchar_10_utf8_key`),
  KEY `col_int_not_null_key` (`col_int_not_null_key`),
  KEY `col_varchar_10_latin1_not_null_key` (`col_varchar_10_latin1_not_null_key`)
) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `A` VALUES (7,'f','x','e',NULL,'a','e','q',NULL,NULL,'s','i','c',1,5,'w',5,7,'k','m','l');
INSERT INTO `A` VALUES (NULL,'q','k','o','i','s','p','f','v',NULL,'q','t','n',2,NULL,'s',8,3,'t','o',NULL);
INSERT INTO `A` VALUES (0,'q','d','e','c','y','u','o','i','y','g','t','k',3,NULL,'k',4,0,'b','o','r');
INSERT INTO `A` VALUES (0,'z','v','s','r','d',NULL,'c','x','o','g',NULL,'x',4,3,'q',4,6,'t','m','w');
INSERT INTO `A` VALUES (3,'e','x',NULL,'c','a','h','p',NULL,'f','j','r','e',5,3,'n',2,1,'x','e',NULL);
INSERT INTO `A` VALUES (1,'m','b',NULL,'p','j','l','q','n','p','i','z','p',6,9,'u',8,9,'s','u','j');
INSERT INTO `A` VALUES (NULL,'l','n','i','s','s','n','o','p','j','n','z','h',7,8,NULL,5,4,'u','p',NULL);
INSERT INTO `A` VALUES (7,'k','a',NULL,NULL,'r','p','n','g',NULL,'q','a','w',8,8,'z',2,8,'d','d','v');
INSERT INTO `A` VALUES (4,'x','h','w','g','w',NULL,'c','y','y','l','n','m',9,2,'a',7,4,'n','u','f');
INSERT INTO `A` VALUES (6,'u','k','c','v','s',NULL,'k','b','p','i','b','n',10,8,'i',8,4,'n','e','v');
INSERT INTO `A` VALUES (6,'e','p','h','h','f','b','t','j','p','k','u','z',11,0,'n',5,5,'w','z','t');
INSERT INTO `A` VALUES (5,'j','k','c','k','q','o','s',NULL,NULL,'x','h','c',12,5,NULL,9,3,'x','v',NULL);
INSERT INTO `A` VALUES (4,'y','e','l','c','u',NULL,'y','b',NULL,'x','j','d',13,NULL,'y',8,0,'v','m','y');
INSERT INTO `A` VALUES (7,'n','q','u',NULL,'f','u','z','e',NULL,'q','w','t',14,NULL,'z',7,5,'y','y',NULL);
INSERT INTO `A` VALUES (6,'z','o','v','l','o','q','u','o','c','o','d','y',15,4,'w',2,3,'t','r','b');
INSERT INTO `A` VALUES (7,'b','c',NULL,NULL,'j','b','m','a','u','r',NULL,'u',16,NULL,'h',1,7,'q','j',NULL);
INSERT INTO `A` VALUES (8,'k','e','f','b','c',NULL,'f',NULL,'h','x',NULL,'m',17,8,'w',0,7,'a','s',NULL);
INSERT INTO `A` VALUES (9,'r','i','q','p','e','l','q',NULL,'e','k','c','r',18,NULL,NULL,7,3,'h','k','b');
INSERT INTO `A` VALUES (3,'n','p','t','e','a','g','e','p','s','s','s','v',19,NULL,'u',2,3,'f','k','h');
INSERT INTO `A` VALUES (2,'k','z','r','s','g',NULL,'q','k','l','h',NULL,'m',20,7,'y',8,9,'p','g','c');
INSERT INTO `A` VALUES (NULL,'u','q',NULL,NULL,'j','h','p','t','o','s','u','b',21,8,'m',6,9,'y','q','b');
INSERT INTO `A` VALUES (3,'n','k',NULL,'a','o','i','e','h','k','w','d','r',22,NULL,'p',7,7,'c','c',NULL);
INSERT INTO `A` VALUES (3,'i','t','z','f','d','n','s','d','u','o',NULL,'q',23,NULL,'u',0,5,'s','d','f');
INSERT INTO `A` VALUES (8,'r','a','y','w','w','t','l','a','x','a','g','p',24,0,'x',7,5,'z','o','l');
INSERT INTO `A` VALUES (0,'c','i',NULL,'r','s','j','j','k',NULL,'n','i','d',25,7,'a',1,8,'v','y','p');
INSERT INTO `A` VALUES (7,'c','m','d',NULL,'s','r','v','k','h','t','s','g',26,1,'t',2,0,'z','f','e');
INSERT INTO `A` VALUES (4,'m','o',NULL,'v','i','b','d','j','u','s','g','s',27,3,'x',9,8,'n','b','g');
INSERT INTO `A` VALUES (2,'x','u','y','k','h','e','z','m',NULL,'d','w','f',28,5,'c',0,5,'t','n','k');
INSERT INTO `A` VALUES (1,'r','h','b','k','a','x','q','f','m','d','s','h',29,3,'r',1,0,'u','i','n');
INSERT INTO `A` VALUES (1,'i','k','k','r','x','d','g','u',NULL,'u','w','l',30,9,'b',4,4,'m','t','l');
INSERT INTO `A` VALUES (2,'q','j','b','o','t','t','e','e','w','x','d','p',31,9,'o',0,2,'z','d','o');
INSERT INTO `A` VALUES (7,'h','x','j','o','x','y','r','n','h','m','k','v',32,5,'i',2,3,'u','k','t');
INSERT INTO `A` VALUES (NULL,'x','z','i','i','u','j','d','a','u','u',NULL,'y',33,4,'o',1,2,'t','p',NULL);
INSERT INTO `A` VALUES (3,'b','u','p','m','h','u','u','y','s','u','g','m',34,8,'d',2,0,'p','k','l');
INSERT INTO `A` VALUES (NULL,'z','p',NULL,'h','y','r','b','e','k','l','f','l',35,5,'b',1,2,'s','o','n');
INSERT INTO `A` VALUES (3,'m','v','e','y','h','j','a','v',NULL,'d','a','k',36,7,'j',3,4,'m','j','q');
INSERT INTO `A` VALUES (3,'l','p','r','o','c',NULL,'k','s','o','w','p','b',37,4,'c',7,1,'u','h','x');
INSERT INTO `A` VALUES (NULL,'l','m','d','v','q','u','v','m','o','y',NULL,'q',38,2,'v',5,1,'s','h',NULL);
INSERT INTO `A` VALUES (NULL,'i','v','k','t','n','l','d','w',NULL,'s','g','m',39,1,'y',3,6,'e','e','y');
INSERT INTO `A` VALUES (0,'z','v','h','h','x','c','g','s','a','p','k','y',40,NULL,'v',7,7,'u','p','u');
INSERT INTO `A` VALUES (1,'d','x','r','c','o','c','g','w','a','s','f','u',41,4,NULL,0,8,'x','p','p');
INSERT INTO `A` VALUES (2,'f','s','p','r','t','d','c',NULL,NULL,'x','p','s',42,4,'w',5,2,'e','t',NULL);
INSERT INTO `A` VALUES (NULL,'q','o','b','l','h','y','l','k','v','a','o','s',43,NULL,'x',9,3,'l','b',NULL);
INSERT INTO `A` VALUES (NULL,'g','v','g','c','u','o','z','l','w','l','q','u',44,5,'d',8,5,'o','u','z');
INSERT INTO `A` VALUES (5,'e','w','s','i','q','k','r','f','c','a','d','i',45,1,'o',6,4,'k','e','j');
INSERT INTO `A` VALUES (5,'d','r','l','j','v',NULL,'v','j',NULL,'u',NULL,'z',46,7,'a',8,0,'w','m','k');
INSERT INTO `A` VALUES (2,'d','j',NULL,NULL,'f','w','t','x',NULL,'s','b','e',47,4,'u',3,8,'c','b','l');
INSERT INTO `A` VALUES (2,'g','r',NULL,'y','g',NULL,'x','d',NULL,'r','u','r',48,1,'s',9,1,'i','p','d');
INSERT INTO `A` VALUES (2,'v','i',NULL,'y','w','l','d','x','j','h',NULL,'a',49,4,'b',8,9,'w','y','y');
INSERT INTO `A` VALUES (NULL,'t','x',NULL,'y','y','x','z','h','a','f','v','b',50,NULL,'g',1,8,'p','x','a');
INSERT INTO `A` VALUES (NULL,'r','d','m','u','r',NULL,'r','d','h','x','t','a',51,4,'v',5,4,'j','l','s');
INSERT INTO `A` VALUES (6,'k','o','p','k','f',NULL,'a','p','b','f','a','w',52,7,'f',0,7,'t','w','s');
INSERT INTO `A` VALUES (NULL,'c','f','r','n','x','y','k','m','y','h','u','j',53,NULL,'w',1,7,'m','c','c');
INSERT INTO `A` VALUES (3,'j','m','g',NULL,'p','p','h','c','k','u',NULL,'h',54,7,'q',6,2,'y','g','w');
INSERT INTO `A` VALUES (8,'a','g','l',NULL,'z','v','o','x','x','m','b','b',55,6,'k',2,6,'d','h','e');
INSERT INTO `A` VALUES (1,'v','a','k','o','s',NULL,'b','r','q','o','q','s',56,NULL,'l',9,4,'s','z',NULL);
INSERT INTO `A` VALUES (0,'i','e',NULL,'i','c',NULL,'f','h','j','m','s','n',57,3,'p',7,6,'w','y',NULL);
INSERT INTO `A` VALUES (1,'t','h','b','v','g',NULL,'i',NULL,'n','l','f','d',58,3,NULL,3,4,'i','c','l');
INSERT INTO `A` VALUES (5,'o','i','y','k','h',NULL,'k','c','v','h','e','z',59,8,NULL,5,9,'w','u','p');
INSERT INTO `A` VALUES (0,'f','g','c','u','j','o','u','w',NULL,'r','f','c',60,6,NULL,7,5,'k','q','g');
INSERT INTO `A` VALUES (7,'w','o','x','k','s','g','z',NULL,'b','i','q','a',61,6,'f',8,6,'p','x','c');
INSERT INTO `A` VALUES (NULL,'r','j',NULL,NULL,'v','f','v','o',NULL,'j','k','k',62,4,'p',2,2,'u','g','o');
INSERT INTO `A` VALUES (6,'l','p','g',NULL,'x','y','l','d','g','t',NULL,'h',63,1,'w',9,9,'i','w','b');
INSERT INTO `A` VALUES (6,'d','o','m','w','t','x','i',NULL,NULL,'l','k','v',64,0,'l',5,2,'u','k',NULL);
INSERT INTO `A` VALUES (1,'p','m','k','j','s','i','u','e','y','w','d','f',65,0,'d',4,7,'u','w','k');
INSERT INTO `A` VALUES (0,'q','l','o','i','z','g','q',NULL,NULL,'x','f','y',66,0,'x',2,5,'y','x','z');
INSERT INTO `A` VALUES (2,'k','r','k','i','z','v','w','m','v','b','w','p',67,9,'g',1,2,'h','b','k');
INSERT INTO `A` VALUES (6,'b','n',NULL,'c','a','m','v','t',NULL,'n','p','f',68,0,'p',9,0,'x','c','n');
INSERT INTO `A` VALUES (8,'d','j','b','s','s',NULL,'d','p',NULL,'a','c','t',69,5,NULL,2,5,'z','e','d');
INSERT INTO `A` VALUES (4,'k','o',NULL,NULL,'j',NULL,'f','x','j','j','c','n',70,NULL,NULL,3,1,'a','x','t');
INSERT INTO `A` VALUES (1,'c','r','g',NULL,'t','k','d',NULL,'c','b','l','l',71,NULL,'k',3,1,'z','g','m');
INSERT INTO `A` VALUES (3,'x','z','y','o','j','k','h','k','k','e','u','m',72,8,'o',2,5,'o','o','j');
INSERT INTO `A` VALUES (NULL,'k','e',NULL,'m','h','x','z','d','c','d','k','u',73,2,NULL,9,6,'x','t',NULL);
INSERT INTO `A` VALUES (NULL,'h','c','z','j','p','q','t','t','w','p','k','f',74,1,'d',5,0,'l','v','c');
INSERT INTO `A` VALUES (5,'a','w','n','n','b','i','c','o','a','a',NULL,'l',75,NULL,'o',7,3,'t','q','s');
INSERT INTO `A` VALUES (5,'i','p','c','s','k','c','a','h',NULL,'g','q','g',76,4,'a',3,2,'e','e','j');
INSERT INTO `A` VALUES (NULL,'y','g',NULL,'m','z',NULL,'z','e','g','j','c','h',77,2,'b',1,5,'u','a',NULL);
INSERT INTO `A` VALUES (9,'d','y','k',NULL,'v','r','a','y',NULL,'t','l','a',78,NULL,'p',0,5,'x','z','f');
INSERT INTO `A` VALUES (3,'v','o','b',NULL,'h','a','b','f','g','n','o','i',79,3,'y',8,4,'c','z','f');
INSERT INTO `A` VALUES (NULL,'p','j','y','p','n',NULL,'k','f','j','g','a','r',80,6,'i',7,8,'n','l','i');
INSERT INTO `A` VALUES (1,'j','n','h','x','k','w','s','n','m','r','v','a',81,2,'k',7,8,'i','s','o');
INSERT INTO `A` VALUES (3,'a','h','w','r','j',NULL,'a',NULL,'j','c',NULL,'y',82,1,NULL,7,1,'p','l','c');
INSERT INTO `A` VALUES (9,'y','d',NULL,'s','f','j','t',NULL,'a','h','h','y',83,9,'v',7,2,'p','k','c');
INSERT INTO `A` VALUES (7,'i','d','r','x','f','q','n',NULL,'x','o','n','e',84,3,NULL,1,5,'k','i','e');
INSERT INTO `A` VALUES (3,'x','y','t','r','q','w','b','q','u','j','z','p',85,NULL,'f',6,1,'w','z','s');
INSERT INTO `A` VALUES (5,'p','o',NULL,NULL,'d','p','p',NULL,'m','c','w','y',86,8,'y',3,4,'u','x','y');
INSERT INTO `A` VALUES (6,'b','a','t',NULL,'i','d','h','w',NULL,'i',NULL,'o',87,NULL,'k',3,4,'g','p','p');
INSERT INTO `A` VALUES (6,'e','d','i','b','y','d','c','u','b','v','j','y',88,1,'v',8,1,'o','n','x');
INSERT INTO `A` VALUES (NULL,'h','h','t','v','x','c','a','z','g','t','o','e',89,NULL,NULL,0,0,'l','s','k');
INSERT INTO `A` VALUES (7,'q','z','l','h','p','x','r','e','p','d','x','l',90,4,'p',2,3,'h','i','y');
INSERT INTO `A` VALUES (4,'u','p','v','k','y','l','n',NULL,'p','l','e','m',91,6,'s',5,6,'e','v','y');
INSERT INTO `A` VALUES (3,'b','n','d','r','s','u','g','f','b','e',NULL,'p',92,3,NULL,9,3,'p','z','v');
INSERT INTO `A` VALUES (NULL,'g','z','h','y','c','q','f','k','f','v','u','p',93,5,'i',4,2,'c','p','t');
INSERT INTO `A` VALUES (5,'j','w','l',NULL,'c','g','x','t','z','q','u','w',94,4,'q',2,2,'j','j','f');
INSERT INTO `A` VALUES (5,'i','t','q','a','v','x','e','m','z','r','i','y',95,3,'i',5,0,'q','z','c');
INSERT INTO `A` VALUES (5,'f','c','a','i','r','z','i','w','m','f','k','n',96,NULL,'u',9,7,'d','y','b');
INSERT INTO `A` VALUES (NULL,'b','l','k','w','n','s','x','z','l','q','k','t',97,1,'m',6,2,'u','r','o');
INSERT INTO `A` VALUES (9,'o','n',NULL,'v','a','b','z','o',NULL,'b',NULL,'p',98,NULL,'x',1,1,'p','v','b');
INSERT INTO `A` VALUES (7,'s','v',NULL,NULL,'b',NULL,'m','p',NULL,'d','v','t',99,1,'r',3,8,'z','j','l');
INSERT INTO `A` VALUES (8,'z','k','g','l','h','e','k','z','p','j',NULL,'c',100,6,'o',9,1,'v','m','m');


CREATE TABLE `DD` (
  `pk` int(11) NOT NULL AUTO_INCREMENT,
  `col_int` int(11) DEFAULT NULL,
  `col_int_not_null` int(11) NOT NULL,
  `col_varchar_1024_latin1_key` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `col_varchar_1024_latin1_not_null_key` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `col_varchar_10_utf8` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `col_varchar_10_latin1_key` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `col_int_not_null_key` int(11) NOT NULL,
  `col_varchar_1024_utf8_not_null` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_varchar_1024_latin1_not_null` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `col_varchar_10_utf8_not_null` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_varchar_1024_latin1` varchar(1024) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `col_varchar_10_latin1_not_null` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `col_varchar_10_latin1_not_null_key` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  `col_varchar_1024_utf8_key` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `col_varchar_1024_utf8_not_null_key` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_varchar_10_utf8_not_null_key` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `col_int_key` int(11) DEFAULT NULL,
  `col_varchar_10_latin1` varchar(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `col_varchar_10_utf8_key` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `col_varchar_1024_utf8` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  PRIMARY KEY (`pk`),
  KEY `col_varchar_1024_latin1_key` (`col_varchar_1024_latin1_key`),
  KEY `col_varchar_1024_latin1_not_null_key` (`col_varchar_1024_latin1_not_null_key`),
  KEY `col_varchar_10_latin1_key` (`col_varchar_10_latin1_key`),
  KEY `col_int_not_null_key` (`col_int_not_null_key`),
  KEY `col_varchar_10_latin1_not_null_key` (`col_varchar_10_latin1_not_null_key`),
  KEY `col_varchar_1024_utf8_key` (`col_varchar_1024_utf8_key`),
  KEY `col_varchar_1024_utf8_not_null_key` (`col_varchar_1024_utf8_not_null_key`),
  KEY `col_varchar_10_utf8_not_null_key` (`col_varchar_10_utf8_not_null_key`),
  KEY `col_int_key` (`col_int_key`),
  KEY `col_varchar_10_utf8_key` (`col_varchar_10_utf8_key`)
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `DD` VALUES (1,NULL,9,'n','l','q','p',2,'c','e','q','a','d','b','r','a','i',7,'v','c','i');
INSERT INTO `DD` VALUES (2,2,0,'r','n','h','h',4,'l','c','h','v','j','c','t','k','q',6,'c','s','d');
INSERT INTO `DD` VALUES (3,0,9,'d','x','c','f',6,'x','a','v','t','o','s','p','t','m',8,NULL,'f','p');
INSERT INTO `DD` VALUES (4,NULL,5,'p','g','p','o',4,'m','i','m','r','f','i','e','b','q',NULL,'n','t',NULL);
INSERT INTO `DD` VALUES (5,5,8,'u','o','l',NULL,1,'a','m','f','f','j','p','o','s','i',0,'n','i',NULL);
INSERT INTO `DD` VALUES (6,1,8,'w','y','v','c',0,'c','v','z',NULL,'n','i','m','m','n',3,'b',NULL,'s');
INSERT INTO `DD` VALUES (7,0,8,NULL,'v','w','q',1,'b','m','b','p','s','d','l','x','f',8,NULL,'x',NULL);
INSERT INTO `DD` VALUES (8,4,1,'u','w','b','j',1,'d','u','t','r','z','a','t','j','q',1,NULL,'i','s');
INSERT INTO `DD` VALUES (9,1,4,'l','s',NULL,NULL,2,'h','n','a','c','q','u','i','z','m',3,'c','n',NULL);
INSERT INTO `DD` VALUES (10,0,2,'h','e','x','w',7,'k','p','u',NULL,'d','i','n','s','g',5,'m','s','a');
INSERT INTO `DD` VALUES (11,0,3,NULL,'f','k',NULL,5,'o','m','i',NULL,'w','m','u','q','w',2,'j',NULL,'c');
INSERT INTO `DD` VALUES (12,3,0,'b','h','r','k',2,'r','w','r','h','v','v','r','l','m',5,NULL,'z','m');
INSERT INTO `DD` VALUES (13,NULL,7,'k','c','h','q',7,'w','e','k','x','u','u','b','m','o',7,'o',NULL,'k');
INSERT INTO `DD` VALUES (14,6,0,'f','g','c','r',7,'s','b','c','i','e','b','u','u','u',7,'t','a','g');
INSERT INTO `DD` VALUES (15,8,1,NULL,'c',NULL,'n',3,'y','n','j','r','x','v','j','i','j',NULL,'f','h','v');
INSERT INTO `DD` VALUES (16,9,9,'a','r','p','w',7,'j','j','r','t','c','j',NULL,'i','l',5,'i','i','o');
INSERT INTO `DD` VALUES (17,6,2,'m','h','c','c',5,'o','d','p','b','b','f','r','p','n',9,NULL,'k','e');
INSERT INTO `DD` VALUES (18,6,0,'t','q','a','i',4,'b','r','q',NULL,'x','p','r','r','e',1,'j','o','k');
INSERT INTO `DD` VALUES (19,NULL,3,'i','r','s',NULL,5,'a','m','t',NULL,'p','d','u','p','x',5,'j',NULL,'q');
INSERT INTO `DD` VALUES (20,2,3,'h','k','d','q',5,'z','h','w','k','s','x',NULL,'o','t',4,'u',NULL,'y');
INSERT INTO `DD` VALUES (21,0,9,NULL,'n','v','o',3,'a','u','a','m','r','d','h','l','p',8,'u','a','o');
INSERT INTO `DD` VALUES (22,NULL,7,'m','z','i',NULL,7,'k','r','y','c','z','s','u','l','j',6,'g',NULL,'w');
INSERT INTO `DD` VALUES (23,6,5,'u','g','v','w',2,'d','t','v','j','q','i','z','j','x',NULL,'j','d',NULL);
INSERT INTO `DD` VALUES (24,5,0,'s','b',NULL,'t',9,'o','p','y','e','z','a','r','k','h',5,'f','u','p');
INSERT INTO `DD` VALUES (25,2,3,'b','b','s','u',7,'x','x','i','m','q','c','h','h','x',1,'f','d','v');
INSERT INTO `DD` VALUES (26,5,1,'r','i','z','z',8,'c','n','y','k','s','f',NULL,'s','r',NULL,'n','k','k');
INSERT INTO `DD` VALUES (27,2,1,NULL,'u','t','e',5,'m','g','i','e','f','o','n','m','a',3,NULL,NULL,'x');
INSERT INTO `DD` VALUES (28,7,8,'r','r','p','t',4,'x','f','a',NULL,'t','t','y','n','y',9,'b','t',NULL);
INSERT INTO `DD` VALUES (29,6,1,'j','y','f','t',2,'x','e','j',NULL,'h','e',NULL,'b','r',4,'o','s',NULL);
INSERT INTO `DD` VALUES (30,NULL,0,'a','d','u',NULL,4,'z','x','c','i','b','x','n','t','f',6,'u','b','h');
INSERT INTO `DD` VALUES (31,6,1,NULL,'i','n','m',3,'z','b','c','h','w','f',NULL,'d','w',0,NULL,'w',NULL);
INSERT INTO `DD` VALUES (32,9,7,'m','k','n',NULL,4,'v','m','k','m','e','j','j','p','f',NULL,'x',NULL,'p');
INSERT INTO `DD` VALUES (33,NULL,7,'o','f','h',NULL,0,'t','p','f','c','q','j','q','a','f',NULL,'n','s',NULL);
INSERT INTO `DD` VALUES (34,2,0,'y','d',NULL,'e',2,'j','g','h','p','m','o','i','u','h',1,NULL,'c','k');
INSERT INTO `DD` VALUES (35,0,9,'d','y','s','c',4,'r','e','a','b','a','f','f','x','u',NULL,'x','z','n');
INSERT INTO `DD` VALUES (36,6,8,'v','l','g',NULL,3,'j','h','s','n','m','l',NULL,'u','g',2,'p','t','a');
INSERT INTO `DD` VALUES (37,1,0,'h','a','v','a',8,'a','g','o',NULL,'i','t','c','i','n',4,'m','a','l');
INSERT INTO `DD` VALUES (38,6,5,'e','l',NULL,'n',2,'b','g','c','f','g','w','v','l','r',4,NULL,'e',NULL);
INSERT INTO `DD` VALUES (39,NULL,9,'e','q','i','i',5,'e','d','j','w','v','y','t','v','a',NULL,NULL,'a','v');
INSERT INTO `DD` VALUES (40,8,9,'t','t','u','h',3,'n','g','w','t','q','k','n','u','o',NULL,'a','p','d');
INSERT INTO `DD` VALUES (41,1,1,'l','b','i','x',3,'o','e','c','a','e','t','h','l','e',5,'k','p',NULL);
INSERT INTO `DD` VALUES (42,8,3,'a','i','k','g',5,'q','r','b','x','j','u','j','y','x',6,'r','d','w');
INSERT INTO `DD` VALUES (43,NULL,8,'o','d','s','m',1,'g','n','c','d','b','v','t','k','f',7,'d','c','x');
INSERT INTO `DD` VALUES (44,NULL,4,'d','g','v','k',9,'c','h','t','n','p','a','k','o','e',0,'z','w','c');
INSERT INTO `DD` VALUES (45,5,9,'q','p','a','k',9,'s','s','l','e','c','f','s','d','x',1,'o','q','p');
INSERT INTO `DD` VALUES (46,5,6,'i','h','s','w',6,'q','b','s','s','t','f','x','d','v',0,'w',NULL,'w');
INSERT INTO `DD` VALUES (47,6,7,NULL,'d','g','p',4,'a','s','l','t','l','s','k','c','w',6,'p',NULL,NULL);
INSERT INTO `DD` VALUES (48,7,3,NULL,'n','l','o',1,'m','r','x','d','j','s','k','v','s',3,'t','k',NULL);
INSERT INTO `DD` VALUES (49,7,6,'y','a','h',NULL,7,'g','k','z','s','k','l',NULL,'f','g',8,'k','r',NULL);
INSERT INTO `DD` VALUES (50,5,4,'q','t','f','k',3,'y','j','k',NULL,'s','l','x','a','u',6,'h',NULL,'i');

  1. What did you expect to see?
    removing having wokes correctly.
    indexes can be ingored or used.
SELECT /*+ignore_index(table2,col_varchar_10_utf8,col_int_key)*/    table2 . `col_int_key` AS field1 FROM  DD AS table1  LEFT  JOIN A AS table2 ON  table1 . `col_varchar_1024_utf8` =  table2 . `col_varchar_10_utf8`  WHERE ( table2 . `col_int` IS  NULL OR table1 . `col_int` > 8 )  GROUP BY field1 HAVING field1 <= 4  ;

+--------+
| field1 |
+--------+
|      4 |
|      2 |
|      1 |
+--------+
SELECT  table2 . `col_int_key` AS field1 FROM  DD AS table1  LEFT  JOIN A AS table2 ON  table1 . `col_varchar_1024_utf8` =  table2 . `col_varchar_10_utf8`  WHERE ( table2 . `col_int` IS  NULL OR table1 . `col_int` > 8 )  GROUP BY field1 order by field1;
+--------+
| field1 |
+--------+
|   NULL |
|      1 |
|      2 |
|      4 |
|      5 |
|      6 |
|      8 |
|      9 |
+--------+
  1. What did you see instead?
SELECT /*+ignore_index(table2,col_varchar_10_utf8,col_int_key)*/    table2 . `col_int_key` AS field1 FROM  DD AS table1  LEFT  JOIN A AS table2 ON  table1 . `col_varchar_1024_utf8` =  table2 . `col_varchar_10_utf8`  WHERE ( table2 . `col_int` IS  NULL OR table1 . `col_int` > 8 )  GROUP BY field1 HAVING field1 <= 4  ;

+--------+
| field1 |
+--------+
|      4 |
|      0 |
|      2 |
|      3 |
+--------+
SELECT  table2 . `col_int_key` AS field1 FROM  DD AS table1  LEFT  JOIN A AS table2 ON  table1 . `col_varchar_1024_utf8` =  table2 . `col_varchar_10_utf8`  WHERE ( table2 . `col_int` IS  NULL OR table1 . `col_int` > 8 )  GROUP BY field1 order by field1;
+--------+
| field1 |
+--------+
|   NULL |
|      1 |
|      2 |
|      4 |
|      5 |
|      6 |
|      8 |
|      9 |
+--------+
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
+----------------------------------------------+
| version()                                    |
+----------------------------------------------+
| 5.7.25-TiDB-v4.0.0-beta-379-ga999ef698-dirty |
+----------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/P1 The issue has P1 priority. sig/execution SIG execution sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants