From ab0fa111fef1afbd04156624cdb29781f08adcac Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Jan 2008 03:06:04 +0200 Subject: Fixed bug in restoring auto-increment value in case of duplicate key with insert or update Fixed bug when calculating max_key_length that caused some ALTER TABLE to fail if MAX_ROWS was used. Use maria_block_size instead of MARIA_MIN_KEY_BLOCK_LENGTH Fixed bug when scanning table with BLOCK format for repair; If table was > bitmap coverage one page block was read twice which caused a lot of duplicate key errors Could not repeat Bug#34106 "auto_increment is reset to 1 when table is recovered from crash" after this patch. NOTE: This is an incompatible change, so one must do maria_chk -r on ones old Maria tables! Sorry, but this was needed to fix the bug with max_key_length and to be able to handle bigger key files with smaller key references cmd-line-utils/readline/readline.c: Fixed compiler warnings mysql-test/r/maria.result: Added more test of auto-increment handling mysql-test/t/maria.test: Added more test of auto-increment handling mysys/my_pread.c: Fixed wrong test Removed not needed tests (error is always 1 if readbytes != Count) mysys/my_read.c: Fixed wrong test storage/maria/ha_maria.cc: Disable LOAD INDEX until I got Sanja's extension to pagecache interface storage/maria/ma_blockrec.c: Ensure that info->last_auto_increment is reset properly storage/maria/ma_check.c: Fixed wrong printing of row number in case of duplicate key for --safe-repair Safety fix in recreate table so that Column numbers are given to maria_create() in original order Added missing HA_OPEN_FOR_REPAIR to maria_open() Fixed bug when scanning table with BLOCK format for repair; If table was > bitmap coverage one page block was read twice which caused a lot of duplicate key errors storage/maria/ma_create.c: Use correct value for how much free space there is on a key page Remember some missing table option when doing re-create. Removed optimization where last packed fields is unpacked; Caused problems for re-create. storage/maria/ma_delete.c: Ensure that info->last_auto_increment is reset properly Fix for update to restore autoincrement value on duplicate key storage/maria/ma_key_recover.c: Moved handling of restoring value of auto-increment in case of duplicate key from clr to undo This ensures the restoring works both for insert and update and also that this is symetrical to how the auto_increment value is stored storage/maria/ma_key_recover.h: Added new prototype storage/maria/ma_loghandler.c: Added hook to write_hook_for_undo_key_delete() storage/maria/ma_open.c: Fixed wrong calculation of max_key_file_length storage/maria/ma_page.c: Use maria_block_size instead of MARIA_MIN_KEY_BLOCK_LENGTH Increase internal buffer (safety fix) storage/maria/ma_search.c: Use maria_block_size instead of MARIA_MIN_KEY_BLOCK_LENGTH Note that this is an incompatible change, so one must do maria_chk -r on ones old Maria tables (sorry) storage/maria/ma_update.c: Ensure that info->last_auto_increment is reset properly storage/maria/ma_write.c: Ensure that info->last_auto_increment is reset properly Fix for update to restore autoincrement value on duplicate key storage/maria/maria_chk.c: Allow small page_buffer_size Fixed printing for --describe to better fit into 80 characters storage/maria/maria_def.h: Added comments --- mysys/my_pread.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mysys/my_pread.c') diff --git a/mysys/my_pread.c b/mysys/my_pread.c index e0218cd1f1f..d3e308ad70f 100644 --- a/mysys/my_pread.c +++ b/mysys/my_pread.c @@ -66,11 +66,12 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count))) { my_errno= errno; - if (errno == 0 || (errno == -1 && (MyFlags & (MY_NABP | MY_FNABP)))) + if (errno == 0 || (readbytes == (size_t) -1 && + (MyFlags & (MY_NABP | MY_FNABP)))) my_errno= HA_ERR_FILE_TOO_SHORT; } #endif - if (error || readbytes != Count) + if (error) { DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d", (int) readbytes, (uint) Count,Filedes,my_errno)); -- cgit v1.2.1