mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
73e80314aa
mysql-test/r/insert_select.result: Result update. mysql-test/r/rpl_insert_id.result: Test update mysql-test/t/insert_select.test: Check if a partly completed INSERT SELECT (failing because of "Duplicate key" after successfully inserting other rows) is written to the binlog if the table is not transactional and at least one row has been inserted (bug #491) mysql-test/t/rpl_insert_id.test: Test for bug #490 (INSERT SELECT in auto_increment) sql/sql_insert.cc: - In INSERT ... SELECT, if it fails with error but one row has been inserted and the table is not transactional, we must write to the binlog (the slave will stop because of the error code in the binlog event, this is normal). bug 491. - we must set INSERT_ID before writing to the binlog (bug 490 accidentally introduced by another dev in 4.0.13).
89 lines
2.9 KiB
Text
89 lines
2.9 KiB
Text
#
|
|
# Problem with INSERT ... SELECT
|
|
#
|
|
|
|
drop table if exists t1,t2;
|
|
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
|
|
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
|
|
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
|
|
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
|
|
--error 1062
|
|
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
|
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
|
|
select * from t2;
|
|
drop table t1,t2;
|
|
#
|
|
# bug in bulk insert optimization
|
|
# test case by Fournier Jocelyn <joc@presence-pc.com>
|
|
#
|
|
|
|
DROP TABLE IF EXISTS crash1,crash2;
|
|
CREATE TABLE `crash1` (
|
|
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
|
`icone` tinyint(4) unsigned NOT NULL default '0',
|
|
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
|
`contenu` text NOT NULL,
|
|
`pseudo` varchar(50) NOT NULL default '',
|
|
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
|
`ip` bigint(11) NOT NULL default '0',
|
|
`signature` tinyint(1) unsigned NOT NULL default '0',
|
|
PRIMARY KEY (`numeropost`,`numreponse`)
|
|
,KEY `ip` (`ip`),
|
|
KEY `date` (`date`),
|
|
KEY `pseudo` (`pseudo`),
|
|
KEY `numreponse` (`numreponse`)
|
|
) TYPE=MyISAM;
|
|
|
|
CREATE TABLE `crash2` (
|
|
`numeropost` bigint(20) unsigned NOT NULL default '0',
|
|
`icone` tinyint(4) unsigned NOT NULL default '0',
|
|
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
|
|
`contenu` text NOT NULL,
|
|
`pseudo` varchar(50) NOT NULL default '',
|
|
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
|
`ip` bigint(11) NOT NULL default '0',
|
|
`signature` tinyint(1) unsigned NOT NULL default '0',
|
|
PRIMARY KEY (`numeropost`,`numreponse`),
|
|
KEY `ip` (`ip`),
|
|
KEY `date` (`date`),
|
|
KEY `pseudo` (`pseudo`),
|
|
KEY `numreponse` (`numreponse`)
|
|
) TYPE=MyISAM;
|
|
|
|
INSERT INTO crash2
|
|
(numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES
|
|
(9,1,56,'test','joce','2001-07-25 13:50:53'
|
|
,3649052399,0);
|
|
|
|
|
|
INSERT INTO crash1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
|
SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM crash2
|
|
WHERE numeropost=9 ORDER BY numreponse ASC;
|
|
|
|
show variables like '%bulk%';
|
|
|
|
INSERT INTO crash1 (numeropost,icone,contenu,pseudo,date,signature,ip)
|
|
SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM crash2
|
|
WHERE numeropost=9 ORDER BY numreponse ASC;
|
|
|
|
DROP TABLE IF EXISTS crash1,crash2;
|
|
|
|
|
|
# Addendum by Guilhem:
|
|
# Check if a partly-completed INSERT SELECT in a MyISAM table goes
|
|
# into the binlog
|
|
drop table if exists t1;
|
|
drop table if exists t2;
|
|
create table t1(a int, unique(a));
|
|
insert into t1 values(2);
|
|
create table t2(a int);
|
|
insert into t2 values(1),(2);
|
|
reset master;
|
|
--error 1062
|
|
insert into t1 select * from t2;
|
|
# The above should produce an error, but still be in the binlog;
|
|
# verify the binlog :
|
|
let $VERSION=`select version()`;
|
|
--replace_result $VERSION VERSION
|
|
show binlog events;
|
|
drop table t1, t2;
|