mirror of
https://github.com/MariaDB/server.git
synced 2025-05-29 21:42:28 +03:00
Merge heikki@bk-internal.mysql.com:/home/bk/mysql-5.0
into hundin.mysql.fi:/home/heikki/mysql-5.0
This commit is contained in:
commit
96ee8cc0d5
@ -2430,32 +2430,32 @@ drop table t1;
|
|||||||
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
|
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
|
||||||
insert into t1 (b) values (1);
|
insert into t1 (b) values (1);
|
||||||
replace into t1 (b) values (2), (1), (3);
|
replace into t1 (b) values (2), (1), (3);
|
||||||
ERROR 23000: Duplicate entry '3' for key 1
|
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a b
|
a b
|
||||||
1 1
|
3 1
|
||||||
|
2 2
|
||||||
|
4 3
|
||||||
truncate table t1;
|
truncate table t1;
|
||||||
insert into t1 (b) values (1);
|
insert into t1 (b) values (1);
|
||||||
replace into t1 (b) values (2);
|
replace into t1 (b) values (2);
|
||||||
replace into t1 (b) values (1);
|
replace into t1 (b) values (1);
|
||||||
replace into t1 (b) values (3);
|
replace into t1 (b) values (3);
|
||||||
ERROR 23000: Duplicate entry '3' for key 1
|
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a b
|
a b
|
||||||
3 1
|
3 1
|
||||||
2 2
|
2 2
|
||||||
|
4 3
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 (rowid int not null auto_increment, val int not null,primary
|
create table t1 (rowid int not null auto_increment, val int not null,primary
|
||||||
key (rowid), unique(val)) engine=innodb;
|
key (rowid), unique(val)) engine=innodb;
|
||||||
replace into t1 (val) values ('1'),('2');
|
replace into t1 (val) values ('1'),('2');
|
||||||
replace into t1 (val) values ('1'),('2');
|
replace into t1 (val) values ('1'),('2');
|
||||||
ERROR 23000: Duplicate entry '3' for key 1
|
|
||||||
insert into t1 (val) values ('1'),('2');
|
insert into t1 (val) values ('1'),('2');
|
||||||
ERROR 23000: Duplicate entry '1' for key 2
|
ERROR 23000: Duplicate entry '1' for key 2
|
||||||
select * from t1;
|
select * from t1;
|
||||||
rowid val
|
rowid val
|
||||||
1 1
|
3 1
|
||||||
2 2
|
4 2
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
|
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
|
||||||
insert into t1 (val) values (1);
|
insert into t1 (val) values (1);
|
||||||
|
@ -1350,16 +1350,12 @@ drop table t1;
|
|||||||
|
|
||||||
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
|
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
|
||||||
insert into t1 (b) values (1);
|
insert into t1 (b) values (1);
|
||||||
# We shouldn't get the following error
|
|
||||||
--error 1062
|
|
||||||
replace into t1 (b) values (2), (1), (3);
|
replace into t1 (b) values (2), (1), (3);
|
||||||
select * from t1;
|
select * from t1;
|
||||||
truncate table t1;
|
truncate table t1;
|
||||||
insert into t1 (b) values (1);
|
insert into t1 (b) values (1);
|
||||||
replace into t1 (b) values (2);
|
replace into t1 (b) values (2);
|
||||||
replace into t1 (b) values (1);
|
replace into t1 (b) values (1);
|
||||||
# We shouldn't get the following error
|
|
||||||
--error 1062
|
|
||||||
replace into t1 (b) values (3);
|
replace into t1 (b) values (3);
|
||||||
select * from t1;
|
select * from t1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
@ -1367,8 +1363,6 @@ drop table t1;
|
|||||||
create table t1 (rowid int not null auto_increment, val int not null,primary
|
create table t1 (rowid int not null auto_increment, val int not null,primary
|
||||||
key (rowid), unique(val)) engine=innodb;
|
key (rowid), unique(val)) engine=innodb;
|
||||||
replace into t1 (val) values ('1'),('2');
|
replace into t1 (val) values ('1'),('2');
|
||||||
# We shouldn't get the following error
|
|
||||||
--error 1062
|
|
||||||
replace into t1 (val) values ('1'),('2');
|
replace into t1 (val) values ('1'),('2');
|
||||||
--error 1062
|
--error 1062
|
||||||
insert into t1 (val) values ('1'),('2');
|
insert into t1 (val) values ('1'),('2');
|
||||||
@ -1377,13 +1371,13 @@ drop table t1;
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test that update changes internal auto-increment value
|
# Test that update does not change internal auto-increment value
|
||||||
#
|
#
|
||||||
|
|
||||||
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
|
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
|
||||||
insert into t1 (val) values (1);
|
insert into t1 (val) values (1);
|
||||||
update t1 set a=2 where a=1;
|
update t1 set a=2 where a=1;
|
||||||
# We shouldn't get the following error
|
# We should get the following error because InnoDB does not update the counter
|
||||||
--error 1062
|
--error 1062
|
||||||
insert into t1 (val) values (1);
|
insert into t1 (val) values (1);
|
||||||
select * from t1;
|
select * from t1;
|
||||||
|
@ -3221,6 +3221,23 @@ no_commit:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A REPLACE command and LOAD DATA INFILE REPLACE handle a duplicate
|
||||||
|
key error themselves, and we must update the autoinc counter if we are
|
||||||
|
performing those statements. */
|
||||||
|
|
||||||
|
if (error == DB_DUPLICATE_KEY && auto_inc_used
|
||||||
|
&& (user_thd->lex->sql_command == SQLCOM_REPLACE
|
||||||
|
|| user_thd->lex->sql_command == SQLCOM_REPLACE_SELECT
|
||||||
|
|| (user_thd->lex->sql_command == SQLCOM_LOAD
|
||||||
|
&& user_thd->lex->duplicates == DUP_REPLACE))) {
|
||||||
|
|
||||||
|
auto_inc = table->next_number_field->val_int();
|
||||||
|
|
||||||
|
if (auto_inc != 0) {
|
||||||
|
dict_table_autoinc_update(prebuilt->table, auto_inc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
innodb_srv_conc_exit_innodb(prebuilt->trx);
|
innodb_srv_conc_exit_innodb(prebuilt->trx);
|
||||||
|
|
||||||
error = convert_error_code_to_mysql(error, user_thd);
|
error = convert_error_code_to_mysql(error, user_thd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user