Commit e71eb27a authored by Michael Widenius's avatar Michael Widenius

Fixed bug lp:826377 "Aria DB Format: Reading specific table from dump causes Wrong bytesec"

The bug was that when using bulk insert combined with lock table, we intitalized the io cache with the wrong file position.
This fixed a bug where MariaDB could not read in a table dump done with mysqldump.


mysql-test/suite/maria/r/locking.result:
  Test case for locking + write cache bug
mysql-test/suite/maria/t/locking.test:
  Test case for locking + write cache bug
storage/maria/ma_extra.c:
  Initialize write cache used with bulk insert to correct file length.
  (The old code didn't work if one was using LOCK TABLE for the given table).
parent 8b63d346
drop table if exists t1;
CREATE TABLE t1 (
`Vorgangsnr` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Datum_Eingang` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Erfassungs-/Buchungsdatum',
`Warennummer` varchar(20) DEFAULT NULL,
`BenutzerID` int(10) unsigned DEFAULT NULL,
`Vermerke_Versand` varchar(1024) DEFAULT NULL,
`Zubehr` varchar(250) DEFAULT NULL,
`Datum_Annahme` varchar(12) DEFAULT NULL,
`K_Lieferscheinnummer` int(10) unsigned DEFAULT NULL,
`RMANr` int(10) unsigned DEFAULT '0',
`K_Bestelldaten` varchar(1024) DEFAULT NULL COMMENT 'Bestellnr, Datum, Auftraggeber',
PRIMARY KEY (`Vorgangsnr`),
KEY `Datum_Eingang` (`Datum_Eingang`)
) ENGINE=Aria AUTO_INCREMENT=250 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
alter table t1 disable keys;
lock tables t1 write;
INSERT INTO t1 (Datum_Eingang, BenutzerID, Zubehr, Datum_Annahme) VALUES ('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006');
INSERT INTO t1 (Datum_Eingang, BenutzerID, Zubehr, Datum_Annahme) VALUES ('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006');
unlock tables;
select count(*) from t1;
count(*)
88
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
alter table t1 enable keys;
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
#
# Aria bugs that has to do with locking
#
--source include/have_maria.inc
disable_warnings;
drop table if exists t1;
enable_warnings;
#
# Test generating data with insert select
#
CREATE TABLE t1 (
`Vorgangsnr` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Datum_Eingang` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Erfassungs-/Buchungsdatum',
`Warennummer` varchar(20) DEFAULT NULL,
`BenutzerID` int(10) unsigned DEFAULT NULL,
`Vermerke_Versand` varchar(1024) DEFAULT NULL,
`Zubehr` varchar(250) DEFAULT NULL,
`Datum_Annahme` varchar(12) DEFAULT NULL,
`K_Lieferscheinnummer` int(10) unsigned DEFAULT NULL,
`RMANr` int(10) unsigned DEFAULT '0',
`K_Bestelldaten` varchar(1024) DEFAULT NULL COMMENT 'Bestellnr, Datum, Auftraggeber',
PRIMARY KEY (`Vorgangsnr`),
KEY `Datum_Eingang` (`Datum_Eingang`)
) ENGINE=Aria AUTO_INCREMENT=250 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
alter table t1 disable keys;
lock tables t1 write;
let $loop=2;
while ($loop)
{
INSERT INTO t1 (Datum_Eingang, BenutzerID, Zubehr, Datum_Annahme) VALUES ('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006'),('2006-06-21 00:00:00', 713, 'ohne Zubehr', '21.06.2006');
dec $loop;
}
unlock tables;
select count(*) from t1;
check table t1 extended;
alter table t1 enable keys;
check table t1 extended;
drop table t1;
...@@ -143,7 +143,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -143,7 +143,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
(READ_CACHE_USED | WRITE_CACHE_USED | OPT_NO_ROWS)) && (READ_CACHE_USED | WRITE_CACHE_USED | OPT_NO_ROWS)) &&
!share->state.header.uniques) !share->state.header.uniques)
if (!(init_io_cache(&info->rec_cache, info->dfile.file, cache_size, if (!(init_io_cache(&info->rec_cache, info->dfile.file, cache_size,
WRITE_CACHE,share->state.state.data_file_length, WRITE_CACHE, info->state->data_file_length,
(pbool) (info->lock_type != F_UNLCK), (pbool) (info->lock_type != F_UNLCK),
MYF(share->write_flag & MY_WAIT_IF_FULL)))) MYF(share->write_flag & MY_WAIT_IF_FULL))))
{ {
......
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