From 361b790392255206eb2750e868dafc42feb964e8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 3 Mar 2024 08:18:55 +0100 Subject: [PATCH 01/23] Remove unnecessary whitespace in mysqldump --- client/mysqldump.c | 5 +++-- mysql-test/main/mysqldump-max.result | 22 +++++++++++----------- mysql-test/main/mysqldump-system.result | 20 ++++++++++---------- mysql-test/main/mysqldump.result | 8 ++++---- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index ae06f1dbf8b..79339fc59b8 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3042,8 +3042,9 @@ static uint get_table_structure(const char *table, const char *db, char *table_t } else dynstr_set_checked(&select_field_names, ""); - insert_option= ((delayed && opt_ignore) ? " DELAYED IGNORE " : - delayed ? " DELAYED " : opt_ignore ? " IGNORE " : ""); + + insert_option= ((delayed && opt_ignore) ? "DELAYED IGNORE " : + delayed ? "DELAYED " : opt_ignore ? "IGNORE " : ""); verbose_msg("-- Retrieving table structure for table %s...\n", table); diff --git a/mysql-test/main/mysqldump-max.result b/mysql-test/main/mysqldump-max.result index eb2cf2aec08..4a53a5f3328 100644 --- a/mysql-test/main/mysqldump-max.result +++ b/mysql-test/main/mysqldump-max.result @@ -102,7 +102,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; DROP TABLE IF EXISTS `t2`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -114,7 +114,7 @@ CREATE TABLE `t2` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t2` ENABLE KEYS */; DROP TABLE IF EXISTS `t3`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -126,7 +126,7 @@ CREATE TABLE `t3` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t3` ENABLE KEYS */; DROP TABLE IF EXISTS `t4`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -138,7 +138,7 @@ CREATE TABLE `t4` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t4` ENABLE KEYS */; DROP TABLE IF EXISTS `t5`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -150,7 +150,7 @@ CREATE TABLE `t5` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t5` ENABLE KEYS */; DROP TABLE IF EXISTS `t6`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -162,7 +162,7 @@ CREATE TABLE `t6` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t6` DISABLE KEYS */; -INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t6` ENABLE KEYS */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -199,7 +199,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; DROP TABLE IF EXISTS `t2`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -211,7 +211,7 @@ CREATE TABLE `t2` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */; -INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t2` ENABLE KEYS */; DROP TABLE IF EXISTS `t3`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -223,7 +223,7 @@ CREATE TABLE `t3` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */; -INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t3` ENABLE KEYS */; DROP TABLE IF EXISTS `t4`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -235,7 +235,7 @@ CREATE TABLE `t4` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */; -INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t4` ENABLE KEYS */; DROP TABLE IF EXISTS `t5`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -247,7 +247,7 @@ CREATE TABLE `t5` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */; -INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t5` ENABLE KEYS */; DROP TABLE IF EXISTS `t6`; /*!40101 SET @saved_cs_client = @@character_set_client */; diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result index 2fa010b3e4e..bc8229ff42f 100644 --- a/mysql-test/main/mysqldump-system.result +++ b/mysql-test/main/mysqldump-system.result @@ -359,31 +359,31 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; -INSERT IGNORE INTO `column_stats` VALUES ('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿'); +INSERT IGNORE INTO `column_stats` VALUES ('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; -INSERT IGNORE INTO `index_stats` VALUES ('mysql','tz','PRIMARY',1,98.2500); +INSERT IGNORE INTO `index_stats` VALUES ('mysql','tz','PRIMARY',1,98.2500); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; -INSERT IGNORE INTO `table_stats` VALUES ('mysql','tz',393); +INSERT IGNORE INTO `table_stats` VALUES ('mysql','tz',393); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; -INSERT IGNORE INTO `innodb_index_stats` VALUES ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); +INSERT IGNORE INTO `innodb_index_stats` VALUES ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; -INSERT IGNORE INTO `innodb_table_stats` VALUES ('mysql','tz','2019-12-31 21:00:00',393,1,0); +INSERT IGNORE INTO `innodb_table_stats` VALUES ('mysql','tz','2019-12-31 21:00:00',393,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -391,31 +391,31 @@ USE mysql; LOCK TABLES `time_zone` WRITE; /*!40000 ALTER TABLE `time_zone` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone` VALUES (1,'N'),(2,'N'),(3,'N'),(4,'Y'),(5,'N'); +INSERT IGNORE INTO `time_zone` VALUES (1,'N'),(2,'N'),(3,'N'),(4,'Y'),(5,'N'); /*!40000 ALTER TABLE `time_zone` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_name` WRITE; /*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_name` VALUES ('Europe/Moscow',3),('Japan',5),('leap/Europe/Moscow',4),('MET',1),('Universal',2),('UTC',2); +INSERT IGNORE INTO `time_zone_name` VALUES ('Europe/Moscow',3),('Japan',5),('leap/Europe/Moscow',4),('MET',1),('Universal',2),('UTC',2); /*!40000 ALTER TABLE `time_zone_name` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_leap_second` WRITE; /*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_leap_second` VALUES (78796800,1),(94694401,2),(126230402,3),(157766403,4),(189302404,5),(220924805,6),(252460806,7),(283996807,8),(315532808,9),(362793609,10),(394329610,11),(425865611,12),(489024012,13),(567993613,14),(631152014,15),(662688015,16),(709948816,17),(741484817,18),(773020818,19),(820454419,20),(867715220,21),(915148821,22); +INSERT IGNORE INTO `time_zone_leap_second` VALUES (78796800,1),(94694401,2),(126230402,3),(157766403,4),(189302404,5),(220924805,6),(252460806,7),(283996807,8),(315532808,9),(362793609,10),(394329610,11),(425865611,12),(489024012,13),(567993613,14),(631152014,15),(662688015,16),(709948816,17),(741484817,18),(773020818,19),(820454419,20),(867715220,21),(915148821,22); /*!40000 ALTER TABLE `time_zone_leap_second` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_transition` WRITE; /*!40000 ALTER TABLE `time_zone_transition` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_transition` VALUES (1,-1693706400,0),(1,-1680483600,1),(1,-1663455600,2),(1,-1650150000,3),(1,-1632006000,2),(1,-1618700400,3),(1,-938905200,2),(1,-857257200,3),(1,-844556400,2),(1,-828226800,3),(1,-812502000,2),(1,-796777200,3),(1,228877200,2),(1,243997200,3),(1,260326800,2),(1,276051600,3),(1,291776400,2),(1,307501200,3),(1,323830800,2),(1,338950800,3),(1,354675600,2),(1,370400400,3),(1,386125200,2),(1,401850000,3),(1,417574800,2),(1,433299600,3),(1,449024400,2),(1,465354000,3),(1,481078800,2),(1,496803600,3),(1,512528400,2),(1,528253200,3),(1,543978000,2),(1,559702800,3),(1,575427600,2),(1,591152400,3),(1,606877200,2),(1,622602000,3),(1,638326800,2),(1,654656400,3),(1,670381200,2),(1,686106000,3),(1,701830800,2),(1,717555600,3),(1,733280400,2),(1,749005200,3),(1,764730000,2),(1,780454800,3),(1,796179600,2),(1,811904400,3),(1,828234000,2),(1,846378000,3),(1,859683600,2),(1,877827600,3),(1,891133200,2),(1,909277200,3),(1,922582800,2),(1,941331600,3),(1,954032400,2),(1,972781200,3),(1,985482000,2),(1,1004230800,3),(1,1017536400,2),(1,1035680400,3),(1,1048986000,2),(1,1067130000,3),(1,1080435600,2),(1,1099184400,3),(1,1111885200,2),(1,1130634000,3),(1,1143334800,2),(1,1162083600,3),(1,1174784400,2),(1,1193533200,3),(1,1206838800,2),(1,1224982800,3),(1,1238288400,2),(1,1256432400,3),(1,1269738000,2),(1,1288486800,3),(1,1301187600,2),(1,1319936400,3),(1,1332637200,2),(1,1351386000,3),(1,1364691600,2),(1,1382835600,3),(1,1396141200,2),(1,1414285200,3),(1,1427590800,2),(1,1445734800,3),(1,1459040400,2),(1,1477789200,3),(1,1490490000,2),(1,1509238800,3),(1,1521939600,2),(1,1540688400,3),(1,1553994000,2),(1,1572138000,3),(1,1585443600,2),(1,1603587600,3),(1,1616893200,2),(1,1635642000,3),(1,1648342800,2),(1,1667091600,3),(1,1679792400,2),(1,1698541200,3),(1,1711846800,2),(1,1729990800,3),(1,1743296400,2),(1,1761440400,3),(1,1774746000,2),(1,1792890000,3),(1,1806195600,2),(1,1824944400,3),(1,1837645200,2),(1,1856394000,3),(1,1869094800,2),(1,1887843600,3),(1,1901149200,2),(1,1919293200,3),(1,1932598800,2),(1,1950742800,3),(1,1964048400,2),(1,1982797200,3),(1,1995498000,2),(1,2014246800,3),(1,2026947600,2),(1,2045696400,3),(1,2058397200,2),(1,2077146000,3),(1,2090451600,2),(1,2108595600,3),(1,2121901200,2),(1,2140045200,3),(3,-1688265000,2),(3,-1656819048,1),(3,-1641353448,2),(3,-1627965048,3),(3,-1618716648,1),(3,-1596429048,3),(3,-1593829848,5),(3,-1589860800,4),(3,-1542427200,5),(3,-1539493200,6),(3,-1525323600,5),(3,-1522728000,4),(3,-1491188400,7),(3,-1247536800,4),(3,354920400,5),(3,370728000,4),(3,386456400,5),(3,402264000,4),(3,417992400,5),(3,433800000,4),(3,449614800,5),(3,465346800,8),(3,481071600,9),(3,496796400,8),(3,512521200,9),(3,528246000,8),(3,543970800,9),(3,559695600,8),(3,575420400,9),(3,591145200,8),(3,606870000,9),(3,622594800,8),(3,638319600,9),(3,654649200,8),(3,670374000,10),(3,686102400,11),(3,695779200,8),(3,701812800,5),(3,717534000,4),(3,733273200,9),(3,748998000,8),(3,764722800,9),(3,780447600,8),(3,796172400,9),(3,811897200,8),(3,828226800,9),(3,846370800,8),(3,859676400,9),(3,877820400,8),(3,891126000,9),(3,909270000,8),(3,922575600,9),(3,941324400,8),(3,954025200,9),(3,972774000,8),(3,985474800,9),(3,1004223600,8),(3,1017529200,9),(3,1035673200,8),(3,1048978800,9),(3,1067122800,8),(3,1080428400,9),(3,1099177200,8),(3,1111878000,9),(3,1130626800,8),(3,1143327600,9),(3,1162076400,8),(3,1174777200,9),(3,1193526000,8),(3,1206831600,9),(3,1224975600,8),(3,1238281200,9),(3,1256425200,8),(3,1269730800,9),(3,1288479600,8),(3,1301180400,9),(3,1319929200,8),(3,1332630000,9),(3,1351378800,8),(3,1364684400,9),(3,1382828400,8),(3,1396134000,9),(3,1414278000,8),(3,1427583600,9),(3,1445727600,8),(3,1459033200,9),(3,1477782000,8),(3,1490482800,9),(3,1509231600,8),(3,1521932400,9),(3,1540681200,8),(3,1553986800,9),(3,1572130800,8),(3,1585436400,9),(3,1603580400,8),(3,1616886000,9),(3,1635634800,8),(3,1648335600,9),(3,1667084400,8),(3,1679785200,9),(3,1698534000,8),(3,1711839600,9),(3,1729983600,8),(3,1743289200,9),(3,1761433200,8),(3,1774738800,9),(3,1792882800,8),(3,1806188400,9),(3,1824937200,8),(3,1837638000,9),(3,1856386800,8),(3,1869087600,9),(3,1887836400,8),(3,1901142000,9),(3,1919286000,8),(3,1932591600,9),(3,1950735600,8),(3,1964041200,9),(3,1982790000,8),(3,1995490800,9),(3,2014239600,8),(3,2026940400,9),(3,2045689200,8),(3,2058390000,9),(3,2077138800,8),(3,2090444400,9),(3,2108588400,8),(3,2121894000,9),(3,2140038000,8),(4,-1688265000,2),(4,-1656819048,1),(4,-1641353448,2),(4,-1627965048,3),(4,-1618716648,1),(4,-1596429048,3),(4,-1593829848,5),(4,-1589860800,4),(4,-1542427200,5),(4,-1539493200,6),(4,-1525323600,5),(4,-1522728000,4),(4,-1491188400,7),(4,-1247536800,4),(4,354920409,5),(4,370728010,4),(4,386456410,5),(4,402264011,4),(4,417992411,5),(4,433800012,4),(4,449614812,5),(4,465346812,8),(4,481071612,9),(4,496796413,8),(4,512521213,9),(4,528246013,8),(4,543970813,9),(4,559695613,8),(4,575420414,9),(4,591145214,8),(4,606870014,9),(4,622594814,8),(4,638319615,9),(4,654649215,8),(4,670374016,10),(4,686102416,11),(4,695779216,8),(4,701812816,5),(4,717534017,4),(4,733273217,9),(4,748998018,8),(4,764722818,9),(4,780447619,8),(4,796172419,9),(4,811897219,8),(4,828226820,9),(4,846370820,8),(4,859676420,9),(4,877820421,8),(4,891126021,9),(4,909270021,8),(4,922575622,9),(4,941324422,8),(4,954025222,9),(4,972774022,8),(4,985474822,9),(4,1004223622,8),(4,1017529222,9),(4,1035673222,8),(4,1048978822,9),(4,1067122822,8),(4,1080428422,9),(4,1099177222,8),(4,1111878022,9),(4,1130626822,8),(4,1143327622,9),(4,1162076422,8),(4,1174777222,9),(4,1193526022,8),(4,1206831622,9),(4,1224975622,8),(4,1238281222,9),(4,1256425222,8),(4,1269730822,9),(4,1288479622,8),(4,1301180422,9),(4,1319929222,8),(4,1332630022,9),(4,1351378822,8),(4,1364684422,9),(4,1382828422,8),(4,1396134022,9),(4,1414278022,8),(4,1427583622,9),(4,1445727622,8),(4,1459033222,9),(4,1477782022,8),(4,1490482822,9),(4,1509231622,8),(4,1521932422,9),(4,1540681222,8),(4,1553986822,9),(4,1572130822,8),(4,1585436422,9),(4,1603580422,8),(4,1616886022,9),(4,1635634822,8),(4,1648335622,9),(4,1667084422,8),(4,1679785222,9),(4,1698534022,8),(4,1711839622,9),(4,1729983622,8),(4,1743289222,9),(4,1761433222,8),(4,1774738822,9),(4,1792882822,8),(4,1806188422,9),(4,1824937222,8),(4,1837638022,9),(4,1856386822,8),(4,1869087622,9),(4,1887836422,8),(4,1901142022,9),(4,1919286022,8),(4,1932591622,9),(4,1950735622,8),(4,1964041222,9),(4,1982790022,8),(4,1995490822,9),(4,2014239622,8),(4,2026940422,9),(4,2045689222,8),(4,2058390022,9),(4,2077138822,8),(4,2090444422,9),(4,2108588422,8),(4,2121894022,9),(4,2140038022,8),(5,-1009875600,1); +INSERT IGNORE INTO `time_zone_transition` VALUES (1,-1693706400,0),(1,-1680483600,1),(1,-1663455600,2),(1,-1650150000,3),(1,-1632006000,2),(1,-1618700400,3),(1,-938905200,2),(1,-857257200,3),(1,-844556400,2),(1,-828226800,3),(1,-812502000,2),(1,-796777200,3),(1,228877200,2),(1,243997200,3),(1,260326800,2),(1,276051600,3),(1,291776400,2),(1,307501200,3),(1,323830800,2),(1,338950800,3),(1,354675600,2),(1,370400400,3),(1,386125200,2),(1,401850000,3),(1,417574800,2),(1,433299600,3),(1,449024400,2),(1,465354000,3),(1,481078800,2),(1,496803600,3),(1,512528400,2),(1,528253200,3),(1,543978000,2),(1,559702800,3),(1,575427600,2),(1,591152400,3),(1,606877200,2),(1,622602000,3),(1,638326800,2),(1,654656400,3),(1,670381200,2),(1,686106000,3),(1,701830800,2),(1,717555600,3),(1,733280400,2),(1,749005200,3),(1,764730000,2),(1,780454800,3),(1,796179600,2),(1,811904400,3),(1,828234000,2),(1,846378000,3),(1,859683600,2),(1,877827600,3),(1,891133200,2),(1,909277200,3),(1,922582800,2),(1,941331600,3),(1,954032400,2),(1,972781200,3),(1,985482000,2),(1,1004230800,3),(1,1017536400,2),(1,1035680400,3),(1,1048986000,2),(1,1067130000,3),(1,1080435600,2),(1,1099184400,3),(1,1111885200,2),(1,1130634000,3),(1,1143334800,2),(1,1162083600,3),(1,1174784400,2),(1,1193533200,3),(1,1206838800,2),(1,1224982800,3),(1,1238288400,2),(1,1256432400,3),(1,1269738000,2),(1,1288486800,3),(1,1301187600,2),(1,1319936400,3),(1,1332637200,2),(1,1351386000,3),(1,1364691600,2),(1,1382835600,3),(1,1396141200,2),(1,1414285200,3),(1,1427590800,2),(1,1445734800,3),(1,1459040400,2),(1,1477789200,3),(1,1490490000,2),(1,1509238800,3),(1,1521939600,2),(1,1540688400,3),(1,1553994000,2),(1,1572138000,3),(1,1585443600,2),(1,1603587600,3),(1,1616893200,2),(1,1635642000,3),(1,1648342800,2),(1,1667091600,3),(1,1679792400,2),(1,1698541200,3),(1,1711846800,2),(1,1729990800,3),(1,1743296400,2),(1,1761440400,3),(1,1774746000,2),(1,1792890000,3),(1,1806195600,2),(1,1824944400,3),(1,1837645200,2),(1,1856394000,3),(1,1869094800,2),(1,1887843600,3),(1,1901149200,2),(1,1919293200,3),(1,1932598800,2),(1,1950742800,3),(1,1964048400,2),(1,1982797200,3),(1,1995498000,2),(1,2014246800,3),(1,2026947600,2),(1,2045696400,3),(1,2058397200,2),(1,2077146000,3),(1,2090451600,2),(1,2108595600,3),(1,2121901200,2),(1,2140045200,3),(3,-1688265000,2),(3,-1656819048,1),(3,-1641353448,2),(3,-1627965048,3),(3,-1618716648,1),(3,-1596429048,3),(3,-1593829848,5),(3,-1589860800,4),(3,-1542427200,5),(3,-1539493200,6),(3,-1525323600,5),(3,-1522728000,4),(3,-1491188400,7),(3,-1247536800,4),(3,354920400,5),(3,370728000,4),(3,386456400,5),(3,402264000,4),(3,417992400,5),(3,433800000,4),(3,449614800,5),(3,465346800,8),(3,481071600,9),(3,496796400,8),(3,512521200,9),(3,528246000,8),(3,543970800,9),(3,559695600,8),(3,575420400,9),(3,591145200,8),(3,606870000,9),(3,622594800,8),(3,638319600,9),(3,654649200,8),(3,670374000,10),(3,686102400,11),(3,695779200,8),(3,701812800,5),(3,717534000,4),(3,733273200,9),(3,748998000,8),(3,764722800,9),(3,780447600,8),(3,796172400,9),(3,811897200,8),(3,828226800,9),(3,846370800,8),(3,859676400,9),(3,877820400,8),(3,891126000,9),(3,909270000,8),(3,922575600,9),(3,941324400,8),(3,954025200,9),(3,972774000,8),(3,985474800,9),(3,1004223600,8),(3,1017529200,9),(3,1035673200,8),(3,1048978800,9),(3,1067122800,8),(3,1080428400,9),(3,1099177200,8),(3,1111878000,9),(3,1130626800,8),(3,1143327600,9),(3,1162076400,8),(3,1174777200,9),(3,1193526000,8),(3,1206831600,9),(3,1224975600,8),(3,1238281200,9),(3,1256425200,8),(3,1269730800,9),(3,1288479600,8),(3,1301180400,9),(3,1319929200,8),(3,1332630000,9),(3,1351378800,8),(3,1364684400,9),(3,1382828400,8),(3,1396134000,9),(3,1414278000,8),(3,1427583600,9),(3,1445727600,8),(3,1459033200,9),(3,1477782000,8),(3,1490482800,9),(3,1509231600,8),(3,1521932400,9),(3,1540681200,8),(3,1553986800,9),(3,1572130800,8),(3,1585436400,9),(3,1603580400,8),(3,1616886000,9),(3,1635634800,8),(3,1648335600,9),(3,1667084400,8),(3,1679785200,9),(3,1698534000,8),(3,1711839600,9),(3,1729983600,8),(3,1743289200,9),(3,1761433200,8),(3,1774738800,9),(3,1792882800,8),(3,1806188400,9),(3,1824937200,8),(3,1837638000,9),(3,1856386800,8),(3,1869087600,9),(3,1887836400,8),(3,1901142000,9),(3,1919286000,8),(3,1932591600,9),(3,1950735600,8),(3,1964041200,9),(3,1982790000,8),(3,1995490800,9),(3,2014239600,8),(3,2026940400,9),(3,2045689200,8),(3,2058390000,9),(3,2077138800,8),(3,2090444400,9),(3,2108588400,8),(3,2121894000,9),(3,2140038000,8),(4,-1688265000,2),(4,-1656819048,1),(4,-1641353448,2),(4,-1627965048,3),(4,-1618716648,1),(4,-1596429048,3),(4,-1593829848,5),(4,-1589860800,4),(4,-1542427200,5),(4,-1539493200,6),(4,-1525323600,5),(4,-1522728000,4),(4,-1491188400,7),(4,-1247536800,4),(4,354920409,5),(4,370728010,4),(4,386456410,5),(4,402264011,4),(4,417992411,5),(4,433800012,4),(4,449614812,5),(4,465346812,8),(4,481071612,9),(4,496796413,8),(4,512521213,9),(4,528246013,8),(4,543970813,9),(4,559695613,8),(4,575420414,9),(4,591145214,8),(4,606870014,9),(4,622594814,8),(4,638319615,9),(4,654649215,8),(4,670374016,10),(4,686102416,11),(4,695779216,8),(4,701812816,5),(4,717534017,4),(4,733273217,9),(4,748998018,8),(4,764722818,9),(4,780447619,8),(4,796172419,9),(4,811897219,8),(4,828226820,9),(4,846370820,8),(4,859676420,9),(4,877820421,8),(4,891126021,9),(4,909270021,8),(4,922575622,9),(4,941324422,8),(4,954025222,9),(4,972774022,8),(4,985474822,9),(4,1004223622,8),(4,1017529222,9),(4,1035673222,8),(4,1048978822,9),(4,1067122822,8),(4,1080428422,9),(4,1099177222,8),(4,1111878022,9),(4,1130626822,8),(4,1143327622,9),(4,1162076422,8),(4,1174777222,9),(4,1193526022,8),(4,1206831622,9),(4,1224975622,8),(4,1238281222,9),(4,1256425222,8),(4,1269730822,9),(4,1288479622,8),(4,1301180422,9),(4,1319929222,8),(4,1332630022,9),(4,1351378822,8),(4,1364684422,9),(4,1382828422,8),(4,1396134022,9),(4,1414278022,8),(4,1427583622,9),(4,1445727622,8),(4,1459033222,9),(4,1477782022,8),(4,1490482822,9),(4,1509231622,8),(4,1521932422,9),(4,1540681222,8),(4,1553986822,9),(4,1572130822,8),(4,1585436422,9),(4,1603580422,8),(4,1616886022,9),(4,1635634822,8),(4,1648335622,9),(4,1667084422,8),(4,1679785222,9),(4,1698534022,8),(4,1711839622,9),(4,1729983622,8),(4,1743289222,9),(4,1761433222,8),(4,1774738822,9),(4,1792882822,8),(4,1806188422,9),(4,1824937222,8),(4,1837638022,9),(4,1856386822,8),(4,1869087622,9),(4,1887836422,8),(4,1901142022,9),(4,1919286022,8),(4,1932591622,9),(4,1950735622,8),(4,1964041222,9),(4,1982790022,8),(4,1995490822,9),(4,2014239622,8),(4,2026940422,9),(4,2045689222,8),(4,2058390022,9),(4,2077138822,8),(4,2090444422,9),(4,2108588422,8),(4,2121894022,9),(4,2140038022,8),(5,-1009875600,1); /*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_transition_type` WRITE; /*!40000 ALTER TABLE `time_zone_transition_type` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_transition_type` VALUES (1,0,7200,1,'MEST'),(1,1,3600,0,'MET'),(1,2,7200,1,'MEST'),(1,3,3600,0,'MET'),(2,0,0,0,'UTC'),(3,0,9000,0,'MMT'),(3,1,12648,1,'MST'),(3,2,9048,0,'MMT'),(3,3,16248,1,'MDST'),(3,4,10800,0,'MSK'),(3,5,14400,1,'MSD'),(3,6,18000,1,'MSD'),(3,7,7200,0,'EET'),(3,8,10800,0,'MSK'),(3,9,14400,1,'MSD'),(3,10,10800,1,'EEST'),(3,11,7200,0,'EET'),(4,0,9000,0,'MMT'),(4,1,12648,1,'MST'),(4,2,9048,0,'MMT'),(4,3,16248,1,'MDST'),(4,4,10800,0,'MSK'),(4,5,14400,1,'MSD'),(4,6,18000,1,'MSD'),(4,7,7200,0,'EET'),(4,8,10800,0,'MSK'),(4,9,14400,1,'MSD'),(4,10,10800,1,'EEST'),(4,11,7200,0,'EET'),(5,0,32400,0,'CJT'),(5,1,32400,0,'JST'); +INSERT IGNORE INTO `time_zone_transition_type` VALUES (1,0,7200,1,'MEST'),(1,1,3600,0,'MET'),(1,2,7200,1,'MEST'),(1,3,3600,0,'MET'),(2,0,0,0,'UTC'),(3,0,9000,0,'MMT'),(3,1,12648,1,'MST'),(3,2,9048,0,'MMT'),(3,3,16248,1,'MDST'),(3,4,10800,0,'MSK'),(3,5,14400,1,'MSD'),(3,6,18000,1,'MSD'),(3,7,7200,0,'EET'),(3,8,10800,0,'MSK'),(3,9,14400,1,'MSD'),(3,10,10800,1,'EEST'),(3,11,7200,0,'EET'),(4,0,9000,0,'MMT'),(4,1,12648,1,'MST'),(4,2,9048,0,'MMT'),(4,3,16248,1,'MDST'),(4,4,10800,0,'MSK'),(4,5,14400,1,'MSD'),(4,6,18000,1,'MSD'),(4,7,7200,0,'EET'),(4,8,10800,0,'MSK'),(4,9,14400,1,'MSD'),(4,10,10800,1,'EEST'),(4,11,7200,0,'EET'),(5,0,32400,0,'CJT'),(5,1,32400,0,'JST'); /*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index c4212ce43b2..a23bf87833d 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -734,7 +734,7 @@ CREATE TABLE `t1` ( LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); +INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -767,7 +767,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); +INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -5558,7 +5558,7 @@ CREATE TABLE `nonunique_table_name` ( UNIQUE KEY `i1` (`i1`) ) ENGINE=MEMORY AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT DELAYED INTO `nonunique_table_name` VALUES (1),(2); +INSERT DELAYED INTO `nonunique_table_name` VALUES (1),(2); /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nonunique_table_view_name` ( @@ -5576,7 +5576,7 @@ CREATE TABLE `basetable` ( `id` smallint(6) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT DELAYED INTO `basetable` VALUES (5),(6); +INSERT DELAYED INTO `basetable` VALUES (5),(6); /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nonunique_table_name` ( From 24abbb9bdb6adb7af2591f76dfc7b0fe6b3130d9 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 22 Apr 2024 20:22:03 +0400 Subject: [PATCH 02/23] MDEV-21034 GREATEST() and LEAST() malfunction for NULL There is a convention that Item::val_int() and Item::val_real() return SQL NULL doing effectively what this code does: null_value= true; return 0; // Always return 0 for SQL NULL This is done to optimize boolean value evaluation: if Item::val_int() or Item::val_real() returned 1 - that always means TRUE and never can means SQL NULL. This convention helps to avoid unnecessary testing Item::null_value after getting a non-zero return value. Item_func_min_max did not follow this convention. It could return a non-zero value together with null_value==true. This made evaluate_join_record() erroneously misinterpret SQL NULL as TRUE in this call: select_cond_result= MY_TEST(select_cond->val_int()); Fixing Item_func_min_max to follow the convention. --- mysql-test/main/func_hybrid_type.result | 25 +++++++++++++++++++++++++ mysql-test/main/func_hybrid_type.test | 23 +++++++++++++++++++++++ sql/item_func.cc | 4 ++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/func_hybrid_type.result b/mysql-test/main/func_hybrid_type.result index 7276080ed71..f20aad9d726 100644 --- a/mysql-test/main/func_hybrid_type.result +++ b/mysql-test/main/func_hybrid_type.result @@ -4313,5 +4313,30 @@ ERROR HY000: Illegal parameter data types bigint unsigned and row for operation SELECT @@max_allowed_packet=ROW(1,1); ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' # +# MDEV-21034 GREATEST() and LEAST() malfunction for NULL +# +SELECT 5 AS c1 FROM dual WHERE GREATEST(1, NULL); +c1 +SELECT 5 AS c1 FROM dual WHERE LEAST(1, NULL); +c1 +CREATE TABLE t0 (c0 INT); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +c0 +SELECT * FROM t0 WHERE LEAST(c0, NULL); +c0 +DROP TABLE t0; +SELECT 5 AS c1 FROM dual WHERE GREATEST(1e0, NULL); +c1 +SELECT 5 AS c1 FROM dual WHERE LEAST(1e0, NULL); +c1 +CREATE TABLE t0 (c0 DOUBLE); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +c0 +SELECT * FROM t0 WHERE LEAST(c0, NULL); +c0 +DROP TABLE t0; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_hybrid_type.test b/mysql-test/main/func_hybrid_type.test index 508cdcfb668..2ebfb3cfdf1 100644 --- a/mysql-test/main/func_hybrid_type.test +++ b/mysql-test/main/func_hybrid_type.test @@ -1115,6 +1115,29 @@ SELECT 0x20+ROW(1,1); --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION SELECT @@max_allowed_packet=ROW(1,1); +--echo # +--echo # MDEV-21034 GREATEST() and LEAST() malfunction for NULL +--echo # + +SELECT 5 AS c1 FROM dual WHERE GREATEST(1, NULL); +SELECT 5 AS c1 FROM dual WHERE LEAST(1, NULL); + +CREATE TABLE t0 (c0 INT); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +SELECT * FROM t0 WHERE LEAST(c0, NULL); +DROP TABLE t0; + +SELECT 5 AS c1 FROM dual WHERE GREATEST(1e0, NULL); +SELECT 5 AS c1 FROM dual WHERE LEAST(1e0, NULL); + +CREATE TABLE t0 (c0 DOUBLE); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +SELECT * FROM t0 WHERE LEAST(c0, NULL); +DROP TABLE t0; + + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_func.cc b/sql/item_func.cc index f6fa613cba6..b6f601ec82b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3022,7 +3022,7 @@ double Item_func_min_max::val_real_native() value=tmp; } if ((null_value= args[i]->null_value)) - break; + return 0; } return value; } @@ -3043,7 +3043,7 @@ longlong Item_func_min_max::val_int_native() value=tmp; } if ((null_value= args[i]->null_value)) - break; + return 0; } return value; } From e02077aa03c9451bd89cccb75c6e52597f1c12cf Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 23 Apr 2024 09:55:49 +0400 Subject: [PATCH 03/23] MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result This problem was earlier fixed by the patch for MDEV 33344. Adding a test case only. --- mysql-test/main/func_regexp.result | 14 ++++++++++++++ mysql-test/main/func_regexp.test | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/mysql-test/main/func_regexp.result b/mysql-test/main/func_regexp.result index e0a4702c095..8e32732e12d 100644 --- a/mysql-test/main/func_regexp.result +++ b/mysql-test/main/func_regexp.result @@ -178,4 +178,18 @@ select 'foo' regexp x from t1 order by x desc; 0 1 drop table t1; +# +# MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result +# +CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR UNIQUE); +INSERT INTO t0 VALUES (0, 1); +INSERT INTO t0 VALUES (0, ''); +SELECT (c1 RLIKE c1), (c0 IS NULL) FROM t0; +(c1 RLIKE c1) (c0 IS NULL) +1 0 +1 0 +SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a; +SUM(a.t) +0 +DROP TABLE t0; # End of 10.5 tests diff --git a/mysql-test/main/func_regexp.test b/mysql-test/main/func_regexp.test index b9e2ef197d6..48a273f6979 100644 --- a/mysql-test/main/func_regexp.test +++ b/mysql-test/main/func_regexp.test @@ -121,4 +121,16 @@ select 'foo' regexp x from t1 order by x asc; select 'foo' regexp x from t1 order by x desc; drop table t1; +--echo # +--echo # MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result +--echo # + +CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR UNIQUE); +INSERT INTO t0 VALUES (0, 1); +INSERT INTO t0 VALUES (0, ''); +SELECT (c1 RLIKE c1), (c0 IS NULL) FROM t0; +SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a; +DROP TABLE t0; + + --echo # End of 10.5 tests From e73181112f684debb7246a298fabc4cbce04eb9b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 23 Apr 2024 10:55:17 +0200 Subject: [PATCH 04/23] MDEV-16944 fix galera tests followup for 061adae9a26e --- mysql-test/suite/galera/t/MDEV-26597.test | 2 +- mysql-test/suite/galera/t/MDEV-29142.test | 4 ++-- mysql-test/suite/galera/t/galera_wsrep_new_cluster.test | 2 +- .../suite/galera_sr/t/galera_sr_kill_all_norecovery.test | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/galera/t/MDEV-26597.test b/mysql-test/suite/galera/t/MDEV-26597.test index 783a52cad50..465f1130443 100644 --- a/mysql-test/suite/galera/t/MDEV-26597.test +++ b/mysql-test/suite/galera/t/MDEV-26597.test @@ -18,7 +18,7 @@ SHOW WARNINGS; SET SESSION wsrep_sync_wait = 0; --source include/kill_galera.inc ---let $start_mysqld_params = "" +--let $start_mysqld_params = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc diff --git a/mysql-test/suite/galera/t/MDEV-29142.test b/mysql-test/suite/galera/t/MDEV-29142.test index 7e9776b005b..f7a8b329089 100644 --- a/mysql-test/suite/galera/t/MDEV-29142.test +++ b/mysql-test/suite/galera/t/MDEV-29142.test @@ -50,12 +50,12 @@ SET SESSION wsrep_sync_wait = 0; --source include/kill_galera.inc --remove_file $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat ---let $start_mysqld_params = "--wsrep-new-cluster" +--let $start_mysqld_params =--wsrep-new-cluster --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/start_mysqld.inc --connection node_2 ---let $start_mysqld_params = "" +--let $start_mysqld_params = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test index 94ea008cb16..cfa5f8bcead 100644 --- a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test +++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test @@ -30,7 +30,7 @@ --echo Starting server ... --let $restart_noprint=2 ---let $start_mysqld_params="--wsrep-new-cluster" +--let $start_mysqld_params=--wsrep-new-cluster --source include/start_mysqld.inc --source include/wait_until_ready.inc diff --git a/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test b/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test index 5332b1a1579..f6f50fd50c9 100644 --- a/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test +++ b/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test @@ -38,12 +38,12 @@ SET SESSION wsrep_sync_wait = 0; --source include/kill_galera.inc --remove_file $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat ---let $start_mysqld_params = "--wsrep-new-cluster" +--let $start_mysqld_params =--wsrep-new-cluster --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/start_mysqld.inc --connection node_2 ---let $start_mysqld_params = "" +--let $start_mysqld_params = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc From 55cb2c2916a26b699ed8260427002243682c7110 Mon Sep 17 00:00:00 2001 From: Meng-Hsiu Chiang Date: Wed, 13 Mar 2024 20:16:56 +0000 Subject: [PATCH 05/23] MDEV-29955: Set path for zlib library with pkg-config `FindZLIB` module uses variable `ZLIB_ROOT`[1] to look for libraries. By setting the variable, `FindZLIB` is able to search the libraries that installed in a non-system path (/workspace/mylib for example). And when using `z` in `LINK_LIBRARIES()` CMake tries to lookup the library in system path by default. It doesn't work if the library isn't installed in the path, and use ${ZLIB_LIBRARY} which set by FindZLIB solve the issue. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services. [1]: https://cmake.org/cmake/help/latest/module/FindZLIB.html#hints --- cmake/zlib.cmake | 8 ++++++-- storage/maria/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 9e085189e4f..ee47eb427d9 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -37,10 +37,14 @@ MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) IF(WITH_ZLIB STREQUAL "bundled") MYSQL_USE_BUNDLED_ZLIB() ELSE() - INCLUDE(FindZLIB) + FIND_PACKAGE(PkgConfig QUIET) + IF(PKG_CONFIG_FOUND AND (COMMAND PKG_GET_VARIABLE) AND (NOT WIN32)) + PKG_GET_VARIABLE(ZLIB_ROOT zlib prefix) + ENDIF() + FIND_PACKAGE(ZLIB) IF(ZLIB_FOUND) INCLUDE(CheckFunctionExists) - SET(CMAKE_REQUIRED_LIBRARIES z) + SET(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES}) CHECK_FUNCTION_EXISTS(crc32 HAVE_CRC32) CHECK_FUNCTION_EXISTS(compressBound HAVE_COMPRESSBOUND) CHECK_FUNCTION_EXISTS(deflateBound HAVE_DEFLATEBOUND) diff --git a/storage/maria/CMakeLists.txt b/storage/maria/CMakeLists.txt index f55d78f0162..a566580dca3 100644 --- a/storage/maria/CMakeLists.txt +++ b/storage/maria/CMakeLists.txt @@ -124,7 +124,7 @@ ENDIF() IF (CURL_FOUND) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) MYSQL_ADD_PLUGIN(s3 ha_s3.cc ${S3_SOURCES} COMPONENT s3-engine - LINK_LIBRARIES ${CURL_LIBRARIES} z STORAGE_ENGINE NOT_EMBEDDED CONFIG s3.cnf) + LINK_LIBRARIES ${CURL_LIBRARIES} ${ZLIB_LIBRARY} STORAGE_ENGINE NOT_EMBEDDED CONFIG s3.cnf) ENDIF() SET(CPACK_RPM_s3-engine_PACKAGE_SUMMARY "Amazon S3 archival storage engine for MariaDB" PARENT_SCOPE) From e2f95ebbcbb958825294a3c58369037b4991cc6b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 23 Apr 2024 14:45:23 +0200 Subject: [PATCH 06/23] fix galera_3nodes.galera_gtid_consistency to work with nc like other galera tests do --- mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf b/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf index 5bd03178d1f..c27490faf36 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf +++ b/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf @@ -33,3 +33,6 @@ log_slave_updates=ON log_bin=mariadb-bin-log binlog-format=row wsrep-gtid-mode=ON + +[sst] +transferfmt=@ENV.MTR_GALERA_TFMT From 259394aed7d3411bb582354fbc31d2257f231f70 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 23 Apr 2024 15:11:52 +0200 Subject: [PATCH 07/23] disable mariabackup.incremental_encrypted,64k on 32bit it allocates 1GB of memory, it causes failures in CI --- mysql-test/suite/mariabackup/incremental_encrypted.test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/suite/mariabackup/incremental_encrypted.test b/mysql-test/suite/mariabackup/incremental_encrypted.test index d5570f20006..a2fb7e74565 100644 --- a/mysql-test/suite/mariabackup/incremental_encrypted.test +++ b/mysql-test/suite/mariabackup/incremental_encrypted.test @@ -7,6 +7,12 @@ if (!$EXAMPLE_KEY_MANAGEMENT_SO) } call mtr.add_suppression("InnoDB: New log files created"); +if (`select @@innodb_page_size=65536`) +{ + # this needs too much memory for 32bit + source include/have_64bit.inc; +} + let $basedir=$MYSQLTEST_VARDIR/tmp/backup; let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; From 7d5e08de6bc14da565f2f73a85814a6431295814 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 24 Apr 2024 18:08:46 +0200 Subject: [PATCH 08/23] MDEV-20157 perfschema.stage_mdl_function failed in buildbot with wrong result MDL wait consists of short 1 second waits (this is not configurable) repeated until lock_wait_timeout is reached. The stage is changed to Waiting and back every second. To have predictable result in the test the query should filter all sequences of X, "Waiting for MDL", X, leaving just X. --- .../suite/perfschema/include/stage_setup.inc | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/perfschema/include/stage_setup.inc b/mysql-test/suite/perfschema/include/stage_setup.inc index 683c4561c15..ba97d9094a9 100644 --- a/mysql-test/suite/perfschema/include/stage_setup.inc +++ b/mysql-test/suite/perfschema/include/stage_setup.inc @@ -121,12 +121,23 @@ begin where thread_id = my_thread_id and nesting_event_id = my_statement_id order by event_id asc; - # Ignore query cache as it may not be enabled - select username, event_name, nesting_event_type - from performance_schema.events_stages_history - where thread_id = my_thread_id - and nesting_event_id = my_statement_id and - event_name not like "%query cache%" + # 1. Ignore query cache as it may not be enabled + # 2. MDL wait consists of short 1 second waits (this is not configurable) + # repeated until lock_wait_timeout is reached. The stage is changed + # to Waiting and back every second. To have predictable result here + # the query filters all sequences of X, "Waiting for MDL", X, + # leaving just X. + with h as ( + select event_id, username, event_name, nesting_event_type, + lag(event_name) over (order by event_id) = lead(event_name) over (order by event_id) + and event_name = "stage/sql/Waiting for stored function metadata lock" as v1, + lag(event_name, 2) over (order by event_id) = event_name + and lag(event_name, 1) over (order by event_id) = "stage/sql/Waiting for stored function metadata lock" as v2 + from performance_schema.events_stages_history + where thread_id = my_thread_id + and nesting_event_id = my_statement_id and + event_name not like "%query cache%" + ) select username, event_name, nesting_event_type from h where v1 is not true and v2 is not true order by event_id asc; end; else From 7229384256f370c819bc2685bf8160be8f5cba79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 07:48:57 +0300 Subject: [PATCH 09/23] MDEV-23974 fixup: Cover all debug builds While commit 75b7cd680b8272ac5a0848791757c1d310501574 was a significant improvement, we occasionally got test failures of debug builds. One of the affected tests is innodb.innodb-64k-crash. --- mysql-test/include/have_innodb.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/include/have_innodb.inc b/mysql-test/include/have_innodb.inc index 8c9cdb54363..1e853d186b1 100644 --- a/mysql-test/include/have_innodb.inc +++ b/mysql-test/include/have_innodb.inc @@ -3,6 +3,11 @@ # will be skipped unless innodb is enabled # --disable_query_log +if (`select version() like '%debug%'`) +{ +SET STATEMENT sql_log_bin=0 FOR +call mtr.add_suppression("InnoDB: Trying to delete tablespace.*pending operations"); +} if (`select count(*) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like 'MSAN%'`) { SET STATEMENT sql_log_bin=0 FOR From 8c8b7da0179929058e4a68541fb3d11ac87d48f0 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 25 Apr 2024 10:50:34 +0530 Subject: [PATCH 10/23] MDEV-33979 Disallow bulk insert operation during partition update statement Problem: ======== - Partition update operation enables the bulk insert for the transaction while moving the row between partitions. This leads to debug assert failure while removing the row from one of the partition. Solution: ======== - Disallow the bulk insert operation for non-insert operation of partition table. --- mysql-test/suite/innodb/r/insert_into_empty.result | 9 +++++++++ mysql-test/suite/innodb/t/insert_into_empty.test | 10 ++++++++++ storage/innobase/handler/ha_innodb.cc | 1 + storage/innobase/row/row0ins.cc | 4 +++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index ef7d015f7f3..fdf66681b5d 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -251,4 +251,13 @@ c1 1984 3331 DROP TABLE t1; +# +# MDEV-33979 Disallow bulk insert operation during +# partition update statement +# +CREATE TABLE t1(a INT KEY)ENGINE=InnoDB +PARTITION BY KEY(a) PARTITIONS 16; +INSERT INTO t1 VALUES(1); +UPDATE t1 SET a = 2 WHERE a = 1; +DROP TABLE t1; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index 010b7ecb43a..67afaeb8eba 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -269,4 +269,14 @@ connection default; disconnect con1; SELECT * FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-33979 Disallow bulk insert operation during +--echo # partition update statement +--echo # +CREATE TABLE t1(a INT KEY)ENGINE=InnoDB + PARTITION BY KEY(a) PARTITIONS 16; +INSERT INTO t1 VALUES(1); +UPDATE t1 SET a = 2 WHERE a = 1; +DROP TABLE t1; --echo # End of 10.6 tests diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 418f39885f7..7099680d2b2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -8776,6 +8776,7 @@ ha_innobase::delete_row( : PLAIN_DELETE; trx->fts_next_doc_id = 0; + ut_ad(!trx->is_bulk_insert()); error = row_update_for_mysql(m_prebuilt); #ifdef WITH_WSREP diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 9897c813f02..6995a0d5c7b 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2708,7 +2708,9 @@ err_exit: && !index->table->skip_alter_undo && !index->table->n_rec_locks && !index->table->is_active_ddl() - && !index->table->versioned()) { + && !index->table->versioned() + && (!dict_table_is_partition(index->table) + || thd_sql_command(trx->mysql_thd) == SQLCOM_INSERT)) { DEBUG_SYNC_C("empty_root_page_insert"); if (!index->table->is_temporary()) { From a1c1f5029e2e394b83a19e13b8a8c05e148409aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 11:05:03 +0300 Subject: [PATCH 11/23] MDEV-33974 Enable GNU libstdc++ debugging Starting with GCC 10, let us enable _GLIBCXX_DEBUG as well as _GLIBCXX_ASSERTIONS which have an impact on the GNU libstdc++. On GCC 8, we observed a compilation failure related to some missing type conversion. Even though clang on GNU/Linux would default to using libstdc++ and enabling the debugging seems to work with clang-18, we will not enable this on clang, in case it would lead to compilation errors. For the clang libc++ before clang-15 there was _LIBCPP_DEBUG, but according to llvm/llvm-project@f3966eaf869b7bdd9113ab9d5b78469eb0f5f028 and llvm/llvm-project@13ea1343231fa4ae12fe9fba4c789728465783d7 and llvm/llvm-project@ff573a42cd1f1d05508f165dc3e645a0ec17edb5 it looks like that for proper results, a specially built debug version of libc++ would have to be used in order to enable equivalent checks. This should help catch bugs like the one that commit 455a15fd06b0f449e72e6b10b0474e4139eeeca2 fixed. Reviewed by: Sergei Golubchik --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 129e25f8e8b..a01ebcf57eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,8 +276,6 @@ IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN AND MY_CHECK_AND_SET_COMPILER_FLAG("-D_FORTIFY_SOURCE=2" RELEASE RELWITHDEBINFO) ENDIF() -INCLUDE(wsrep) - OPTION(WITH_DBUG_TRACE "Enable DBUG_ENTER()/DBUG_RETURN()/DBUG_PRINT()" ON) IF(WITH_DBUG_TRACE) FOREACH(LANG C CXX) @@ -288,7 +286,12 @@ ENDIF() # Always enable debug sync for debug builds. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC") - + +IF(CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10") + # Enable extra checks when using a recent enough version of GNU libstdc++ + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -D_GLIBCXX_ASSERTIONS") +ENDIF() + OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF) IF (ENABLE_GCOV) MY_CHECK_AND_SET_COMPILER_FLAG("-fprofile-arcs -ftest-coverage -lgcov" DEBUG) @@ -349,6 +352,8 @@ ELSEIF(TRASH_FREED_MEMORY MATCHES "AUTO" AND NOT WIN32 AND NOT WITH_VALGRIND AND SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTRASH_FREED_MEMORY") ENDIF() +INCLUDE(wsrep) + # Set commonly used variables IF(WIN32) SET(DEFAULT_MYSQL_HOME "C:/Program Files/MariaDB ${MYSQL_BASE_VERSION}") From 553a4d6271104f96717d3846dd389ba0c603a036 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 23 Apr 2024 21:02:08 +0200 Subject: [PATCH 12/23] MDEV-33602: Sporadic test failure in rpl.rpl_gtid_stop_start The test could fail with a duplicate key error because switching to non-GTID mode could start at the wrong old-style position. The position could be wrong when the previous GTID connect was stopped before receiving the fake GTID list event which gives the old-style position corresponding to the GTID connected position. Work-around by injecting an extra event and syncing the slave before switching to non-GTID mode. Signed-off-by: Kristian Nielsen --- .../suite/rpl/r/rpl_gtid_stop_start.result | 4 ++++ .../suite/rpl/t/rpl_gtid_stop_start.test | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result index 50f24d56e9a..788f8bdfc06 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result @@ -112,6 +112,10 @@ a 6 7 *** MDEV-4486: Allow to start old-style replication even if mysql.gtid_slave_pos is unavailable +connection server_1; +INSERT INTO t1 VALUES (8); +DELETE FROM t1 WHERE a=8; +connection server_2; connection server_2; include/stop_slave.inc CHANGE MASTER TO master_use_gtid= no; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test index 8e41d6162ea..fc8c513e80d 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test @@ -170,6 +170,24 @@ SELECT * FROM t1 ORDER BY a; --echo *** MDEV-4486: Allow to start old-style replication even if mysql.gtid_slave_pos is unavailable +# In GTID mode, the old-style replication position is also updated. But during +# GTID connect, the old-style position is not known until receiving the fake +# GTID list event, which contains the required position value. If we happened +# to stop the slave above before this fake GTID list event, the test could fail +# with duplicate key errors due to switching to non-GTID mode at a wrong +# position too far back in the binlog. +# +# Work-around this by injecting an extra dummt event and syncing the slave to +# it, ensuring the old-style position will be updated. +# +# This work-around could be removed after MDEV-33996 is fixed. +--connection server_1 +INSERT INTO t1 VALUES (8); +DELETE FROM t1 WHERE a=8; +--save_master_pos +--connection server_2 +--sync_with_master + --connection server_2 --source include/stop_slave.inc CHANGE MASTER TO master_use_gtid= no; From 0936c13809f85972ed176abb764b925edd954256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 13:44:10 +0300 Subject: [PATCH 13/23] MDEV-33993 Possible server hang on DROP INDEX or RENAME INDEX commit_try_norebuild(): Add the parameter statistics_exist, similar to commit_try_rebuild(). If the InnoDB statistics tables did not exist, we will not attempt to update statistics later on during the transaction. Thanks to Matthias Leich for originally reproducing this scenario. --- .../suite/innodb/r/innodb-alter-debug.result | 15 +++++++++++-- .../suite/innodb/t/innodb-alter-debug.test | 22 +++++++++++++++---- storage/innobase/handler/handler0alter.cc | 16 ++++++++++++-- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result index c55b4a3ddd5..fd33581ffab 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-debug.result +++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result @@ -108,11 +108,11 @@ DROP TABLE t; # MDEV-26772 InnoDB DDL fails with DUPLICATE KEY error # create table t1(f1 int not null primary key, -f2 int not null, index idx(f2))engine=innodb; +f2 int not null, index idx(f2), index i(f2,f1))engine=innodb; insert into t1 values(1, 1); connect con1,localhost,root,,,; SET DEBUG_SYNC='before_delete_table_stats SIGNAL blocked WAIT_FOR go'; -SET innodb_lock_wait_timeout=0; +SET STATEMENT innodb_lock_wait_timeout=0 FOR ALTER TABLE t1 FORCE, ALGORITHM=COPY; connection default; SET DEBUG_SYNC='now WAIT_FOR blocked'; @@ -124,6 +124,17 @@ connection con1; connection default; COMMIT; SET DEBUG_SYNC=RESET; +RENAME TABLE mysql.innodb_table_stats TO mysql.innodb_table_stats_hidden; +connection con1; +SET DEBUG_SYNC='innodb_commit_inplace_before_lock SIGNAL blocked WAIT_FOR go'; +ALTER TABLE t1 DROP INDEX i; +connection default; +SET DEBUG_SYNC='now WAIT_FOR blocked'; +RENAME TABLE mysql.innodb_table_stats_hidden TO mysql.innodb_table_stats; +SET DEBUG_SYNC='now SIGNAL go'; +connection con1; +connection default; +SET DEBUG_SYNC=RESET; connection con1; ALTER TABLE t1 RENAME KEY idx TO idx1, ALGORITHM=COPY; disconnect con1; diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test index c4a68ac71b7..6b94bfd214f 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-debug.test +++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test @@ -144,15 +144,14 @@ DROP TABLE t; --echo # create table t1(f1 int not null primary key, - - f2 int not null, index idx(f2))engine=innodb; + f2 int not null, index idx(f2), index i(f2,f1))engine=innodb; insert into t1 values(1, 1); connect(con1,localhost,root,,,); SET DEBUG_SYNC='before_delete_table_stats SIGNAL blocked WAIT_FOR go'; -SET innodb_lock_wait_timeout=0; -send ALTER TABLE t1 FORCE, ALGORITHM=COPY; +send SET STATEMENT innodb_lock_wait_timeout=0 FOR +ALTER TABLE t1 FORCE, ALGORITHM=COPY; connection default; SET DEBUG_SYNC='now WAIT_FOR blocked'; @@ -167,6 +166,21 @@ connection default; COMMIT; SET DEBUG_SYNC=RESET; +RENAME TABLE mysql.innodb_table_stats TO mysql.innodb_table_stats_hidden; +connection con1; +SET DEBUG_SYNC='innodb_commit_inplace_before_lock SIGNAL blocked WAIT_FOR go'; +send ALTER TABLE t1 DROP INDEX i; + +connection default; +SET DEBUG_SYNC='now WAIT_FOR blocked'; +RENAME TABLE mysql.innodb_table_stats_hidden TO mysql.innodb_table_stats; +SET DEBUG_SYNC='now SIGNAL go'; + +connection con1; +reap; +connection default; +SET DEBUG_SYNC=RESET; + connection con1; ALTER TABLE t1 RENAME KEY idx TO idx1, ALGORITHM=COPY; disconnect con1; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 087a0c32319..63a5e56e666 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10228,6 +10228,7 @@ when rebuilding the table. @param ctx In-place ALTER TABLE context @param altered_table MySQL table that is being altered @param old_table MySQL table as it is before the ALTER operation +@param statistics_exist whether to update InnoDB persistent statistics @param trx Data dictionary transaction @param table_name Table name in MySQL @retval true Failure @@ -10501,6 +10502,7 @@ when not rebuilding the table. @param ha_alter_info Data used during in-place alter @param ctx In-place ALTER TABLE context @param old_table MySQL table as it is before the ALTER operation +@param statistics_exist whether to update InnoDB persistent statistics @param trx Data dictionary transaction @param table_name Table name in MySQL @retval true Failure @@ -10514,6 +10516,7 @@ commit_try_norebuild( ha_innobase_inplace_ctx*ctx, TABLE* altered_table, const TABLE* old_table, + bool statistics_exist, trx_t* trx, const char* table_name) { @@ -10628,6 +10631,10 @@ commit_try_norebuild( goto handle_error; } + if (!statistics_exist) { + continue; + } + error = dict_stats_delete_from_index_stats(db, table, index->name, trx); switch (error) { @@ -10639,7 +10646,8 @@ commit_try_norebuild( } } - if (const size_t size = ha_alter_info->rename_keys.size()) { + if (!statistics_exist) { + } else if (const size_t size = ha_alter_info->rename_keys.size()) { char tmp_name[5]; char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN]; @@ -11386,6 +11394,8 @@ err_index: } } + DEBUG_SYNC(m_user_thd, "innodb_commit_inplace_before_lock"); + DBUG_EXECUTE_IF("stats_lock_fail", error = DB_LOCK_WAIT_TIMEOUT; trx_rollback_for_mysql(trx);); @@ -11469,7 +11479,9 @@ fail: goto fail; } } else if (commit_try_norebuild(ha_alter_info, ctx, - altered_table, table, trx, + altered_table, table, + table_stats && index_stats, + trx, table_share->table_name.str)) { goto fail; } From 10d251e05a4b797860081c9c289d9d2e6ed08703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 15:52:38 +0300 Subject: [PATCH 14/23] MDEV-26450 fixup: Remove a bogus assertion mtr_t::commit_shrink(): Do not assert that some previously clean pages will be flagged as modified by this mini-transaction. It could be the case that there had been no recent write-back of any of the undo tablespace pages that we are modifying when truncating the tablespace. It suffices to assert that some pages were modified again: ut_ad(m_modifications). This fixes up commit f5fddae3cbcff2d2531f0ce61bd144212379aa42 --- storage/innobase/mtr/mtr0mtr.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index bf4b2b6b07c..4f730dd4eff 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -572,7 +572,6 @@ void mtr_t::commit_shrink(fil_space_t &space) ut_ad(!is_inside_ibuf()); ut_ad(!high_level_read_only); ut_ad(m_modifications); - ut_ad(m_made_dirty); ut_ad(!recv_recovery_is_on()); ut_ad(m_log_mode == MTR_LOG_ALL); ut_ad(UT_LIST_GET_LEN(space.chain) == 1); From b3e531a3cc5292536f2e6edf3746ff1f8c35775f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 12 Apr 2024 10:10:29 +0300 Subject: [PATCH 15/23] MDEV-33896 : Galera test failure on galera_3nodes.MDEV-29171 Based on logs we might start SST before donor has reached Primary state. Because this test shutdowns all nodes we need to make sure when we start nodes that previous nodes have reached Primary state and joined the cluster. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera_3nodes/disabled.def | 1 - .../suite/galera_3nodes/r/MDEV-29171.result | 20 ++++++++++ .../suite/galera_3nodes/t/MDEV-29171.test | 37 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index 02479c1362e..de7d8e755c7 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -16,5 +16,4 @@ galera_ssl_reload : MDEV-32778 galera_ssl_reload failed with warning message galera_ipv6_mariabackup : temporarily disabled at the request of Codership galera_pc_bootstrap : temporarily disabled at the request of Codership galera_ipv6_mariabackup_section : temporarily disabled at the request of Codership -MDEV-29171 : MDEV-33842 galera_3nodes.MDEV-29171 fails on shutdown_server GCF-354 : MDEV-25614 Galera test failure on GCF-354 diff --git a/mysql-test/suite/galera_3nodes/r/MDEV-29171.result b/mysql-test/suite/galera_3nodes/r/MDEV-29171.result index 371ce006dd3..55513ff53af 100644 --- a/mysql-test/suite/galera_3nodes/r/MDEV-29171.result +++ b/mysql-test/suite/galera_3nodes/r/MDEV-29171.result @@ -19,20 +19,40 @@ connection node_2; connection node_1; connection node_1; # restart: --wsrep_new_cluster --wsrep_gtid_domain_id=200 +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +VARIABLE_VALUE +Primary +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE +Synced show variables like 'wsrep_gtid_domain_id'; Variable_name Value wsrep_gtid_domain_id 200 connection node_2; # restart +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +VARIABLE_VALUE +Primary +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE +Synced show variables like 'wsrep_gtid_domain_id'; Variable_name Value wsrep_gtid_domain_id 200 +connection node_1; connection node_3; # restart: --wsrep_sst_donor=node2 +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +VARIABLE_VALUE +Primary +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE +Synced show variables like 'wsrep_gtid_domain_id'; Variable_name Value wsrep_gtid_domain_id 200 connection node_1; +connection node_1; set global wsrep_gtid_domain_id=100; connection node_2; set global wsrep_gtid_domain_id=100; diff --git a/mysql-test/suite/galera_3nodes/t/MDEV-29171.test b/mysql-test/suite/galera_3nodes/t/MDEV-29171.test index bfb7abf9a8b..1ce33bee974 100644 --- a/mysql-test/suite/galera_3nodes/t/MDEV-29171.test +++ b/mysql-test/suite/galera_3nodes/t/MDEV-29171.test @@ -50,6 +50,16 @@ select @@wsrep_gtid_domain_id,@@wsrep_node_name; --connection node_1 --let $restart_parameters = --wsrep_new_cluster --wsrep_gtid_domain_id=200 --source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; show variables like 'wsrep_gtid_domain_id'; # @@ -59,8 +69,21 @@ show variables like 'wsrep_gtid_domain_id'; --let $restart_parameters = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; show variables like 'wsrep_gtid_domain_id'; +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc # # Restart node_3, select node_2 as donor @@ -70,9 +93,23 @@ show variables like 'wsrep_gtid_domain_id'; --let $restart_parameters = --wsrep_sst_donor="node2" --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect --source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; + # Expect domain id 200 show variables like 'wsrep_gtid_domain_id'; +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc # # Cleanup From ef7a2344af2392365333da9ca40ede159e3fc398 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 25 Apr 2024 15:21:16 +0200 Subject: [PATCH 16/23] Fixup 0ccdf54b644352f42e1768bc660be7ab50c1e9d 0ccdf54 removed stack allocated THD objects from functions Wsrep_schema::replay_transaction(). However, it inadvertedly anticipated the destruction of the THD, causing assertions and usage of THD after it was destroyed. The fix consists in extracting the original function into a separate function, and leave the allocation and destruction of the THD object in Wsrep_schema::replay_transaction(), making sure that using the heap allocated THD has no side effects. Same for Wsrep_schema::recover_sr_transactions(). Signed-off-by: Julius Goryavsky --- sql/wsrep_schema.cc | 91 +++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index 2473d20b20d..32ce8310bc4 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -1244,25 +1244,12 @@ int Wsrep_schema::remove_fragments(THD* thd, DBUG_RETURN(ret); } -int Wsrep_schema::replay_transaction(THD* orig_thd, - Relay_log_info* rli, - const wsrep::ws_meta& ws_meta, - const std::vector& fragments) +static int replay_transaction(THD* thd, + THD* orig_thd, + Relay_log_info* rli, + const wsrep::ws_meta& ws_meta, + const std::vector& fragments) { - DBUG_ENTER("Wsrep_schema::replay_transaction"); - DBUG_ASSERT(!fragments.empty()); - - THD *thd= new THD(next_thread_id(), true); - if (!thd) - { - WSREP_WARN("Could not open allocate memory for THD"); - DBUG_RETURN(1); - } - - thd->thread_stack= (orig_thd ? orig_thd->thread_stack : - (char*) &thd); - wsrep_assign_from_threadvars(thd); - Wsrep_schema_impl::wsrep_off wsrep_off(thd); Wsrep_schema_impl::binlog_off binlog_off(thd); Wsrep_schema_impl::sql_safe_updates sql_safe_updates(thd); @@ -1283,8 +1270,7 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, { WSREP_WARN("Could not open SR table for read: %d", error); Wsrep_schema_impl::finish_stmt(thd); - my_free(thd); - DBUG_RETURN(1); + return 1; } frag_table= frag_table_l.table; @@ -1370,24 +1356,36 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, if (key) my_free(key); + + return ret; +} + +int Wsrep_schema::replay_transaction(THD* orig_thd, + Relay_log_info* rli, + const wsrep::ws_meta& ws_meta, + const std::vector& fragments) +{ + DBUG_ENTER("Wsrep_schema::replay_transaction"); + DBUG_ASSERT(!fragments.empty()); + + THD *thd= new THD(next_thread_id(), true); + if (!thd) + { + WSREP_WARN("Could not allocate memory for THD"); + DBUG_RETURN(1); + } + + thd->thread_stack= (orig_thd ? orig_thd->thread_stack : (char *) &thd); + wsrep_assign_from_threadvars(thd); + + int ret= ::replay_transaction(thd, orig_thd, rli, ws_meta, fragments); + delete thd; DBUG_RETURN(ret); } - -int Wsrep_schema::recover_sr_transactions(THD *orig_thd) +static int recover_sr_transactions(THD* storage_thd, THD* orig_thd) { - DBUG_ENTER("Wsrep_schema::recover_sr_transactions"); - - THD *storage_thd= new THD(next_thread_id(), true); - if (!storage_thd) - { - WSREP_WARN("Could not open allocate memory for THD"); - DBUG_RETURN(1); - } - storage_thd->thread_stack= (orig_thd ? orig_thd->thread_stack : - (char*) &storage_thd); - wsrep_assign_from_threadvars(storage_thd); TABLE* frag_table= 0; TABLE_LIST frag_table_l; TABLE* cluster_table= 0; @@ -1410,14 +1408,14 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) &cluster_table_l)) { Wsrep_schema_impl::finish_stmt(storage_thd); - DBUG_RETURN(1); + return 1; } cluster_table= cluster_table_l.table; if (Wsrep_schema_impl::init_for_scan(cluster_table)) { Wsrep_schema_impl::finish_stmt(storage_thd); - DBUG_RETURN(1); + return 1; } if ((error= Wsrep_schema_impl::next_record(cluster_table))) @@ -1428,12 +1426,12 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) if (error == HA_ERR_END_OF_FILE) { WSREP_INFO("Cluster table is empty, not recovering transactions"); - DBUG_RETURN(0); + return 0; } else { WSREP_ERROR("Failed to read cluster table: %d", error); - DBUG_RETURN(1); + return 1; } } @@ -1540,6 +1538,25 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) trans_commit(storage_thd); storage_thd->set_mysys_var(0); out: + return ret; +} + +int Wsrep_schema::recover_sr_transactions(THD *orig_thd) +{ + DBUG_ENTER("Wsrep_schema::recover_sr_transactions"); + + THD *storage_thd= new THD(next_thread_id(), true); + if (!storage_thd) + { + WSREP_WARN("Could not allocate memory for THD"); + DBUG_RETURN(1); + } + storage_thd->thread_stack= + (orig_thd ? orig_thd->thread_stack : (char *) &storage_thd); + wsrep_assign_from_threadvars(storage_thd); + + int ret= ::recover_sr_transactions(storage_thd, orig_thd); + delete storage_thd; DBUG_RETURN(ret); } From 3d4174762563afcc2532e86c5a6c5686daa52fad Mon Sep 17 00:00:00 2001 From: Hugo Wen Date: Wed, 20 Mar 2024 12:46:39 -0700 Subject: [PATCH 17/23] MDEV-33574 Improve mysqlbinlog error message Previously, when running mysqlbinlog without providing a binlog file, it would print the entire help text, which was very verbose and made it difficult to identify the actual issue. Now change the behavior to print a more concise error message instead: "ERROR: Please provide the log file(s). Run with '--help' for usage instructions." This makes the error output more user-friendly and easier to understand, especially when running the tool in scripts or automated processes. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- client/mysqlbinlog.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d7f3a39aff2..6abfd32208d 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2997,7 +2997,8 @@ int main(int argc, char** argv) { if (!opt_version) { - usage(); + error("Please provide the log file(s). Run with '--help' for usage " + "instructions."); retval= ERROR_STOP; } goto err; From 3141a68b7ce00852b54d9ce363907897c060a640 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 26 Apr 2024 11:57:25 +0400 Subject: [PATCH 18/23] MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc| The negation in this line: ulonglong abs_dec= dec_negative ? -dec : dec; did not take into account that 'dec' can be the smallest possible signed negative value -9223372036854775808. Its negation is an operation with an undefined behavior. Fixing the code to use Longlong_hybrid, which implements a safe method to get an absolute value. --- mysql-test/main/func_math.result | 15 +++++++++++++++ mysql-test/main/func_math.test | 10 ++++++++++ sql/item_func.cc | 22 ++++++++++++---------- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index 98d5fdcf3d0..4296a983d71 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -3617,5 +3617,20 @@ SELECT CRC32(ExtractValue('', '/a/b')) AS f; f 0 # +# MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc| +# +SELECT TRUNCATE(EXP(-1.e-2),-1.e+30) AS c1; +c1 +0 +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) AS c1; +c1 +0 +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; +c1 +0 +SELECT(ASIN(-1)+ LN(-1)) % (ATAN(-1) MOD FLOOR(1)) * (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; +c1 +NULL +# # End of 10.5 tests # diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test index 171975859e3..dbeefa94d59 100644 --- a/mysql-test/main/func_math.test +++ b/mysql-test/main/func_math.test @@ -1929,6 +1929,16 @@ DROP TABLE t2, t1; SELECT CRC32(ExtractValue('', '/a/b')) AS f; +--echo # +--echo # MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc| +--echo # + +SELECT TRUNCATE(EXP(-1.e-2),-1.e+30) AS c1; +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) AS c1; +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; +SELECT(ASIN(-1)+ LN(-1)) % (ATAN(-1) MOD FLOOR(1)) * (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; + + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_func.cc b/sql/item_func.cc index b6f601ec82b..1e6fa039059 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2638,12 +2638,12 @@ void Item_func_round::fix_arg_hex_hybrid() } -double my_double_round(double value, longlong dec, bool dec_unsigned, +double my_double_round(double value, longlong dec_value, bool dec_unsigned, bool truncate) { double tmp; - bool dec_negative= (dec < 0) && !dec_unsigned; - ulonglong abs_dec= dec_negative ? -dec : dec; + const Longlong_hybrid dec(dec_value, dec_unsigned); + const ulonglong abs_dec= dec.abs(); /* tmp2 is here to avoid return the value with 80 bit precision This will fix that the test round(0.1,1) = round(0.1,1) is true @@ -2658,22 +2658,24 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, volatile double value_div_tmp= value / tmp; volatile double value_mul_tmp= value * tmp; - if (!dec_negative && std::isinf(tmp)) // "dec" is too large positive number + if (!dec.neg() && std::isinf(tmp)) // "dec" is a too large positive number return value; - if (dec_negative && std::isinf(tmp)) - tmp2= 0.0; - else if (!dec_negative && std::isinf(value_mul_tmp)) + if (dec.neg() && std::isinf(tmp)) // "dec" is a too small negative number + return 0.0; + + // Handle "dec" with a reasonably small absolute value + if (!dec.neg() && std::isinf(value_mul_tmp)) tmp2= value; else if (truncate) { if (value >= 0.0) - tmp2= dec < 0 ? floor(value_div_tmp) * tmp : floor(value_mul_tmp) / tmp; + tmp2= dec.neg() ? floor(value_div_tmp) * tmp : floor(value_mul_tmp) / tmp; else - tmp2= dec < 0 ? ceil(value_div_tmp) * tmp : ceil(value_mul_tmp) / tmp; + tmp2= dec.neg() ? ceil(value_div_tmp) * tmp : ceil(value_mul_tmp) / tmp; } else - tmp2=dec < 0 ? rint(value_div_tmp) * tmp : rint(value_mul_tmp) / tmp; + tmp2=dec.neg() ? rint(value_div_tmp) * tmp : rint(value_mul_tmp) / tmp; return tmp2; } From a09ebe5567694f13dd77876bf61ce3560dfed0e6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 26 Apr 2024 14:44:38 +0200 Subject: [PATCH 19/23] PCRE2-10.43 pcre2 - fix CMAKE_C_FLAGS for MSVC for external project by Vladislav Vaintroub --- cmake/pcre.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 65dc2ae28f6..5ef089aa686 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -46,16 +46,16 @@ MACRO(BUNDLE_PCRE2) SET(pcre2_flags${v} "${pcre2_flags${v}} -std=c99 ") IF(MSVC) # Suppress a warning - STRING(APPEND pcre2_flags${v} " /wd4244 " ) + STRING(APPEND pcre2_flags${v} " /wd4244 /wd4267 " ) # Disable asan support - STRING(REPLACE "-fsanitize=address" "" pcre2_flags${v} "${CMAKE_C_FLAGS${v}}") + STRING(REPLACE "-fsanitize=address" "" pcre2_flags${v} "${pcre2_flags${v}}") ENDIF() ENDFOREACH() ExternalProject_Add( pcre2 PREFIX "${dir}" - URL "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.zip" - URL_MD5 fe90992fbfb03f854bd9f344074f49eb + URL "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.43/pcre2-10.43.zip" + URL_MD5 b58f050f2fdd6f2ca5774a2975377a85 INSTALL_COMMAND "" CMAKE_ARGS "-DCMAKE_WARN_DEPRECATED=FALSE" From bda8d4fdf7d363b761d94a6dedf13ad58df54bf6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 26 Apr 2024 18:34:27 +0200 Subject: [PATCH 20/23] require boost 1.53 for columnstore --- storage/columnstore/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/columnstore/CMakeLists.txt b/storage/columnstore/CMakeLists.txt index 1b3b739b706..7c875251214 100644 --- a/storage/columnstore/CMakeLists.txt +++ b/storage/columnstore/CMakeLists.txt @@ -15,7 +15,7 @@ IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") # https://jira.mariadb.org/browse/MCOL-5611 - FIND_PACKAGE(Boost COMPONENTS system filesystem thread regex date_time chrono atomic) + FIND_PACKAGE(Boost 1.53 COMPONENTS system filesystem thread regex date_time chrono atomic) IF (${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_GREATER "1.79") MESSAGE_ONCE(CS_NO_BOOST "Boost Libraries >= 1.80.0 not supported!") return() From 52f6df99ed7179a6467a8c9078d21eb5add85870 Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Wed, 24 Apr 2024 19:53:13 +0530 Subject: [PATCH 21/23] MDEV-33669 mariabackup --backup hangs This is a server hang and not an issue with backup. While concurrent DDLs in server gets in hanged state, mariabackup waits for DDLs to finish trying to acquire MDL_BACKUP_BLOCK_DDL. The server hang is serious in nature and caused by thread pool state being incorrectly set to thread creation pending state while no creation is actually pending. Once a thread pool reaches such state no new thread gets created in the pool. While it could possibly affect all thread pools in server, the innodb thread pool is the victim in current bug where IO job gets blocked when the pool is stuck with much less number of threads than intended. Available workers are blocked in purge waiting for page lock to be released by IO write (SX lock) causing a complete deadlock. The issue is caused by the state variable m_thread_creation_pending introduced by MDEV-31095: 9e62ab7aafbf. We check and set the variable early while attempting to create a new thread in pool but fail to reset it if we exit the flow for other reasons like maximum threads reached or get into thread creation throttling path. Fix: The simple fix is to make sure that the state is reset back in case we don't actually attempt to create the thread. --- tpool/tpool_generic.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc index f0637044639..a4d6c405bdf 100644 --- a/tpool/tpool_generic.cc +++ b/tpool/tpool_generic.cc @@ -722,9 +722,6 @@ static int throttling_interval_ms(size_t n_threads,size_t concurrency) /* Create a new worker.*/ bool thread_pool_generic::add_thread() { - if (m_thread_creation_pending.test_and_set()) - return false; - size_t n_threads = thread_count(); if (n_threads >= m_max_threads) @@ -750,6 +747,14 @@ bool thread_pool_generic::add_thread() } } + /* Check and set "thread creation pending" flag before creating the thread. We + reset the flag in thread_pool_generic::worker_main in new thread created. The + flag must be reset back in case we fail to create the thread. If this flag is + not reset all future attempt to create thread for this pool would not work as + we would return from here. */ + if (m_thread_creation_pending.test_and_set()) + return false; + worker_data *thread_data = m_thread_data_cache.get(); m_active_threads.push_back(thread_data); try @@ -769,6 +774,7 @@ bool thread_pool_generic::add_thread() "current number of threads in pool %zu\n", e.what(), thread_count()); warning_written = true; } + m_thread_creation_pending.clear(); return false; } return true; From 267dd5a993d5432132c6479d766a6028b85f77fb Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 29 Apr 2024 16:17:22 +1000 Subject: [PATCH 22/23] MDEV-30727 Check spider_hton_ptr in spider udfs We have to #undef my_error and find it from udfs when spider is not installed. --- .../spider/bugfix/r/mdev_30727.result | 24 +++++++++++++++ .../spider/bugfix/t/mdev_30727.test | 30 +++++++++++++++++++ storage/spider/spd_copy_tables.cc | 8 +++++ storage/spider/spd_direct_sql.cc | 8 +++++ 4 files changed, 70 insertions(+) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result new file mode 100644 index 00000000000..ce8ebdc3966 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result @@ -0,0 +1,24 @@ +CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); +ERROR HY000: Plugin 'SPIDER' is not loaded +CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); +ERROR HY000: Plugin 'SPIDER' is not loaded +CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_copy_tables ('t', '0', '0'); +ERROR HY000: Plugin 'SPIDER' is not loaded +CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_flush_table_mon_cache (); +spider_flush_table_mon_cache () +1 +install soname 'ha_spider'; +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); +ERROR HY000: The foreign server name you are trying to reference does not exist. Data source error: b +call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'"); +SELECT spider_copy_tables ('t', '0', '0'); +ERROR HY000: Can't find record in 'spider_tables' +SELECT spider_flush_table_mon_cache (); +spider_flush_table_mon_cache () +1 +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test new file mode 100644 index 00000000000..e1d917e7147 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test @@ -0,0 +1,30 @@ +CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; +--error ER_PLUGIN_IS_NOT_LOADED +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); + +CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; +--error ER_PLUGIN_IS_NOT_LOADED +SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); + +CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; +--error ER_PLUGIN_IS_NOT_LOADED +SELECT spider_copy_tables ('t', '0', '0'); + +# spider_flush_table_mon_cache does not require spider init to function +CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_flush_table_mon_cache (); + +# The function functions properly after the plugin is installed +install soname 'ha_spider'; + +--error ER_FOREIGN_SERVER_DOESNT_EXIST +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); + +call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'"); +--error ER_KEY_NOT_FOUND +SELECT spider_copy_tables ('t', '0', '0'); + +SELECT spider_flush_table_mon_cache (); + +--disable_query_log +--source ../../include/clean_up_spider.inc diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index c2463ce30df..1783fe7374b 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -1154,12 +1154,20 @@ error: DBUG_RETURN(0); } +#undef my_error +extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...); + my_bool spider_copy_tables_init_body( UDF_INIT *initid, UDF_ARGS *args, char *message ) { DBUG_ENTER("spider_copy_tables_init_body"); + if (!spider_hton_ptr) + { + my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER"); + goto error; + } if (args->arg_count != 3 && args->arg_count != 4) { strcpy(message, "spider_copy_tables() requires 3 or 4 arguments"); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index fc8ba264b19..4f6bc0a4405 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1789,6 +1789,9 @@ error: DBUG_RETURN(0); } +#undef my_error +extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...); + my_bool spider_direct_sql_init_body( UDF_INIT *initid, UDF_ARGS *args, @@ -1797,6 +1800,11 @@ my_bool spider_direct_sql_init_body( ) { SPIDER_BG_DIRECT_SQL *bg_direct_sql; DBUG_ENTER("spider_direct_sql_init_body"); + if (!spider_hton_ptr) + { + my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER"); + goto error; + } if (args->arg_count != 3) { strcpy(message, "spider_(bg)_direct_sql() requires 3 arguments"); From 814dc46748d8c276f18c7664d8d14a543cff954c Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 27 Apr 2024 13:35:48 +0300 Subject: [PATCH 23/23] Fixed slow bootstrap introduced in 10.6 The problem was that the signal thread was not killed when using unireg_abort(). The bug was introduced by: MDEV-30260: Slave crashed:reload_acl_and_cache during shutdown Other things fixed: - Don't produce memory leaks with safemalloc if all threads was not ended properly (not useful) --- include/my_sys.h | 2 +- mysys/my_thr_init.c | 8 +++++--- sql/mysqld.cc | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 84a1e6a4752..d58e53d0bf3 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -153,7 +153,7 @@ char *guess_malloc_library(); void sf_report_leaked_memory(my_thread_id id); int sf_sanity(); extern my_thread_id (*sf_malloc_dbug_id)(void); -#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X) +#define SAFEMALLOC_REPORT_MEMORY(X) if (!sf_leaking_memory) sf_report_leaked_memory(X) #else #define SAFEMALLOC_REPORT_MEMORY(X) do {} while(0) #endif diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 2e8decd7d06..b2436d2be27 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -220,7 +220,11 @@ void my_thread_global_end(void) fprintf(stderr, "Error in my_thread_global_end(): %d threads didn't exit\n", THR_thread_count); -#endif +#endif /* HAVE_PTHREAD_KILL */ +#ifdef SAFEMALLOC + /* We know we will have memoryleaks, suppress the leak report */ + sf_leaking_memory= 1; +#endif /* SAFEMALLOC */ all_threads_killed= 0; break; } @@ -234,9 +238,7 @@ void my_thread_global_end(void) that could use them. */ if (all_threads_killed) - { my_thread_destroy_internal_mutex(); - } my_thread_global_init_done= 0; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0d2f1bd0309..6d7b09adc4c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1889,6 +1889,7 @@ extern "C" void unireg_abort(int exit_code) wsrep_sst_auth_free(); #endif // WITH_WSREP + wait_for_signal_thread_to_end(); clean_up(!opt_abort && (exit_code || !opt_bootstrap)); /* purecov: inspected */ DBUG_PRINT("quit",("done with cleanup in unireg_abort")); mysqld_exit(exit_code);