From 67ed4223131f1554e30a8ca4c49352461f62e44e Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Fri, 6 Mar 2009 20:19:29 +0200 Subject: [PATCH 01/15] Bug #40559 assertion failed in check_binlog_magic The reason of the bug is in that the test makes a trick with relay log files and did not reset fully at the end. If mtr does not restart the test the new SQL thread tried to work with the old time session data. Fixed with deploying RESET slave at the clean-up. mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test: adding RESET slave to force active mi and rli data struct to be reset. The slave SQL thread will deal with a fresh structures each time it restarts. --- .../suite/binlog/r/binlog_auto_increment_bug33029.result | 1 + .../suite/binlog/t/binlog_auto_increment_bug33029.test | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result index 8df0568a755..8226469fcf7 100644 --- a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result +++ b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result @@ -38,4 +38,5 @@ DROP PROCEDURE IF EXISTS p2; DROP FUNCTION IF EXISTS f1; DROP TRIGGER IF EXISTS tr1; stop slave sql_thread; +reset slave; SET @@global.relay_log_purge= @old_relay_log_purge; diff --git a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test index f20cc33f820..5297767675c 100644 --- a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test +++ b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test @@ -52,9 +52,10 @@ DROP FUNCTION IF EXISTS f1; DROP TRIGGER IF EXISTS tr1; enable_warnings; +stop slave sql_thread; +reset slave; +source include/wait_for_slave_sql_to_stop.inc; remove_file $MYSQLD_DATADIR/slave-relay-bin.000001; remove_file $MYSQLD_DATADIR/slave-relay-bin.index; -stop slave sql_thread; -source include/wait_for_slave_sql_to_stop.inc; SET @@global.relay_log_purge= @old_relay_log_purge; From e0bc00257617f2991d370b688bea7847dddbae8b Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Mon, 9 Mar 2009 16:56:46 -0400 Subject: [PATCH 02/15] Fix non-DBUG return. --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index ced34f16212..c1eb07d7f8e 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3199,7 +3199,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) DBUG_ENTER("dump_selected_tables"); if (init_dumping(db, init_dumping_tables)) - return 1; + DBUG_RETURN(1); init_alloc_root(&root, 8192, 0); if (!(dump_tables= pos= (char**) alloc_root(&root, tables * sizeof(char *)))) From 89a1db2bd228965707645ba346519b824f7a48e9 Mon Sep 17 00:00:00 2001 From: Chad MILLER Date: Mon, 9 Mar 2009 16:58:47 -0400 Subject: [PATCH 03/15] Bug#42635: mysqldump includes views that were excluded using the \ --ignore-table option mysqldump would correctly omit temporary tables for views, but would incorrectly still emit all CREATE VIEW statements. Backport a fix from 5.1, where we capture the names we want to emit views for in one pass (the placeholder tables) and in the pass where we actually emit the views, we don't emit a view if it wasn't in that list. --- client/mysqldump.c | 24 ++++++++++++---- mysql-test/r/mysqldump.result | 54 +++++++++++++++++++++++++++++++++++ mysql-test/t/mysqldump.test | 14 +++++++++ 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index c1eb07d7f8e..dea1b0b3659 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3103,6 +3103,11 @@ static my_bool dump_all_views_in_db(char *database) char *table; uint numrows; char table_buff[NAME_LEN*2+3]; + char hash_key[2*NAME_LEN+2]; /* "db.tablename" */ + char *afterdot; + + afterdot= strmov(hash_key, database); + *afterdot++= '.'; if (init_dumping(database, init_dumping_views)) return 1; @@ -3112,10 +3117,15 @@ static my_bool dump_all_views_in_db(char *database) { DYNAMIC_STRING query; init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024); - for (numrows= 0 ; (table= getTableName(1)); numrows++) + for (numrows= 0 ; (table= getTableName(1)); ) { - dynstr_append_checked(&query, quote_name(table, table_buff, 1)); - dynstr_append_checked(&query, " READ /*!32311 LOCAL */,"); + char *end= strmov(afterdot, table); + if (include_table((uchar*) hash_key,end - hash_key)) + { + numrows++; + dynstr_append_checked(&query, quote_name(table, table_buff, 1)); + dynstr_append_checked(&query, " READ /*!32311 LOCAL */,"); + } } if (numrows && mysql_real_query(mysql, query.str, query.length-1)) DB_error(mysql, "when using LOCK TABLES"); @@ -3129,7 +3139,11 @@ static my_bool dump_all_views_in_db(char *database) /* We shall continue here, if --force was given */ } while ((table= getTableName(0))) - get_view_structure(table, database); + { + char *end= strmov(afterdot, table); + if (include_table((uchar*) hash_key, end - hash_key)) + get_view_structure(table, database); + } if (opt_xml) { fputs("\n", md_result_file); diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 76e553dea42..831f953157e 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3574,5 +3574,59 @@ DROP TABLE t1,t2; -- Dump completed on DATE SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; # +# Bug #42635: mysqldump includes views that were excluded using +# the --ignore-table option +# +create database db42635; +use db42635; +create table t1 (id int); +create view db42635.v1 (c) as select * from db42635.t1; +create view db42635.v2 (c) as select * from db42635.t1; + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `t1`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `t1` ( + `id` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +SET character_set_client = @saved_cs_client; + +LOCK TABLES `t1` WRITE; +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; +UNLOCK TABLES; +DROP TABLE IF EXISTS `v2`; +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE TABLE `v2` ( + `c` int(11) +) ENGINE=MyISAM */; +/*!50001 DROP TABLE `v2`*/; +/*!50001 DROP VIEW IF EXISTS `v2`*/; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v2` AS select `t1`.`id` AS `c` from `t1` */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +use test; +drop database db42635; +# # End of 5.0 tests # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 5cd9c17e2ac..30a7da751e8 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1649,6 +1649,20 @@ DROP TABLE t1,t2; # We reset concurrent_inserts value to whatever it was at the start of the test SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT; +--echo # +--echo # Bug #42635: mysqldump includes views that were excluded using +--echo # the --ignore-table option +--echo # + +create database db42635; +use db42635; +create table t1 (id int); +create view db42635.v1 (c) as select * from db42635.t1; +create view db42635.v2 (c) as select * from db42635.t1; +--exec $MYSQL_DUMP --skip-comments --ignore-table=db42635.v1 db42635 +use test; +drop database db42635; + --echo # --echo # End of 5.0 tests From 48044a8b789ff415557c5fdedd121a7c36d33128 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 11 Mar 2009 14:52:53 -0600 Subject: [PATCH 04/15] Remove outdated and now useless TODO file from sql-bench. Requested by sales. --- sql-bench/TODO | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 sql-bench/TODO diff --git a/sql-bench/TODO b/sql-bench/TODO deleted file mode 100644 index 8a103e89199..00000000000 --- a/sql-bench/TODO +++ /dev/null @@ -1,21 +0,0 @@ -When comparing with ms-sql: - -Check how to get MySQL faster mysql ms-sql - -count_distinct (2000) | 89.00| 39.00| -count_distinct_big (120) | 324.00| 121.00| -count_distinct_group (1000) | 158.00| 107.00| -count_distinct_group_on_key (1000) | 49.00| 17.00| -count_distinct_group_on_key_parts (1| 157.00| 108.00| -order_by_big (10) | 197.00| 89.00| -order_by_big_key (10) | 170.00| 82.00| -order_by_big_key2 (10) | 163.00| 73.00| -order_by_big_key_desc (10) | 172.00| 84.00| -order_by_big_key_diff (10) | 193.00| 89.00| -order_by_big_key_prefix (10) | 165.00| 72.00| - - -Why is the following slow on NT: - NT Linux -update_of_primary_key_many_keys (256| 560.00| 65.00| - From 81e4e1e79cc56be4fe9b86f23a30e81ba9f9f110 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 11 Mar 2009 14:54:57 -0600 Subject: [PATCH 05/15] Bug #32625: Make test type_bit_innodb more robust Since there is more than one duplicate value in the table, when adding the unique index it is not deterministic which value will be reported as causing a problem. Replace the reported value with '' so that it doesn't affect the results. --- mysql-test/t/type_bit_innodb.test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test index dbca69d67f0..e7e66da8927 100644 --- a/mysql-test/t/type_bit_innodb.test +++ b/mysql-test/t/type_bit_innodb.test @@ -40,7 +40,9 @@ drop table t1; create table t1 (a bit) engine=innodb; insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); select hex(a) from t1; ---error 1062 +# It is not deterministic which duplicate will be seen first +--replace_regex /(.*Duplicate entry )'.*'( for key.*)/\1''\2/ +--error ER_DUP_ENTRY alter table t1 add unique (a); drop table t1; From 59fbffa45cc804bde74d504129eb705cd80b3bba Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Wed, 11 Mar 2009 23:32:53 +0100 Subject: [PATCH 06/15] Bug#40657: assertion with out of range variables and traditional sql_mode normalize error-messages mysql-test/r/variables.result: show that warning uses underscore (sysvar-name), not hyphens (option-name) mysql-test/t/variables.test: show that warning uses underscore (sysvar-name), not hyphens (option-name) sql/set_var.cc: normalize error-messages --- mysql-test/r/variables.result | 6 ++++++ mysql-test/t/variables.test | 5 +++++ sql/set_var.cc | 5 +++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 28b35c1461d..aeda5b59dab 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1421,6 +1421,12 @@ SELECT @@global.expire_logs_days; @@global.expire_logs_days 99 SET GLOBAL expire_logs_days = @old_eld; +SET GLOBAL auto_increment_offset=-1; +Warnings: +Warning 1292 Truncated incorrect auto_increment_offset value: '-1' +SET GLOBAL auto_increment_offset=0; +Warnings: +Warning 1292 Truncated incorrect auto_increment_offset value: '0' select @@storage_engine; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def @@storage_engine 253 6 6 N 1 31 8 diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 95f4d6e97c5..43169b22b5e 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1155,6 +1155,11 @@ SELECT @@global.expire_logs_days; # cleanup SET GLOBAL expire_logs_days = @old_eld; +# show that warning uses underscore (sysvar-name), not hyphens (option-name) +SET GLOBAL auto_increment_offset=-1; +SET GLOBAL auto_increment_offset=0; + + # # Bug#41030 Wrong meta data (incorrect fieldlen) diff --git a/sql/set_var.cc b/sql/set_var.cc index d6a9cbb19ee..84e628fbddf 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1520,9 +1520,10 @@ static bool get_unsigned(THD *thd, set_var *var, ulonglong user_max, var->save_result.ulonglong_value= getopt_ull_limit_value(var->save_result. ulonglong_value, - limits, &fixed); + limits, &fixed); - if ((warnings == 0) && throw_bounds_warning(thd, fixed, TRUE, limits->name, + if ((warnings == 0) && throw_bounds_warning(thd, fixed, TRUE, + var->var->name, (longlong) unadjusted)) return TRUE; } From 50851796a5cd4f38268f9e986ef728e9651c0bd1 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 11 Mar 2009 18:14:24 -0600 Subject: [PATCH 07/15] Applying InnoDB snashot 5.1-ss4350, part 1. Fixes Bug #42279 Race condition in btr_search_drop_page_hash_when_freed() Detailed revision comments: r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines branches/5.1: Merge r4031 from branches/5.0: btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen() returns NULL. The page may have been evicted from the buffer pool between buf_page_peek_if_search_hashed() and buf_page_get_gen(), because the buffer pool mutex will be released between these two calls. (Bug #42279) rb://82 approved by Heikki Tuuri --- storage/innobase/btr/btr0sea.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 3482e16497a..84ad0e27110 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -1105,12 +1105,20 @@ btr_search_drop_page_hash_when_freed( page = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL, BUF_GET_IF_IN_POOL, __FILE__, __LINE__, &mtr); + /* Because the buffer pool mutex was released by + buf_page_peek_if_search_hashed(), it is possible that the + block was removed from the buffer pool by another thread + before buf_page_get_gen() got a chance to acquire the buffer + pool mutex again. Thus, we must check for a NULL return. */ + + if (UNIV_LIKELY(page != NULL)) { #ifdef UNIV_SYNC_DEBUG - buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH); + buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH); #endif /* UNIV_SYNC_DEBUG */ - btr_search_drop_page_hash_index(page); + btr_search_drop_page_hash_index(page); + } mtr_commit(&mtr); } From a33a51e2a8cd07b684020753453ecb29fa668733 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 11 Mar 2009 18:15:46 -0600 Subject: [PATCH 08/15] Applying InnoDB snashot 5.1-ss4350, part 2. Fixes Bug #42400 InnoDB autoinc code can't handle floating-point columns Detailed revision comments: r4065 | sunny | 2009-01-29 16:01:36 +0200 (Thu, 29 Jan 2009) | 8 lines branches/5.1: In the last round of AUTOINC cleanup we assumed that AUTOINC is only defined for integer columns. This caused an assertion failure when we checked for the maximum value of a column type. We now calculate the max value for floating-point autoinc columns too. Fix Bug#42400 - InnoDB autoinc code can't handle floating-point columns rb://84 and Mantis issue://162 r4111 | sunny | 2009-02-03 22:06:52 +0200 (Tue, 03 Feb 2009) | 2 lines branches/5.1: Add the ULL suffix otherwise there is an overflow. --- mysql-test/r/innodb-autoinc.result | 48 +++++++++++++++++++++++++++ mysql-test/t/innodb-autoinc.test | 27 +++++++++++++++ storage/innobase/handler/ha_innodb.cc | 12 +++++-- 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index 1e4b088c6cd..c49405f5175 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -579,3 +579,51 @@ c1 18446744073709551610 18446744073709551615 DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +Variable_name Value +auto_increment_increment 1 +auto_increment_offset 1 +CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +3 3 +4 4 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +c1 c2 +1 1 +2 2 +3 3 +4 4 +DROP TABLE t1; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index e6b804c4fff..5f9d4bfdae9 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -390,3 +390,30 @@ INSERT INTO t1 VALUES (NULL); #endif SELECT * FROM t1; DROP TABLE t1; + +# +# Check for floating point autoinc column handling +# +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1; +SET @@INSERT_ID=1; +SHOW VARIABLES LIKE "%auto_inc%"; +CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL, 1); +INSERT INTO t1 VALUES(NULL, 2); +SELECT * FROM t1; +ALTER TABLE t1 CHANGE c1 c1 SERIAL; +SELECT * FROM t1; +INSERT INTO t1 VALUES(NULL, 3); +INSERT INTO t1 VALUES(NULL, 4); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 522392edc7a..22e69852dc2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3405,7 +3405,7 @@ skip_field: } /************************************************************************ -Get the upper limit of the MySQL integral type. */ +Get the upper limit of the MySQL integral and floating-point type. */ ulonglong ha_innobase::innobase_get_int_col_max_value( @@ -3444,12 +3444,20 @@ ha_innobase::innobase_get_int_col_max_value( max_value = 0x7FFFFFFFULL; break; /* BIG */ - case HA_KEYTYPE_ULONGLONG: + case HA_KEYTYPE_ULONGLONG: max_value = 0xFFFFFFFFFFFFFFFFULL; break; case HA_KEYTYPE_LONGLONG: max_value = 0x7FFFFFFFFFFFFFFFULL; break; + case HA_KEYTYPE_FLOAT: + /* We use the maximum as per IEEE754-2008 standard, 2^24 */ + max_value = 0x1000000ULL; + break; + case HA_KEYTYPE_DOUBLE: + /* We use the maximum as per IEEE754-2008 standard, 2^53 */ + max_value = 0x20000000000000ULL; + break; default: ut_error; } From 7ae516e1ca56d33581d5531e6bab72136f4b02b8 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 11 Mar 2009 18:16:53 -0600 Subject: [PATCH 09/15] Applying InnoDB snashot 5.1-ss4350, part 3. No functional changes. Detailed revision comments: r4165 | calvin | 2009-02-12 01:34:27 +0200 (Thu, 12 Feb 2009) | 1 line branches/5.1: minor non-functional changes. --- storage/innobase/handler/ha_innodb.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 22e69852dc2..5c4e111b67d 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3312,8 +3312,8 @@ build_template( goto include_field; } - if (bitmap_is_set(table->read_set, i) || - bitmap_is_set(table->write_set, i)) { + if (bitmap_is_set(table->read_set, i) || + bitmap_is_set(table->write_set, i)) { /* This field is needed in the query */ goto include_field; @@ -3416,7 +3416,7 @@ ha_innobase::innobase_get_int_col_max_value( switch(field->key_type()) { /* TINY */ - case HA_KEYTYPE_BINARY: + case HA_KEYTYPE_BINARY: max_value = 0xFFULL; break; case HA_KEYTYPE_INT8: @@ -3430,7 +3430,7 @@ ha_innobase::innobase_get_int_col_max_value( max_value = 0x7FFFULL; break; /* MEDIUM */ - case HA_KEYTYPE_UINT24: + case HA_KEYTYPE_UINT24: max_value = 0xFFFFFFULL; break; case HA_KEYTYPE_INT24: From 08ee9470a97888380059f8f8b7e6dab1a0eb2da8 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 11 Mar 2009 18:17:53 -0600 Subject: [PATCH 10/15] Applying InnoDB snashot 5.1-ss4350, part 4. Fixes Bug #42714 AUTO_INCREMENT errors in 5.1.31 Detailed revision comments: r4287 | sunny | 2009-02-25 05:32:01 +0200 (Wed, 25 Feb 2009) | 10 lines branches/5.1: Fix Bug#42714 AUTO_INCREMENT errors in 5.1.31. There are two changes to the autoinc handling. 1. To fix the immediate problem from the bug report, we must ensure that the value written to the table is always less than the max value stored in dict_table_t. 2. The second related change is that according to MySQL documentation when the offset is greater than the increment, we should ignore the offset. --- mysql-test/r/innodb-autoinc.result | 221 ++++++++++++++++++++++++++ mysql-test/t/innodb-autoinc.test | 42 +++++ storage/innobase/handler/ha_innodb.cc | 8 +- 3 files changed, 270 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index c49405f5175..f400c8e9f16 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -627,3 +627,224 @@ c1 c2 3 3 4 4 DROP TABLE t1; +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +DROP TABLE IF EXISTS t2; +Warnings: +Note 1051 Unknown table 't2' +CREATE TABLE t1 ( +a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, +b INT(10) UNSIGNED NOT NULL, +c ENUM('FALSE','TRUE') DEFAULT NULL, +PRIMARY KEY (a)) ENGINE = InnoDB; +CREATE TABLE t2 ( +m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, +n INT(10) UNSIGNED NOT NULL, +o enum('FALSE','TRUE') DEFAULT NULL, +PRIMARY KEY (m)) ENGINE = InnoDB; +INSERT INTO t2 (n,o) VALUES +(1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'), +(3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false'); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `m` int(11) unsigned NOT NULL AUTO_INCREMENT, + `n` int(10) unsigned NOT NULL, + `o` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`m`) +) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +23 1 FALSE +24 2 FALSE +25 3 FALSE +26 4 FALSE +27 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +23 1 FALSE +24 2 FALSE +25 3 FALSE +26 4 FALSE +27 5 FALSE +30 1 FALSE +31 2 FALSE +32 3 FALSE +33 4 FALSE +34 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1 +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +a b c +1 1 TRUE +2 1 FALSE +3 2 TRUE +4 2 FALSE +5 3 TRUE +6 3 FALSE +7 4 TRUE +8 4 FALSE +9 5 TRUE +10 5 FALSE +13 1 TRUE +14 1 FALSE +15 2 TRUE +16 2 FALSE +17 3 TRUE +18 3 FALSE +19 4 TRUE +20 4 FALSE +21 5 TRUE +22 5 FALSE +23 1 FALSE +24 2 FALSE +25 3 FALSE +26 4 FALSE +27 5 FALSE +30 1 FALSE +31 2 FALSE +32 3 FALSE +33 4 FALSE +34 5 FALSE +37 1 FALSE +38 2 FALSE +39 3 FALSE +40 4 FALSE +41 5 FALSE +44 1 FALSE +45 2 FALSE +46 3 FALSE +47 4 FALSE +48 5 FALSE +51 1 FALSE +52 2 FALSE +53 3 FALSE +54 4 FALSE +55 5 FALSE +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) unsigned NOT NULL AUTO_INCREMENT, + `b` int(10) unsigned NOT NULL, + `c` enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1 +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index 5f9d4bfdae9..6be2e5ac67e 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -417,3 +417,45 @@ INSERT INTO t1 VALUES(NULL, 3); INSERT INTO t1 VALUES(NULL, 4); SELECT * FROM t1; DROP TABLE t1; + +# +# Bug# 42714: AUTOINC column calculated next value not greater than highest +# value stored in table. +# +SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5; +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( + a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + b INT(10) UNSIGNED NOT NULL, + c ENUM('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (a)) ENGINE = InnoDB; +CREATE TABLE t2 ( + m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + n INT(10) UNSIGNED NOT NULL, + o enum('FALSE','TRUE') DEFAULT NULL, + PRIMARY KEY (m)) ENGINE = InnoDB; +INSERT INTO t2 (n,o) VALUES + (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'), + (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false'); +SHOW CREATE TABLE t2; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SHOW CREATE TABLE t1; +INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false'; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5c4e111b67d..b125c731228 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -953,6 +953,12 @@ innobase_next_autoinc( /* Should never be 0. */ ut_a(increment > 0); + /* According to MySQL documentation, if the offset is greater than + the increment then the offset is ignored. */ + if (offset > increment) { + offset = 0; + } + if (max_value <= current) { next_value = max_value; } else if (offset <= 1) { @@ -3780,7 +3786,7 @@ no_commit: will be 0 if get_auto_increment() was not called.*/ if (auto_inc <= col_max_value - && auto_inc > prebuilt->autoinc_last_value) { + && auto_inc >= prebuilt->autoinc_last_value) { set_max_autoinc: ut_a(prebuilt->autoinc_increment > 0); From 8cbd34f0d7a08f112ca4fb900bda31aeaf0703f1 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 11 Mar 2009 18:18:44 -0600 Subject: [PATCH 11/15] Applying InnoDB snashot 5.1-ss4350, part 5. Fixes Bug #43203 Overflow from auto incrementing causes server segv Detailed revision comments: r4325 | sunny | 2009-03-02 02:28:52 +0200 (Mon, 02 Mar 2009) | 10 lines branches/5.1: Bug#43203: Overflow from auto incrementing causes server segv It was not a SIGSEGV but an assertion failure. The assertion was checking the invariant that *first_value passed in by MySQL doesn't contain a value that is greater than the max value for that type. The assertion has been changed to a check and if the value is greater than the max we report a generic AUTOINC failure. rb://93 Approved by Heikki --- mysql-test/r/innodb-autoinc.result | 19 +++++++++++++++++++ mysql-test/t/innodb-autoinc.test | 21 ++++++++++++++++++++- storage/innobase/handler/ha_innodb.cc | 12 +++++++----- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index f400c8e9f16..ade4db35ce6 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -848,3 +848,22 @@ t1 CREATE TABLE `t1` ( ) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1 DROP TABLE t1; DROP TABLE t2; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +DROP TABLE IF EXISTS t2; +Warnings: +Note 1051 Unknown table 't2' +CREATE TABLE t1( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT +PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +CREATE TABLE t2( +c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT +PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t2 SELECT c1 FROM t1; +Got one of the listed errors +INSERT INTO t2 SELECT NULL FROM t1; +Got one of the listed errors +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index 6be2e5ac67e..d76b29a7dc8 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -418,7 +418,7 @@ INSERT INTO t1 VALUES(NULL, 4); SELECT * FROM t1; DROP TABLE t1; -# +# # Bug# 42714: AUTOINC column calculated next value not greater than highest # value stored in table. # @@ -459,3 +459,22 @@ SELECT * FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; DROP TABLE t2; +# +# 43203: Overflow from auto incrementing causes server segv +# + +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1( + c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT + PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); +CREATE TABLE t2( + c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT + PRIMARY KEY) ENGINE=InnoDB; +-- error ER_DUP_ENTRY,1062 +INSERT INTO t2 SELECT c1 FROM t1; +-- error ER_DUP_ENTRY,1467 +INSERT INTO t2 SELECT NULL FROM t1; +DROP TABLE t1; +DROP TABLE t2; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b125c731228..a019b95a2bb 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7664,11 +7664,13 @@ ha_innobase::get_auto_increment( prebuilt->autoinc_last_value = next_value; - ut_a(prebuilt->autoinc_last_value >= *first_value); - - /* Update the table autoinc variable */ - dict_table_autoinc_update_if_greater( - prebuilt->table, prebuilt->autoinc_last_value); + if (prebuilt->autoinc_last_value < *first_value) { + *first_value = (~(ulonglong) 0); + } else { + /* Update the table autoinc variable */ + dict_table_autoinc_update_if_greater( + prebuilt->table, prebuilt->autoinc_last_value); + } } else { /* This will force write_row() into attempting an update of the table's AUTOINC counter. */ From a5dc03fb684ffed13b6915534727317837473ce1 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 13 Mar 2009 12:51:25 +0400 Subject: [PATCH 12/15] Bug#42610 Dynamic plugin broken in 5.1.31 --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage --option 'ignore-builtin-innodb' disables all InnoDB builtin plugins (including I_S plugins) sql/mysql_priv.h: --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage sql/mysqld.cc: --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage sql/sql_plugin.cc: --added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage --option 'ignore-builtin-innodb' disables all InnoDB builtin plugins (including I_S plugins) --- sql/mysql_priv.h | 3 +++ sql/mysqld.cc | 8 +++++++- sql/sql_plugin.cc | 35 +++++++++++++++++++++++------------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index a2fbddd667a..2c938fc96a2 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -2047,6 +2047,9 @@ extern SHOW_COMP_OPTION have_geometry, have_rtree_keys; extern SHOW_COMP_OPTION have_crypt; extern SHOW_COMP_OPTION have_compress; +extern int orig_argc; +extern char **orig_argv; +extern const char *load_default_groups[]; #ifndef __WIN__ extern pthread_t signal_thread; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 921bcfcf68e..b88e6b641dd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -648,6 +648,9 @@ static int defaults_argc; static char **defaults_argv; static char *opt_bin_logname; +int orig_argc; +char **orig_argv; + static my_socket unix_sock,ip_sock; struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD() @@ -2923,7 +2926,7 @@ pthread_handler_t handle_shutdown(void *arg) #endif #if !defined(EMBEDDED_LIBRARY) -static const char *load_default_groups[]= { +const char *load_default_groups[]= { #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE "mysql_cluster", #endif @@ -3221,6 +3224,8 @@ static int init_common_variables(const char *conf_file_name, int argc, SQLCOM_END + 8); #endif + orig_argc=argc; + orig_argv=argv; load_defaults(conf_file_name, groups, &argc, &argv); defaults_argv=argv; defaults_argc=argc; @@ -3886,6 +3891,7 @@ server."); if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts, mysqld_get_one_option))) unireg_abort(ho_error); + my_getopt_skip_unknown= TRUE; if (defaults_argc) { diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 60f205ec8e8..223ba6ef42e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1139,8 +1139,9 @@ int plugin_init(int *argc, char **argv, int flags) for (plugin= *builtins; plugin->info; plugin++) { if (opt_ignore_builtin_innodb && - !my_strcasecmp(&my_charset_latin1, plugin->name, "InnoDB")) - continue; + !my_strnncoll(&my_charset_latin1, (const uchar*) plugin->name, + 6, (const uchar*) "InnoDB", 6)) + continue; /* by default, ndbcluster and federated are disabled */ def_enabled= my_strcasecmp(&my_charset_latin1, plugin->name, "NDBCLUSTER") != 0 && @@ -1633,8 +1634,8 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl { TABLE_LIST tables; TABLE *table; - int error, argc; - char *argv[2]; + int error, argc=orig_argc; + char **argv=orig_argv; struct st_plugin_int *tmp; DBUG_ENTER("mysql_install_plugin"); @@ -1650,21 +1651,31 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl pthread_mutex_lock(&LOCK_plugin); rw_wrlock(&LOCK_system_variables_hash); - /* handle_options() assumes arg0 (program name) always exists */ - argv[0]= const_cast(""); // without a cast gcc emits a warning - argv[1]= 0; - argc= 1; + + load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv); error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER); + if (argv) + free_defaults(argv); rw_unlock(&LOCK_system_variables_hash); if (error || !(tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) goto err; - if (plugin_initialize(tmp)) + if (tmp->state == PLUGIN_IS_DISABLED) { - my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, - "Plugin initialization function failed."); - goto deinit; + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_CANT_INITIALIZE_UDF, ER(ER_CANT_INITIALIZE_UDF), + name->str, "Plugin is disabled"); + } + else + { + DBUG_ASSERT(tmp->state == PLUGIN_IS_UNINITIALIZED); + if (plugin_initialize(tmp)) + { + my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, + "Plugin initialization function failed."); + goto deinit; + } } /* From 7ac3f3f1beabcc9187a271b17f660d9ea7cddfb1 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Mar 2009 11:16:32 +0200 Subject: [PATCH 13/15] addendum to bug #36540 : fix the funcs_1 test suite. --- mysql-test/suite/funcs_1/r/is_columns_mysql.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result index 9d1f316a9bf..2f1f61c0525 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result @@ -48,7 +48,7 @@ NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NUL NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') select,insert,update,references -NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) select,insert,update,references +NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') select,insert,update,references NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') select,insert,update,references @@ -60,7 +60,7 @@ NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('fu NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references -NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references @@ -150,7 +150,7 @@ NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references -NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references +NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references @@ -329,7 +329,7 @@ NULL mysql event ends datetime NULL NULL NULL NULL datetime 3.0000 mysql event on_completion enum 8 24 utf8 utf8_general_ci enum('DROP','PRESERVE') 3.0000 mysql event sql_mode set 478 1434 utf8 utf8_general_ci set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') 3.0000 mysql event comment char 64 192 utf8 utf8_bin char(64) -NULL mysql event originator int NULL NULL NULL NULL int(10) +NULL mysql event originator int NULL NULL NULL NULL int(10) unsigned 1.0000 mysql event time_zone char 64 64 latin1 latin1_swedish_ci char(64) 3.0000 mysql event character_set_client char 32 96 utf8 utf8_bin char(32) 3.0000 mysql event collation_connection char 32 96 utf8 utf8_bin char(32) @@ -342,7 +342,7 @@ NULL mysql func ret tinyint NULL NULL NULL NULL tinyint(1) NULL mysql general_log event_time timestamp NULL NULL NULL NULL timestamp 1.0000 mysql general_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext NULL mysql general_log thread_id int NULL NULL NULL NULL int(11) -NULL mysql general_log server_id int NULL NULL NULL NULL int(11) +NULL mysql general_log server_id int NULL NULL NULL NULL int(10) unsigned 3.0000 mysql general_log command_type varchar 64 192 utf8 utf8_general_ci varchar(64) 1.0000 mysql general_log argument mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext NULL mysql help_category help_category_id smallint NULL NULL NULL NULL smallint(5) unsigned @@ -434,7 +434,7 @@ NULL mysql slow_log rows_examined int NULL NULL NULL NULL int(11) 3.0000 mysql slow_log db varchar 512 1536 utf8 utf8_general_ci varchar(512) NULL mysql slow_log last_insert_id int NULL NULL NULL NULL int(11) NULL mysql slow_log insert_id int NULL NULL NULL NULL int(11) -NULL mysql slow_log server_id int NULL NULL NULL NULL int(11) +NULL mysql slow_log server_id int NULL NULL NULL NULL int(10) unsigned 1.0000 mysql slow_log sql_text mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext 3.0000 mysql tables_priv Host char 60 180 utf8 utf8_bin char(60) 3.0000 mysql tables_priv Db char 64 192 utf8 utf8_bin char(64) From 7b2d7bea5e8315f25def764ba220e089ce288a52 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 13 Mar 2009 14:25:50 +0400 Subject: [PATCH 14/15] compilation(embedded server) failure fix --- sql/mysqld.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b88e6b641dd..7fe498ae147 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2925,18 +2925,16 @@ pthread_handler_t handle_shutdown(void *arg) } #endif -#if !defined(EMBEDDED_LIBRARY) const char *load_default_groups[]= { #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE "mysql_cluster", #endif "mysqld","server", MYSQL_BASE_VERSION, 0, 0}; -#if defined(__WIN__) +#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) static const int load_default_groups_sz= sizeof(load_default_groups)/sizeof(load_default_groups[0]); #endif -#endif /*!EMBEDDED_LIBRARY*/ /** From 60beb4c3da759bd716ac7c49ee4103ca31abcf93 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 13 Mar 2009 13:13:55 +0200 Subject: [PATCH 15/15] Bug #43614: make distcheck failure (ndb/Makefile is made, but not subdirs of ndb) There are some recursive targets that automake generates which reference DIST_SUBDIRS. It's critical, then, for such subdirs to exist even if they won't be built as part of SUBDIRS. During a VPATH build, it is the configure script which creates the subdirs (when it processes the AC_CONFIG_FILES() for each subdir's Makefile). If autoconf doesn't create a subdir's Makefile, then the recursive make will fail when it is unable to cd into that subdir. This isn't a problem in non-VPATH builds, because the subdirs are all present in the source tarball. So the problem only shows up during 'make distcheck', which does a VPATH build. The fix is to look, when configure is being created by autoconf, for any plugin subdirectories. These are the dynamic subdirectories which need to be handled specially. It's enough to tell autoconf to generate a Makefile for any Makefile.am found in the plugin directory - all plugin subdirectories using automake (i.e., listed in the plugin's DIST_SUBDIRS) will have a Makefile.am. This is done by calling 'find'. This means that 'find' must be in the PATH on the host that is running autoconf. 'find' is NOT needed when calling configure, so it is not an additional dependency for the user. Finally, ha_ndbcluster.m4 had called AC_CONFIG_FILES() on all those subdir Makefiles, but only when the plugin was actually being built. So it didn't work in the case that NDB was not being built. All of those Makefiles have to be removed from this static list, since the plugin machinery is now adding them automatically. autoconf fails if a file is duplicated in AC_CONFIG_FILES(). --- config/ac-macros/ha_ndbcluster.m4 | 40 ++++--------------------------- config/ac-macros/plugins.m4 | 17 +++++++++++-- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/config/ac-macros/ha_ndbcluster.m4 b/config/ac-macros/ha_ndbcluster.m4 index 5ee136f2266..3718b64f688 100644 --- a/config/ac-macros/ha_ndbcluster.m4 +++ b/config/ac-macros/ha_ndbcluster.m4 @@ -330,41 +330,11 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [ AC_SUBST([NDB_SIZEOF_LONG]) AC_SUBST([NDB_SIZEOF_LONG_LONG]) - AC_CONFIG_FILES(storage/ndb/include/Makefile dnl - storage/ndb/src/Makefile storage/ndb/src/common/Makefile dnl - storage/ndb/docs/Makefile dnl - storage/ndb/tools/Makefile dnl - storage/ndb/src/common/debugger/Makefile dnl - storage/ndb/src/common/debugger/signaldata/Makefile dnl - storage/ndb/src/common/portlib/Makefile dnl - storage/ndb/src/common/util/Makefile dnl - storage/ndb/src/common/logger/Makefile dnl - storage/ndb/src/common/transporter/Makefile dnl - storage/ndb/src/common/mgmcommon/Makefile dnl - storage/ndb/src/kernel/Makefile dnl - storage/ndb/src/kernel/error/Makefile dnl - storage/ndb/src/kernel/blocks/Makefile dnl - storage/ndb/src/kernel/blocks/dbdict/Makefile dnl - storage/ndb/src/kernel/blocks/dbdih/Makefile dnl - storage/ndb/src/kernel/blocks/dblqh/Makefile dnl - storage/ndb/src/kernel/blocks/dbtup/Makefile dnl - storage/ndb/src/kernel/blocks/backup/Makefile dnl - storage/ndb/src/kernel/vm/Makefile dnl - storage/ndb/src/mgmapi/Makefile dnl - storage/ndb/src/ndbapi/Makefile dnl - storage/ndb/src/mgmsrv/Makefile dnl - storage/ndb/src/mgmclient/Makefile dnl - storage/ndb/src/cw/Makefile dnl - storage/ndb/src/cw/cpcd/Makefile dnl - storage/ndb/test/Makefile dnl - storage/ndb/test/src/Makefile dnl - storage/ndb/test/ndbapi/Makefile dnl - storage/ndb/test/ndbapi/bank/Makefile dnl - storage/ndb/test/tools/Makefile dnl - storage/ndb/test/run-test/Makefile dnl - storage/ndb/include/ndb_version.h storage/ndb/include/ndb_global.h dnl - storage/ndb/include/ndb_types.h dnl - ) + AC_CONFIG_FILES([ + storage/ndb/include/ndb_version.h + storage/ndb/include/ndb_global.h + storage/ndb/include/ndb_types.h + ]) ]) AC_SUBST(TEST_NDBCLUSTER) diff --git a/config/ac-macros/plugins.m4 b/config/ac-macros/plugins.m4 index e1da6fd11f5..5d15afeda99 100644 --- a/config/ac-macros/plugins.m4 +++ b/config/ac-macros/plugins.m4 @@ -477,10 +477,23 @@ dnl Although this is "pretty", it breaks libmysqld build # Even if we don't build a plugin, we bundle its source into the dist # file. So its Makefile (and Makefiles for any subdirs) must be # generated for 'make dist' to work. - m4_syscmd(test -f "$6/configure") + m4_syscmd([test -f "]$6[/configure"]) ifelse(m4_sysval, 0, [AC_CONFIG_SUBDIRS($6)], - [AC_CONFIG_FILES($6/Makefile)] + [ + # autoconf doesn't provide an automatic way to configure DIST_SUBDIRS of + # a subdir; for our purposes, it's enough to just check for existing + # Makefile.am files and add them in here +dnl +dnl Warning, don't try to quote the m4_esyscmd() macro, it doesn't +dnl work. Quoting here is tricky. +dnl +dnl The $FIND or $SED variable can be set by the user when calling autoconf itself +dnl to if they need to pass a specific path. This is *NOT* used when calling +dnl running configure! +dnl + AC_CONFIG_FILES(m4_esyscmd([${FIND-find} "]$6[" -name Makefile.am -print | ${SED-sed} 's,\.am$,,'])) + ] ) ifelse(