diff --git a/CMakeLists.txt b/CMakeLists.txt index de1e19d12ea..c9ca4344e5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,4 +60,5 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c IF(NOT SOURCE_SUBLIBS) ADD_LIBRARY(innobase ${INNOBASE_SOURCES}) + ADD_DEPENDENCIES(innobase GenError) ENDIF(NOT SOURCE_SUBLIBS) diff --git a/dict/dict0dict.c b/dict/dict0dict.c index c3b5215d71e..0576b4a7e67 100644 --- a/dict/dict0dict.c +++ b/dict/dict0dict.c @@ -342,7 +342,7 @@ void dict_table_autoinc_initialize( /*==========================*/ dict_table_t* table, /* in/out: table */ - ib_longlong value) /* in: next value to assign to a row */ + ib_ulonglong value) /* in: next value to assign to a row */ { ut_ad(mutex_own(&table->autoinc_mutex)); @@ -354,7 +354,7 @@ dict_table_autoinc_initialize( Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized. */ UNIV_INTERN -ib_longlong +ib_ulonglong dict_table_autoinc_read( /*====================*/ /* out: value for a new row, or 0 */ @@ -383,7 +383,7 @@ dict_table_autoinc_update( /*======================*/ dict_table_t* table, /* in/out: table */ - ib_longlong value) /* in: value which was assigned to a row */ + ib_ulonglong value) /* in: value which was assigned to a row */ { if (table->autoinc_inited && value > table->autoinc) { diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index e703e0e8cf4..a81a02df223 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -74,10 +74,6 @@ extern "C" { /* This is needed because of Bug #3596. Let us hope that pthread_mutex_t is defined the same in both builds: the MySQL server and the InnoDB plugin. */ extern pthread_mutex_t LOCK_thread_count; - -/* this is defined in mysql_priv.h inside #ifdef MYSQL_SERVER -but we need it here */ -bool check_global_access(THD *thd, ulong want_access); #endif /* MYSQL_SERVER */ /** to protect innobase_open_files */ @@ -90,6 +86,8 @@ static pthread_cond_t commit_cond; static pthread_mutex_t commit_cond_m; static bool innodb_inited = 0; +#define INSIDE_HA_INNOBASE_CC + #ifdef MYSQL_DYNAMIC_PLUGIN /* These must be weak global variables in the dynamic plugin. */ struct handlerton* innodb_hton_ptr; @@ -3795,7 +3793,19 @@ no_commit: if (auto_inc > prebuilt->last_value) { set_max_autoinc: ut_a(prebuilt->table->autoinc_increment > 0); - auto_inc += prebuilt->table->autoinc_increment; + + ulonglong have; + ulonglong need; + + /* Check for overflow conditions. */ + need = prebuilt->table->autoinc_increment; + have = ~0x0ULL - auto_inc; + + if (have < need) { + need = have; + } + + auto_inc += need; err = innobase_set_max_autoinc(auto_inc); @@ -5527,8 +5537,15 @@ ha_innobase::create( DBUG_ASSERT(innobase_table != 0); - if ((create_info->used_fields & HA_CREATE_USED_AUTO) && - (create_info->auto_increment_value != 0)) { + /* Note: We can't call update_thd() as prebuilt will not be + setup at this stage and so we use thd. */ + + /* We need to copy the AUTOINC value from the old table if + this is an ALTER TABLE. */ + + if (((create_info->used_fields & HA_CREATE_USED_AUTO) + || thd_sql_command(thd) == SQLCOM_ALTER_TABLE) + && create_info->auto_increment_value != 0) { /* Query was ALTER TABLE...AUTO_INCREMENT = x; or CREATE TABLE ...AUTO_INCREMENT = x; Find out a table @@ -6326,7 +6343,7 @@ ha_innobase::info( } if (flag & HA_STATUS_AUTO && table->found_next_number_field) { - longlong auto_inc; + ulonglong auto_inc; int ret; /* The following function call can the first time fail in @@ -7684,9 +7701,9 @@ ha_innobase::innobase_read_and_init_auto_inc( /*=========================================*/ /* out: 0 or generic MySQL error code */ - longlong* value) /* out: the autoinc value */ + ulonglong* value) /* out: the autoinc value */ { - longlong auto_inc; + ulonglong auto_inc; ibool stmt_start; int mysql_error = 0; dict_table_t* innodb_table = prebuilt->table; @@ -7737,7 +7754,9 @@ ha_innobase::innobase_read_and_init_auto_inc( index, autoinc_col_name, &auto_inc); if (error == DB_SUCCESS) { - ++auto_inc; + if (auto_inc < ~0x0ULL) { + ++auto_inc; + } dict_table_autoinc_initialize(innodb_table, auto_inc); } else { ut_print_timestamp(stderr); @@ -7790,14 +7809,14 @@ ha_innobase::innobase_get_auto_increment( error = innobase_autoinc_lock(); if (error == DB_SUCCESS) { - ib_longlong autoinc; + ulonglong autoinc; /* Determine the first value of the interval */ autoinc = dict_table_autoinc_read(prebuilt->table); /* We need to initialize the AUTO-INC value, for that we release all locks.*/ - if (autoinc <= 0) { + if (autoinc == 0) { trx_t* trx; trx = prebuilt->trx; @@ -7816,14 +7835,11 @@ ha_innobase::innobase_get_auto_increment( mysql_error = innobase_read_and_init_auto_inc( &autoinc); - if (!mysql_error) { - /* Should have read the proper value */ - ut_a(autoinc > 0); - } else { + if (mysql_error) { error = DB_ERROR; } } else { - *value = (ulonglong) autoinc; + *value = autoinc; } /* A deadlock error during normal processing is OK and can be ignored. */ @@ -7908,10 +7924,19 @@ ha_innobase::get_auto_increment( /* With old style AUTOINC locking we only update the table's AUTOINC counter after attempting to insert the row. */ if (innobase_autoinc_lock_mode != AUTOINC_OLD_STYLE_LOCKING) { + ulonglong have; + ulonglong need; + + /* Check for overflow conditions. */ + need = *nb_reserved_values * increment; + have = ~0x0ULL - *first_value; + + if (have < need) { + need = have; + } /* Compute the last value in the interval */ - prebuilt->last_value = *first_value + - (*nb_reserved_values * increment); + prebuilt->last_value = *first_value + need; ut_a(prebuilt->last_value >= *first_value); diff --git a/handler/ha_innodb.h b/handler/ha_innodb.h index 9d9e520f729..509e2b65cfc 100644 --- a/handler/ha_innodb.h +++ b/handler/ha_innodb.h @@ -73,7 +73,7 @@ class ha_innobase: public handler void update_thd(); int change_active_index(uint keynr); int general_fetch(uchar* buf, uint direction, uint match_mode); - int innobase_read_and_init_auto_inc(longlong* ret); + int innobase_read_and_init_auto_inc(ulonglong* ret); ulong innobase_autoinc_lock(); ulong innobase_set_max_autoinc(ulonglong auto_inc); ulong innobase_reset_autoinc(ulonglong auto_inc); diff --git a/include/dict0dict.h b/include/dict0dict.h index 9a44273c925..8f2311e1ca4 100644 --- a/include/dict0dict.h +++ b/include/dict0dict.h @@ -179,12 +179,12 @@ void dict_table_autoinc_initialize( /*==========================*/ dict_table_t* table, /* in/out: table */ - ib_longlong value); /* in: next value to assign to a row */ + ib_ulonglong value); /* in: next value to assign to a row */ /************************************************************************ Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized. */ UNIV_INTERN -ib_longlong +ib_ulonglong dict_table_autoinc_read( /*====================*/ /* out: value for a new row, or 0 */ @@ -198,7 +198,7 @@ dict_table_autoinc_update( /*======================*/ dict_table_t* table, /* in/out: table */ - ib_longlong value); /* in: value which was assigned to a row */ + ib_ulonglong value); /* in: value which was assigned to a row */ /************************************************************************ Release the autoinc lock.*/ UNIV_INTERN diff --git a/include/dict0mem.h b/include/dict0mem.h index 22de263d6d4..94406fd3d27 100644 --- a/include/dict0mem.h +++ b/include/dict0mem.h @@ -445,7 +445,7 @@ struct dict_table_struct{ /* TRUE if the autoinc counter has been inited; MySQL gets the init value by executing SELECT MAX(auto inc column) */ - ib_longlong autoinc;/* autoinc counter value to give to the + ib_ulonglong autoinc;/* autoinc counter value to give to the next inserted row */ ib_longlong autoinc_increment; /* The increment step of the auto increment diff --git a/include/row0sel.h b/include/row0sel.h index 04feb4e18c1..b258bf462f7 100644 --- a/include/row0sel.h +++ b/include/row0sel.h @@ -181,7 +181,7 @@ row_search_max_autoinc( error code */ dict_index_t* index, /* in: index to search */ const char* col_name, /* in: autoinc column name */ - ib_longlong* value); /* out: AUTOINC value read */ + ib_ulonglong* value); /* out: AUTOINC value read */ /* A structure for caching column values for prefetched rows */ struct sel_buf_struct{ diff --git a/include/srv0srv.h b/include/srv0srv.h index 621bfb43c17..c2b7e5845c4 100644 --- a/include/srv0srv.h +++ b/include/srv0srv.h @@ -264,11 +264,7 @@ extern srv_sys_t* srv_sys; /* Alternatives for the file flush option in Unix; see the InnoDB manual about what these mean */ -#define SRV_UNIX_FDATASYNC 1 /* This is the default; it is - currently mapped to a call of - fsync() because fdatasync() seemed - to corrupt files in Linux and - Solaris */ +#define SRV_UNIX_FSYNC 1 /* This is the default */ #define SRV_UNIX_O_DSYNC 2 #define SRV_UNIX_LITTLESYNC 3 #define SRV_UNIX_NOSYNC 4 diff --git a/include/univ.i b/include/univ.i index afe14bc306a..3ed5bf2301b 100644 --- a/include/univ.i +++ b/include/univ.i @@ -253,9 +253,12 @@ typedef long int lint; #ifdef __WIN__ typedef __int64 ib_longlong; typedef unsigned __int64 ib_uint64_t; +typedef unsigned __int64 ib_ulonglong; #else +/* Note: longlong and ulonglong come from MySQL headers. */ typedef longlong ib_longlong; typedef ulonglong ib_uint64_t; +typedef ulonglong ib_ulonglong; #endif typedef unsigned long long int ullint; diff --git a/mysql-test/have_innodb.inc b/mysql-test/have_innodb.inc index cbffe6a2574..8944cc46f3e 100644 --- a/mysql-test/have_innodb.inc +++ b/mysql-test/have_innodb.inc @@ -1,4 +1,4 @@ disable_query_log; --require r/true.require -select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'innodb'; +select (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') as `TRUE` from information_schema.engines where engine = 'innodb'; enable_query_log; diff --git a/mysql-test/innodb-autoinc.result b/mysql-test/innodb-autoinc.result new file mode 100644 index 00000000000..3078eadf4a5 --- /dev/null +++ b/mysql-test/innodb-autoinc.result @@ -0,0 +1,89 @@ +drop table if exists t1; +CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (9223372036854775807, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +9223372036854775807 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (127, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +127 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (255, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +255 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (32767, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +32767 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (65535, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +65535 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (8388607, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +8388607 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (16777215, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +16777215 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (2147483647, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +2147483647 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (4294967295, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +4294967295 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (9223372036854775807, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +9223372036854775807 NULL +DROP TABLE t1; +CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (18446744073709551615, null); +INSERT INTO t1 (c2) VALUES ('innodb'); +Got one of the listed errors +SELECT * FROM t1; +c1 c2 +18446744073709551615 NULL +DROP TABLE t1; diff --git a/mysql-test/innodb-autoinc.test b/mysql-test/innodb-autoinc.test new file mode 100644 index 00000000000..b6bb9c6b0b7 --- /dev/null +++ b/mysql-test/innodb-autoinc.test @@ -0,0 +1,107 @@ +-- source include/have_innodb.inc +# embedded server ignores 'delayed', so skip this +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug #34335 +# +CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (9223372036854775807, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +## Test AUTOINC overflow +## + +# TINYINT +CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (127, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (255, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# SMALLINT +# +CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (32767, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (65535, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# MEDIUMINT +# +CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (8388607, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (16777215, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# INT +# +CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (2147483647, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (4294967295, null); +-- error ER_DUP_ENTRY,1062 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; +# +# BIGINT +# +CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (9223372036854775807, null); +-- error ER_DUP_ENTRY,1062 +-- warning ER_WARN_DATA_OUT_OF_RANGE,1264 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (18446744073709551615, null); +-- error ER_AUTOINC_READ_FAILED,1467 +INSERT INTO t1 (c2) VALUES ('innodb'); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/innodb.result b/mysql-test/innodb.result index 6e31b0142a4..f01c06007f0 100644 --- a/mysql-test/innodb.result +++ b/mysql-test/innodb.result @@ -1836,6 +1836,7 @@ set @a=repeat(' ',20); insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); Warnings: Note 1265 Data truncated for column 'v' at row 1 +Note 1265 Data truncated for column 'c' at row 1 select concat('*',v,'*',c,'*',t,'*') from t1; concat('*',v,'*',c,'*',t,'*') *+ *+*+ * @@ -3233,3 +3234,35 @@ a 2 DROP TABLE t1; DROP TABLE t2; +create table t1 (i int, j int) engine=innodb; +insert into t1 (i, j) values (1, 1), (2, 2); +update t1 set j = 2; +affected rows: 1 +info: Rows matched: 2 Changed: 1 Warnings: 0 +drop table t1; +create table t1 (id int) comment='this is a comment' engine=innodb; +select table_comment, data_free > 0 as data_free_is_set +from information_schema.tables +where table_schema='test' and table_name = 't1'; +table_comment data_free_is_set +this is a comment 1 +drop table t1; +CREATE TABLE t1 ( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +c2 VARCHAR(128) NOT NULL, +PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100; +CREATE TABLE t2 ( +c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +c2 INT(10) UNSIGNED DEFAULT NULL, +PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200; +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +AUTO_INCREMENT +200 +ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +AUTO_INCREMENT +200 +DROP TABLE t2; +DROP TABLE t1; diff --git a/mysql-test/innodb.test b/mysql-test/innodb.test index 6c6345389ad..cfaaad09116 100644 --- a/mysql-test/innodb.test +++ b/mysql-test/innodb.test @@ -2415,6 +2415,50 @@ DROP TABLE t1; DROP TABLE t2; DISCONNECT c1; DISCONNECT c2; +CONNECTION default; + +# +# Bug #29157 UPDATE, changed rows incorrect +# +create table t1 (i int, j int) engine=innodb; +insert into t1 (i, j) values (1, 1), (2, 2); +--enable_info +update t1 set j = 2; +--disable_info +drop table t1; + +# +# Bug #32440 InnoDB free space info does not appear in SHOW TABLE STATUS or +# I_S +# +create table t1 (id int) comment='this is a comment' engine=innodb; +select table_comment, data_free > 0 as data_free_is_set + from information_schema.tables + where table_schema='test' and table_name = 't1'; +drop table t1; + +# +# Bug 34920 test +# +CONNECTION default; +CREATE TABLE t1 ( + c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + c2 VARCHAR(128) NOT NULL, + PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100; + +CREATE TABLE t2 ( + c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + c2 INT(10) UNSIGNED DEFAULT NULL, + PRIMARY KEY(c1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200; + +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1); +SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2'; +DROP TABLE t2; +DROP TABLE t1; +# End 34920 test ####################################################################### # # diff --git a/mysql-test/innodb_bug34053.test b/mysql-test/innodb_bug34053.test index 5fbe09070b8..b935e45c06d 100644 --- a/mysql-test/innodb_bug34053.test +++ b/mysql-test/innodb_bug34053.test @@ -2,6 +2,7 @@ # Make sure http://bugs.mysql.com/34053 remains fixed. # +-- source include/not_embedded.inc -- source include/have_innodb.inc SET storage_engine=InnoDB; diff --git a/os/os0file.c b/os/os0file.c index c55a5aafc97..edd78b4d90c 100644 --- a/os/os0file.c +++ b/os/os0file.c @@ -22,8 +22,6 @@ Created 10/21/1995 Heikki Tuuri #include #endif /* UNIV_HOTBACKUP */ -#undef HAVE_FDATASYNC - #ifdef POSIX_ASYNC_IO /* We assume in this case that the OS has standard Posix aio (at least SunOS 2.6, HP-UX 11i and AIX 4.3 have) */ @@ -1866,8 +1864,6 @@ os_file_flush( ret = fsync(file); } } -#elif HAVE_FDATASYNC - ret = fdatasync(file); #else /* fprintf(stderr, "Flushing to file %p\n", file); */ ret = fsync(file); diff --git a/row/row0sel.c b/row/row0sel.c index 4a845e86091..2d3476d65f0 100644 --- a/row/row0sel.c +++ b/row/row0sel.c @@ -4656,7 +4656,7 @@ row_search_check_if_query_cache_permitted( Read the AUTOINC column from the current row. If the value is less than 0 and the type is not unsigned then we reset the value to 0. */ static -ib_longlong +ib_ulonglong row_search_autoinc_read_column( /*===========================*/ /* out: value read from the column */ @@ -4667,33 +4667,28 @@ row_search_autoinc_read_column( { ulint len; const byte* data; - ib_longlong value; + ib_ulonglong value; mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; rec_offs_init(offsets_); - /* TODO: We have to cast away the const of rec for now. This needs - to be fixed later.*/ - offsets = rec_get_offsets( - (rec_t*) rec, index, offsets, ULINT_UNDEFINED, &heap); + offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); - /* TODO: We have to cast away the const of rec for now. This needs - to be fixed later.*/ - data = rec_get_nth_field((rec_t*)rec, offsets, col_no, &len); + data = rec_get_nth_field(rec, offsets, col_no, &len); ut_a(len != UNIV_SQL_NULL); ut_a(len <= sizeof value); /* we assume AUTOINC value cannot be negative */ - value = (ib_longlong) mach_read_int_type(data, len, unsigned_type); + value = mach_read_int_type(data, len, unsigned_type); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } - if (!unsigned_type && value < 0) { + if (!unsigned_type && (ib_longlong) value < 0) { value = 0; } @@ -4732,7 +4727,7 @@ row_search_max_autoinc( column name can't be found in index */ dict_index_t* index, /* in: index to search */ const char* col_name, /* in: name of autoinc column */ - ib_longlong* value) /* out: AUTOINC value read */ + ib_ulonglong* value) /* out: AUTOINC value read */ { ulint i; ulint n_cols; diff --git a/srv/srv0srv.c b/srv/srv0srv.c index 76616c3c062..4d3dd4f7f27 100644 --- a/srv/srv0srv.c +++ b/srv/srv0srv.c @@ -162,7 +162,7 @@ a heavier load on the I/O sub system. */ UNIV_INTERN ulong srv_insert_buffer_batch_size = 20; UNIV_INTERN char* srv_file_flush_method_str = NULL; -UNIV_INTERN ulint srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; +UNIV_INTERN ulint srv_unix_file_flush_method = SRV_UNIX_FSYNC; UNIV_INTERN ulint srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; UNIV_INTERN ulint srv_max_n_open_files = 300; diff --git a/srv/srv0start.c b/srv/srv0start.c index b14e41323be..1348b19b3df 100644 --- a/srv/srv0start.c +++ b/srv/srv0start.c @@ -1091,12 +1091,12 @@ innobase_start_or_create_for_mysql(void) if (srv_file_flush_method_str == NULL) { /* These are the default options */ - srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; + srv_unix_file_flush_method = SRV_UNIX_FSYNC; srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; #ifndef __WIN__ - } else if (0 == ut_strcmp(srv_file_flush_method_str, "fdatasync")) { - srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; + } else if (0 == ut_strcmp(srv_file_flush_method_str, "fsync")) { + srv_unix_file_flush_method = SRV_UNIX_FSYNC; } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) { srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;