Commit 92268172 authored by marko's avatar marko

branches/zip: Merge revisions 5233:5341 from branches/5.1:

  ------------------------------------------------------------------------
  r5233 | marko | 2009-06-03 15:12:44 +0300 (Wed, 03 Jun 2009) | 11 lines

  branches/5.1: Merge the test case from r5232 from branches/5.0:
    ------------------------------------------------------------------------
    r5232 | marko | 2009-06-03 14:31:04 +0300 (Wed, 03 Jun 2009) | 21 lines

    branches/5.0: Merge r3590 from branches/5.1 in order to fix Bug #40565
    (Update Query Results in "1 Row Affected" But Should Be "Zero Rows").

    Also, add a test case for Bug #40565.

    rb://128 approved by Heikki Tuuri
    ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r5243 | sunny | 2009-06-04 03:17:14 +0300 (Thu, 04 Jun 2009) | 14 lines

  branches/5.1: When the InnoDB and MySQL data dictionaries go out of sync, before
  the bug fix we would assert on missing autoinc columns. With this fix we allow
  MySQL to open the table but set the next autoinc value for the column to the
  MAX value. This effectively disables the next value generation. INSERTs will
  fail with a generic AUTOINC failure. However, the user should be able to
  read/dump the table, set the column values explicitly, use ALTER TABLE to
  set the next autoinc value and/or sync the two data dictionaries to resume
  normal operations.

  Fix Bug#44030 Error: (1500) Couldn't read the MAX(ID) autoinc value from the
  index (PRIMARY)

  rb://118
  ------------------------------------------------------------------------
  r5252 | sunny | 2009-06-04 10:16:24 +0300 (Thu, 04 Jun 2009) | 2 lines

  branches/5.1: The version of the result file checked in was broken in r5243.
  ------------------------------------------------------------------------
  r5259 | vasil | 2009-06-05 10:29:16 +0300 (Fri, 05 Jun 2009) | 7 lines

  branches/5.1:

  Remove the word "Error" from the printout because the mysqltest suite
  interprets it as an error and thus the innodb-autoinc test fails.

  Approved by:	Sunny (via IM)
  ------------------------------------------------------------------------
  r5339 | marko | 2009-06-17 11:01:37 +0300 (Wed, 17 Jun 2009) | 2 lines

  branches/5.1: Add missing #include "mtr0log.h" so that the code compiles
  with -DUNIV_MUST_NOT_INLINE.

  (null merge; this had already been committed in branches/zip)
  ------------------------------------------------------------------------
  r5340 | marko | 2009-06-17 12:11:49 +0300 (Wed, 17 Jun 2009) | 4 lines

  branches/5.1: row_unlock_for_mysql(): When the clustered index is unknown,
  refuse to unlock the record.
  (Bug #45357, caused by the fix of Bug #39320).
  rb://132 approved by Sunny Bains.
  ------------------------------------------------------------------------
parent 3f449602
......@@ -2971,8 +2971,7 @@ ha_innobase::innobase_initialize_autoinc()
dict_index_t* index;
ulonglong auto_inc;
const char* col_name;
ulint error = DB_SUCCESS;
dict_table_t* innodb_table = prebuilt->table;
ulint error;
col_name = table->found_next_number_field->field_name;
index = innobase_get_index(table->s->next_number_index);
......@@ -2980,22 +2979,40 @@ ha_innobase::innobase_initialize_autoinc()
/* Execute SELECT MAX(col_name) FROM TABLE; */
error = row_search_max_autoinc(index, col_name, &auto_inc);
if (error == DB_SUCCESS) {
switch (error) {
case DB_SUCCESS:
/* At the this stage we dont' know the increment
/* At the this stage we don't know the increment
or the offset, so use default inrement of 1. */
++auto_inc;
break;
dict_table_autoinc_initialize(innodb_table, auto_inc);
} else {
case DB_RECORD_NOT_FOUND:
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Error: (%lu) Couldn't read "
"the MAX(%s) autoinc value from the "
"index (%s).\n", error, col_name, index->name);
}
fprintf(stderr, " InnoDB: MySQL and InnoDB data "
"dictionaries are out of sync.\n"
"InnoDB: Unable to find the AUTOINC column %s in the "
"InnoDB table %s.\n"
"InnoDB: We set the next AUTOINC column value to the "
"maximum possible value,\n"
"InnoDB: in effect disabling the AUTOINC next value "
"generation.\n"
"InnoDB: You can either set the next AUTOINC value "
"explicitly using ALTER TABLE\n"
"InnoDB: or fix the data dictionary by recreating "
"the table.\n",
col_name, index->table->name);
auto_inc = 0xFFFFFFFFFFFFFFFFULL;
break;
default:
return(error);
}
dict_table_autoinc_initialize(prebuilt->table, auto_inc);
return(DB_SUCCESS);
}
/*****************************************************************//**
......@@ -3213,7 +3230,6 @@ ha_innobase::open(
if (dict_table_autoinc_read(prebuilt->table) == 0) {
error = innobase_initialize_autoinc();
/* Should always succeed! */
ut_a(error == DB_SUCCESS);
}
......
......@@ -867,3 +867,25 @@ INSERT INTO t2 SELECT NULL FROM t1;
Got one of the listed errors
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (null);
INSERT INTO t1 VALUES (null);
ALTER TABLE t1 CHANGE c1 d1 INT NOT NULL AUTO_INCREMENT;
SELECT * FROM t1;
d1
1
3
SELECT * FROM t1;
d1
1
3
INSERT INTO t1 VALUES(null);
Got one of the listed errors
ALTER TABLE t1 AUTO_INCREMENT = 3;
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
d1
1
3
4
DROP TABLE t1;
......@@ -478,3 +478,23 @@ INSERT INTO t2 SELECT c1 FROM t1;
INSERT INTO t2 SELECT NULL FROM t1;
DROP TABLE t1;
DROP TABLE t2;
#
# 44030: Error: (1500) Couldn't read the MAX(ID) autoinc value from
# the index (PRIMARY)
# This test requires a restart of the server
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (null);
INSERT INTO t1 VALUES (null);
ALTER TABLE t1 CHANGE c1 d1 INT NOT NULL AUTO_INCREMENT;
SELECT * FROM t1;
# Restart the server
-- source include/restart_mysqld.inc
# The MySQL and InnoDB data dictionaries should now be out of sync.
# The select should print message to the error log
SELECT * FROM t1;
-- error ER_AUTOINC_READ_FAILED,1467
INSERT INTO t1 VALUES(null);
ALTER TABLE t1 AUTO_INCREMENT = 3;
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
DROP TABLE t1;
set session transaction isolation level read committed;
create table bug45357(a int, b int,key(b))engine=innodb;
insert into bug45357 values (25170,6122);
update bug45357 set a=1 where b=30131;
delete from bug45357 where b < 20996;
delete from bug45357 where b < 7001;
drop table bug45357;
-- source include/have_innodb.inc
set session transaction isolation level read committed;
create table bug45357(a int, b int,key(b))engine=innodb;
insert into bug45357 values (25170,6122);
update bug45357 set a=1 where b=30131;
delete from bug45357 where b < 20996;
delete from bug45357 where b < 7001;
drop table bug45357;
......@@ -1498,9 +1498,14 @@ row_unlock_for_mysql(
index = btr_pcur_get_btr_cur(clust_pcur)->index;
}
if (UNIV_UNLIKELY(!dict_index_is_clust(index))) {
/* This is not a clustered index record. We
do not know how to unlock the record. */
goto no_unlock;
}
/* If the record has been modified by this
transaction, do not unlock it. */
ut_a(dict_index_is_clust(index));
if (index->trx_id_offset) {
rec_trx_id = trx_read_trx_id(rec
......@@ -1540,7 +1545,7 @@ row_unlock_for_mysql(
prebuilt->select_lock_type);
}
}
no_unlock:
mtr_commit(&mtr);
}
......
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