Commit 8093d7a5 authored by vasil's avatar vasil

branches/zip: Merge 2489:2524 from branches/5.1:

  ------------------------------------------------------------------------
  r2519 | sunny | 2008-06-26 16:55:43 +0300 (Thu, 26 Jun 2008) | 5 lines
  
  branches/5.1: Add test cases and fix a bug where the last AUTOINC cached value
  was not reset to 0 when the table was truncated.
  
  Bug #37531 : After truncate, auto_increment behaves incorrectly for InnoDB
  
  ------------------------------------------------------------------------
  r2520 | vasil | 2008-06-26 17:38:02 +0300 (Thu, 26 Jun 2008) | 7 lines
  
  branches/5.1:
   
  Fix Bug#36941 Performance problem in ha_print_info (SHOW INNODB STATUS)
  by disabling some of the code in ha_print_info() in production builds.
   
  Approved by:	Heikki (via IM)
  
  ------------------------------------------------------------------------
  r2521 | vasil | 2008-06-26 17:39:01 +0300 (Thu, 26 Jun 2008) | 8 lines
  
  branches/5.1:
   
  Fix Bug#36942 Performance problem in lock_get_n_rec_locks (SHOW INNODB STATUS)
  by not calling lock_get_n_rec_locks() from lock_print_info_summary() on
  production builds.
   
  Approved by:	Heikki (via IM)
  
  ------------------------------------------------------------------------
  r2524 | vasil | 2008-07-01 10:37:34 +0300 (Tue, 01 Jul 2008) | 29 lines
  
  branches/5.1:
  
  Merge a change from MySQL (this fixes the failing innodb-replace test):
  
    revno: 2659
    committer: Mattias Jonsson <mattiasj@mysql.com>
    branch nick: b31210-51-bugteam
    timestamp: Tue 2008-06-03 13:25:41 +0200
    message:
      Bug#31210: INSERT DELAYED crashes server when used on partitioned tables
        
      Problem was an unclear error message since it could suggest that
      MyISAM did not support INSERT DELAYED.
      Changed the error message to say that DELAYED is not supported by the
      table, instead of the table's storage engine.
      The confusion is that a partitioned table is in somewhat sense using
      the partitioning storage engine, which in turn uses the ordinary
      storage engine. By saying that the table does not support DELAYED we
      do not give any extra informantion about the storage engine or if it
      is partitioned.
    modified:
      mysql-test/r/innodb-replace.result
      mysql-test/t/innodb-replace.test
      mysql-test/t/merge.test
      mysql-test/t/partition_hash.test
      sql/share/errmsg.txt
      sql/sql_insert.cc


------------------------------------------------------------------------
parent dd4efa39
......@@ -373,11 +373,20 @@ ha_print_info(
FILE* file, /* in: file where to print */
hash_table_t* table) /* in: hash table */
{
#ifdef UNIV_DEBUG
/* Some of the code here is disabled for performance reasons in production
builds, see http://bugs.mysql.com/36941 */
#define PRINT_USED_CELLS
#endif /* UNIV_DEBUG */
#ifdef PRINT_USED_CELLS
hash_cell_t* cell;
ulint cells = 0;
ulint n_bufs;
ulint i;
#endif /* PRINT_USED_CELLS */
ulint n_bufs;
#ifdef PRINT_USED_CELLS
for (i = 0; i < hash_get_n_cells(table); i++) {
cell = hash_get_nth_cell(table, i);
......@@ -387,10 +396,14 @@ ha_print_info(
cells++;
}
}
#endif /* PRINT_USED_CELLS */
fprintf(file, "Hash table size %lu",
(ulong) hash_get_n_cells(table));
fprintf(file,
"Hash table size %lu, used cells %lu",
(ulong) hash_get_n_cells(table), (ulong) cells);
#ifdef PRINT_USED_CELLS
fprintf(file, ", used cells %lu", (ulong) cells);
#endif /* PRINT_USED_CELLS */
if (table->heaps == NULL && table->heap != NULL) {
......
......@@ -6641,6 +6641,14 @@ ha_innobase::info(
if (thd_sql_command(user_thd) == SQLCOM_TRUNCATE) {
n_rows = 0;
/* We need to reset the prebuilt value too, otherwise
checks for values greater than the last value written
to the table will fail and the autoinc counter will
not be updated. This will force write_row() into
attempting an update of the table's AUTOINC counter. */
prebuilt->last_value = 0;
}
stats.records = (ha_rows)n_rows;
......
......@@ -4264,6 +4264,15 @@ lock_rec_print(
}
#ifndef UNIV_HOTBACKUP
#ifdef UNIV_DEBUG
/* Print the number of lock structs from lock_print_info_summary() only
in non-production builds for performance reasons, see
http://bugs.mysql.com/36942 */
#define PRINT_NUM_OF_LOCK_STRUCTS
#endif /* UNIV_DEBUG */
#ifdef PRINT_NUM_OF_LOCK_STRUCTS
/*************************************************************************
Calculates the number of record lock structs in the record lock hash table. */
static
......@@ -4290,6 +4299,7 @@ lock_get_n_rec_locks(void)
return(n_locks);
}
#endif /* PRINT_NUM_OF_LOCK_STRUCTS */
/*************************************************************************
Prints info of locks for all transactions. */
......@@ -4331,9 +4341,11 @@ lock_print_info_summary(
"History list length %lu\n",
(ulong) trx_sys->rseg_history_len);
#ifdef PRINT_NUM_OF_LOCK_STRUCTS
fprintf(file,
"Total number of lock structs in row lock hash table %lu\n",
(ulong) lock_get_n_rec_locks());
#endif /* PRINT_NUM_OF_LOCK_STRUCTS */
}
/*************************************************************************
......
......@@ -87,3 +87,85 @@ SELECT * FROM t1;
c1 c2
18446744073709551615 NULL
DROP TABLE t1;
CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
4
5
6
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
TRUNCATE TABLE t1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
4
5
6
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
4
5
6
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
DELETE FROM t1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
7
8
9
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
DROP TABLE t1;
......@@ -105,3 +105,37 @@ INSERT INTO t1 VALUES (18446744073709551615, null);
INSERT INTO t1 (c2) VALUES ('innodb');
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug 37531
# After truncate, auto_increment behaves incorrectly for InnoDB
#
CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
SHOW CREATE TABLE t1;
TRUNCATE TABLE t1;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
#
# Deleting all records should not reset the AUTOINC counter.
#
CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
SHOW CREATE TABLE t1;
DELETE FROM t1;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -3,11 +3,11 @@ create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=inn
select * from t1;
c1 c2 stamp
replace delayed into t1 (c1, c2) values ( "text1","11");
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR HY000: DELAYED option not supported for table 't1'
select * from t1;
c1 c2 stamp
replace delayed into t1 (c1, c2) values ( "text1","12");
ERROR HY000: Table storage engine for 't1' doesn't have this option
ERROR HY000: DELAYED option not supported for table 't1'
select * from t1;
c1 c2 stamp
drop table t1;
......@@ -11,10 +11,10 @@ drop table if exists t1;
#
create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
select * from t1;
--error 1031
--error ER_DELAYED_NOT_SUPPORTED
replace delayed into t1 (c1, c2) values ( "text1","11");
select * from t1;
--error 1031
--error ER_DELAYED_NOT_SUPPORTED
replace delayed into t1 (c1, c2) values ( "text1","12");
select * from t1;
drop table t1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment