Commit graph

173 commits

Author SHA1 Message Date
Michael Widenius
26f988594c Aria fixes:
- Don't delete pages without flushing that has had a tail or head information in pagecache_delete()
  This fixes a case where REPAIR could find old deleted rows.


storage/maria/ha_maria.cc:
  Remove calls to depricated function ha_statistic_increment
storage/maria/ma_blockrec.c:
  Don't delete pages without flushing that has had a tail or head information in pagecache_delete()
storage/maria/ma_pagecache.c:
  Added possibility to mark pages to not be deleted by pagecache_delete() without beeing flushed.
storage/maria/ma_pagecache.h:
  Added new prototype
2011-01-07 12:17:34 +02:00
Michael Widenius
5b0afd8a0d Bug fixing in Aria:
- Fixed some bugs in recovery of blobs
- Don't ASSERT() on checksum errors when running check table
- Added to maria_read_log option --tables-to-redo=list-of-tables to only recover some tables (good for debugging)


storage/maria/ma_blockrec.c:
  Don't ASSERT() on checksum errors when running check table
  Fixed bug in recovery of blog page that was not in dirty pages list
storage/maria/ma_check.c:
  Don't ASSERT() on checksum errors when running check table
storage/maria/ma_recovery.c:
  Handling of --tables-to-redo
storage/maria/ma_recovery.h:
  Handling of --tables-to-redo
storage/maria/ma_recovery_util.c:
  Give better warning if table was not in dirty pages list
storage/maria/maria_def.h:
  Added in_check_table
storage/maria/maria_read_log.c:
  Added --tables-to-redo=list-of-tables to only recover some tables (good for debugging)
  Cleaned up message when wrong arguments
2011-01-06 22:49:17 +02:00
Michael Widenius
6b03fbf9fc Fixed overwrite of directory information on the row page.
This could only happen with very small rows on very full pages with old deleted information in middle of page.
2011-01-05 15:46:44 +02:00
Michael Widenius
1e0b42d91f Fixed recovery problem in Aria where bitmap had wrong information after recovery.
LP#619731: Aria recovery corruption "Page 1: Row: 1 has an extent with wrong information in bitmap

storage/maria/ma_bitmap.c:
  Don't send broadcast if no one is waiting for it
storage/maria/ma_blockrec.c:
  Don't update bitmap if the page is not in the dirty_page list (or LSN is after checkpoint start)
  Fixes the case where we have in the log redo_free_block followed by another redo entry for the same page which is ignored.
  Also fixed that _ma_apply_redo_insert_row_blobs() doesn't update the bitmap in similar circumstances.
storage/maria/ma_blockrec.h:
  Updated prototype
storage/maria/ma_check.c:
  Added printing of bitmap information if used with maria_chk -vvv (for debugging)
storage/maria/ma_recovery.c:
  Updated call parameters to _ma_apply_redo_free_blocks().
2011-01-05 00:09:05 +02:00
Michael Widenius
865685dc0c Fixed bug in Aria that caused REPAIR to find old deleted rows.
BUILD/compile-pentium64:
  Added --with-zlib-dir=bundled when doing static build.
mysql-test/suite/maria/r/maria.result:
  Added test case
mysql-test/suite/maria/t/maria.test:
  Added test case
storage/maria/ma_blockrec.c:
  We need to flush blob pages to disk to ensure they overwrite any reused head/tail pages.
  If not, REPAIR will find rows that was previously deleted.
2010-12-21 19:22:20 +02:00
Michael Widenius
e3c8798eb6 When scanning pages, stop when you are at 'data_file_length'.
This fixes a bug that gave ER_FILE_TOO_SHORT error when scanning Aria tables.

storage/maria/ma_blockrec.c:
  Changed code so that we update share->state.state.data_file_length after page cache write is done.
  When scanning pages, stop when you are at 'data_file_length'.
  (We can't trust the bitmap as there may be reserved pages in the bitmap that are not yet written).
  This fixes a bug that gave ER_FILE_TOO_SHORT error when scanning Aria tables.
storage/maria/maria_def.h:
  Updated struct for stopping scanning at end of file
2010-11-04 16:57:30 +02:00
Michael Widenius
5b3159dbc7 Fixed compiler & valgrind warnings from my previous push.
Fixed a bug in Aria when two threads was inserting into the same table and row page and one thread did an abort becasue of duplicate key.



mysys/thr_lock.c:
  Fixed valgrind warning
sql/sql_base.cc:
  Remove not used variable
storage/maria/ma_bitmap.c:
  Added ma_bitmap_lock() & ma_bitmap_unlock() to protect against two threads using the bitmap at the same time.
  More DBUG_PRINT()
storage/maria/ma_blockrec.c:
  Fixed a bug in Aria when two threads was inserting into the same table and row page and one thread did an abort becasue of duplicate key.
  Fix was that we block other threads to modify the bitmap while we are removing the row with a duplicate key.
storage/maria/ma_blockrec.h:
  Added ma_bitmap_lock() & ma_bitmap_unlock() to protect against two threads using the bitmap at the same time.
storage/maria/maria_def.h:
  Changed flush_all_requested to be a counter.
storage/myisam/mi_locking.c:
  Fixed compiler error on windows (typo).
2010-11-03 14:14:02 +02:00
Michael Widenius
20acfbf30d Fix for: LP #634955: Assert in _ma_update_at_original_place()
Added locking of lock mutex when updating status in external_unlock() for Aria and MyISAM tables.
Fixed that 'source' command doesn't cause mysql command line tool to exit on error.
DEBUG_EXECUTE() and DEBUG_EVALUATE_IF() should not execute things based on wildcards. (Allows one to run --debug with mysql-test-run scripts that uses @debug)
Fixed several core dump, deadlock and crashed table bugs in handling of LOCK TABLE with MERGE tables:
- Added priority of locks to avoid crashes with MERGE tables.
- Added thr_lock_merge() to allow one to merge two results of thr_lock().
Fixed 'not found row' bug in REPLACE with Aria tables.
Mark MyISAM tables that are part of MERGE with HA_OPEN_MERGE_TABLE and set the locks to have priority THR_LOCK_MERGE_PRIV.
- By sorting MERGE tables last in thr_multi_unlock() it's safer to release and relock them many times (can happen when TRIGGERS are created)
Avoid printing (null) in debug file (to easier find out wrong NULL pointer usage with %s).



client/mysql.cc:
  Fixed that 'source' command doesn't cause mysql command line tool to exit on error.
client/mysqltest.cc:
  Don't send NULL to fn_format(). (Can cause crash on Solaris when using --debug)
dbug/dbug.c:
  DEBUG_EXECUTE() and DEBUG_EVALUATE_IF() should not execute things based on wildcards.
include/my_base.h:
  Added flag to signal if one opens a MERGE table.
  Added extra() command to signal that one is not part of a MERGE table anymore.
include/thr_lock.h:
  Added priority for locks (needed to fix bug in thr_lock when using MERGE tables)
  Added option to thr_unlock() if get_status() should be called.
  Added prototype for thr_merge_locks().
mysql-test/mysql-test-run.pl:
  Ignore crashed table warnings for tables named 'crashed'.
mysql-test/r/merge.result:
  Renamed triggers to make debugging easier.
  Added some CHECK TABLES to catch errors earlier.
  Additional tests.
mysql-test/r/merge_debug.result:
  Test of error handling when reopening MERGE tables.
mysql-test/r/udf_query_cache.result:
  Added missing flush status
mysql-test/suite/parts/r/partition_repair_myisam.result:
  Update results
mysql-test/t/merge.test:
  Renamed triggers to make debugging easier.
  Added some CHECK TABLES to catch errors earlier.
  Additional tests.
mysql-test/t/merge_debug.test:
  Test of error handling when reopening MERGE tables.
mysql-test/t/udf_query_cache.test:
  Added missing flush status
mysys/my_getopt.c:
  Removed not used variable
mysys/my_symlink2.c:
  Changed (null) to (NULL) to make it easier to find NULL arguments to DBUG_PRINT() functions.
  (On linux, NULL to sprintf is printed 'null')
mysys/thr_lock.c:
  Added priority of locks to avoid crashes with MERGE tables.
  Added thr_lock_merge() to allow one to merge two results of thr_lock().
  - This is needed for MyISAM as all locked table must share the same status. If not, you will not see newly inserted rows in other instances of the table.
  If calling thr_unlock() with THR_UNLOCK_UPDATE_STATUS, call update_status() and restore_status() for the locks. This is needed in some rare cases where we call thr_unlock() followed by thr_lock() without calling external_unlock/external_lock in between.
  Simplify loop in thr_multi_lock().
  Added 'start_trans', which is called at end of thr_multi_lock() when all locks are taken.
  - This was needed by Aria to ensure that transaction is started when we got all locks, not at get_status(). Without this, some rows could not be visible when we lock two tables at the same time, causing REPLACE using two tables to fail unexpectedly.
sql/handler.cc:
  Add an assert() in handler::print_error() for "impossible errors" (like table is crashed) when --debug-assert-if-crashed-table is used.
sql/lock.cc:
  Simplify mysql_lock_tables() code if get_lock_data() returns 0 locks.
  Added new parameter to thr_multi_unlock()
  In mysql_unlock_read_tables(), call first externa_unlock(), then thr_multi_unlock();  This is same order as we do in mysql_unlock_tables().
  Don't abort locks in mysql_lock_abort() for merged tables when a MERGE table is deleted; Would cause a spin lock.
  Added call to thr_merge_locks() in mysql_lock_merge() to ensure consistency in thr_locks().
  - New locks of same type and table is stored after the old lock to ensure that we get the status from the original lock.
sql/mysql_priv.h:
  Added debug_assert_if_crashed_table
sql/mysqld.cc:
  Added --debug-assert-if-crashed-table
sql/parse_file.cc:
  Don't print '(null)' in DBUG_PRINT of no dir given
sql/set_var.cc:
  Increase default size of buffer for @debug variable.
sql/sql_base.cc:
  In case of error from reopen_table() in reopen_tables(), call unlock_open_table() and restart loop.
  - This fixed bug when we twice deleted same table from open_cache.
  Don't take name lock for already name locked table in open_unireg_entry().
  - Fixed bug when doing repair in reopen_table().
  - In detach_merge_children(), always detach if 'clear_refs' is given. We can't trust parent->children_attached as this function can be called twice, first time with clear_refs set to 0.
sql/sql_class.cc:
  Changed printing of (null) to "" in set_thd_proc_info()
sql/sql_parse.cc:
  Added DBUG
sql/sql_trigger.cc:
  Don't call unlink_open_table() if reopen_table() fails as the table may already be freed.
storage/maria/ma_bitmap.c:
  Fixed DBUG_ASSERT() in allocate_tail()
storage/maria/ma_blockrec.c:
  Fixed wrong calculation of row length for very small rows in undo_row_update().
  - Fixes ASSERT() when doing undo.
storage/maria/ma_blockrec.h:
  Added _ma_block_start_trans() and _ma_block_start_trans_no_versioning()
storage/maria/ma_locking.c:
  Call _ma_update_status_with_lock() when releasing write locks.
  - Fixes potential problem with updating status without the proper lock.
storage/maria/ma_open.c:
  Changed to use start_trans() instead of get_status() to ensure that we see all rows in all locked tables when we got the locks.
  - Fixed 'not found row' bug in REPLACE with Aria tables.
storage/maria/ma_state.c:
  Added _ma_update_status_with_lock() and _ma_block_start_trans().
  This is to ensure that we see all rows in all locked tables when we got the locks.
storage/maria/ma_state.h:
  Added _ma_update_status_with_lock()
storage/maria/ma_write.c:
  More DBUG_PRINT
storage/myisam/mi_check.c:
  Fixed error message
storage/myisam/mi_extra.c:
  Added HA_EXTRA_DETACH_CHILD:
  - Detach MyISAM table to not be part of MERGE table (remove flag & lock priority).
storage/myisam/mi_locking.c:
  Call mi_update_status_with_lock() when releasing write locks.
  - Fixes potential problem with updating status without the proper lock.
  Change to use new HA_OPEN_MERGE_TABLE flag to test if MERGE table.
  Added mi_fix_status(), called by thr_merge().
storage/myisam/mi_open.c:
  Added marker if part of MERGE table.
  Call mi_fix_status() in thr_lock() for transactional tables.
storage/myisam/myisamdef.h:
  Change my_once_flag to uint, as it stored different values than just 0/1
  Added 'open_flag' to store state given to mi_open()
storage/myisammrg/ha_myisammrg.cc:
  Add THR_LOCK_MERGE_PRIV to THR_LOCK_DATA to get MERGE locks sorted after other types of locks.
storage/myisammrg/myrg_locking.c:
  Remove windows specific code.
storage/myisammrg/myrg_open.c:
  Use HA_OPEN_MERGE_TABLE to mi_open().
  Set HA_OPEN_MERGE_TABLE for linked MyISAM tables.
storage/xtradb/buf/buf0buf.c:
  Fixed compiler warning
storage/xtradb/buf/buf0lru.c:
  Initialize variable that could be used not initialized.
2010-11-02 17:22:57 +02:00
Michael Widenius
b9890b0544 Fix for LP#634943 "marked as crashed", "zerofilling" and "wrong data in bitmap" when recovering Aria tables
This was an interaction of several bugs:
- Tables marked as opened was not properly unmarked on recovery if there was not changes since checkpoint
- zerofill of tables put wrong data in bitmap if directory for page was full
- Tables was thought as 'moved' during recovery if they had a create_lsn bigger than the lsn in the control file.


storage/maria/ha_maria.cc:
  If table is moved and crashed, threat it as crashed.
  (Not a related to this bug, but still good to have fixed)
storage/maria/ma_blockrec.c:
  Make enough_free_entries_on_page() global
storage/maria/ma_blockrec.h:
  Make enough_free_entries_on_page() global
storage/maria/ma_check.c:
  If directory is full, mark page full. Fixes bug in zerofill
storage/maria/ma_open.c:
  Don't marke files as MOVED during recovery if create_trid > trnman_max_trid, as this fails for tables created after checkpoint.
storage/maria/ma_recovery.c:
  Reset open_count in file that was open during crash and was part of checkpoint.
  Fixed wrong warning of 'open count' after recovery of files that was not touched since checkpoint.
storage/maria/maria_chk.c:
  Changed not documented option --log-dir to --logdir
  Document more of the options.
  Clean up output for --help
storage/maria/trnman.c:
  Added DBUG_PRINT
2010-09-10 23:27:26 +03:00
Michael Widenius
1a0315f1e7 Write message to stderr if recovery is not likely to succeed because we don't log records for batch inserts.
Don't do UNDO or REDO on a crashed table.
More DBUG_PRINT

sql/sql_parse.cc:
  Remove display of 'packet' which is not useful
storage/maria/ma_blockrec.c:
  More DBUG_PRINT()
storage/maria/ma_key_recover.c:
  Write page number instead of page position
storage/maria/ma_recovery.c:
  Write message to stderr if recovery is not likely to succeed because we don't log records for batch inserts.
  In normal cases this should never be an issue as we would recreate an empty table if MariaDB dies under batch insert.
  This warning will be given if you remove all tables and try to recreate them with maria_read_log, which can't be done as
  the log doesn't contain all data.
  Don't do UNDO or REDO on a crashed table.
storage/maria/ma_write.c:
  Write page number instead of page position.
2010-09-09 02:01:05 +03:00
Michael Widenius
89e62085c6 Fixed recovery bug where bitmap pages would not be correctly updated after processing UNDO rows.
Fixed test failures in buildbot
Don't write errors when failing to send ok packet

mysql-test/suite/pbxt/r/range.result:
  Don't write number of rows as it varies.
mysql-test/suite/pbxt/t/range.test:
  Don't write number of rows as it varies.
sql/mysqld.cc:
  Don't write errors when failing to send ok packet
storage/maria/ma_bitmap.c:
  Added DBUG_ASSERT to detect wrong bitmap pages
storage/maria/ma_blockrec.c:
  Don't reset BLOCKUSED_USE_ORG_BITMAP flag. This fixed a bug where bitmap could be wrong after UNDO of row with blobs
2010-09-07 19:58:39 +03:00
Michael Widenius
ecf95c6e7f Fix of LP#616253 Crash in _ma_bitmap_set_full_page_bits on Aria recovery
The bug was based on wrong undo data in recovery file and not enough checking of bad data.

sql/sql_select.h:
  Added comment
storage/maria/ma_blockrec.c:
  - Removed wrong sanity checks (didn't work for UNDO records)
  - More sanity checks and DBUG_ASSERT
  - More DBUG_ENTER and DBUG_PRINT
  - Removed filler blocks in extent_to_bitmap_blocks() as it caused problems in write_block_record().
    This was the main cause of the bug.
    (This change can make records generated by UNDO slightly smaller than original record, which we have to fix
    by correcting row_pos.length before calling write_block_record())
  - Fixed some problems in write_block_record() while doing UNDO.
  - Store header_length without TRANSID_SIZE into recovery log (as UNDO entires doesn't have TRANSID_SIZE)
  - Mark table crashed if something goes wrong during UNDO
storage/maria/maria_def.h:
  Added header_length
2010-08-24 20:17:17 +03:00
Michael Widenius
096666fcbb Fixed compilation failure and added some new suppressions
storage/maria/ma_blockrec.c:
  Fixed compilation failure
support-files/compiler_warnings.supp:
  Added suppressions for pbxt
2010-08-20 16:16:47 +03:00
Michael Widenius
66ee158b3a Fixed wrong macro that caused compile failures when compiling without DBUG 2010-08-20 11:39:10 +03:00
Michael Widenius
6ab5a8ac81 Fixed valgrind errors and compiler warnings discovered by buildbot
More DBUG_ASSERT() to discover errors earlier
More checking of BLOCK structures in Aria.
Fixed crashing bug in Aria when doing UPDATE of several records in same block when doing table scan.

storage/federatedx/ha_federatedx.cc:
  Added missing delete_dynamic(); This fixes the valgrind warnings about lost memory discovered by buildbot.
storage/maria/ma_blockrec.c:
  Added debugging helper function _ma_print_block_info() to print block structure.
  Changed arguments to _ma_print_directory() so it can be called by _ma_print_block_info()
  check_directory() now also checks that empty_space on block is calculated correctly.
  Added some local variables to get more information about what happend when things crash.
  Fixed crashing bug when doing UPDATE of several records in same block when doing table scan.
storage/maria/ma_key_recover.c:
  Simple optimization (don't call bmove_upp() if not needed); This could happen during page split.
storage/maria/ma_recovery.c:
  Fixed compiler warning
storage/maria/ma_test2.c:
  Run test without syncing to disk. (Not needed for this test)
storage/maria/ma_write.c:
  More comments.
  Added DBUG_ASSERT() to find wrong log entires, like the one reported at LP#616344, during log file creation.
storage/maria/unittest/ma_test_recovery.pl:
  Added extra -s to maria_chk to get it more silent.
  This fixes that ma_test_all.sh works again.
2010-08-20 10:29:26 +03:00
Michael Widenius
e6cf286b5d Fixed LP#605798 RQG: Table corruption after Maria engine recovery - "Wrong data in bitmap"
maria_chk & maria_read_log now reads block size from control file.



mysql-test/suite/maria/r/maria.result:
  Updated results after trivial change of maria_chk's output
storage/maria/ma_bitmap.c:
  More DBUG_PRINT
storage/maria/ma_blockrec.c:
  Fixed bug that we didn't mark page full in bitmap if directory is full
storage/maria/ma_check.c:
  Write out if directory is full for errors in bitmap
storage/maria/ma_control_file.c:
  Don't give error for wrong block size if block size is 0
storage/maria/maria_chk.c:
  Read block size from control file
  In case of -dvv, write also out bitmap information (good for debugging)
storage/maria/maria_read_log.c:
  Read block size from control file
  Fixed that maria_read_log works with different page size than TRANSLOG_PAGE_SIZE
2010-08-11 00:58:08 +03:00
Michael Widenius
2e80f1bb09 Fix build failure on windows 2010-08-06 16:12:30 +03:00
Michael Widenius
d2f8b7d045 Fix for LP#602604: RQG: ma_blockrec.c:6187: _ma_apply_redo_insert_row_head_or_tail: Assertion `0' failed on Maria engine recovery
More DBUG_PRINT (to simplify future debugging)
Aria: Added STATE_IN_REPAIR, which is set on start of repair. This allows us to see if 'crashed' flag was set intentionally.
Aria: Some trivial speedup optimization
Aria: Better warning if table was marked crashed by unfinnished repair


mysql-test/lib/v1/mysql-test-run.pl:
  Fix so one can run RQG
mysql-test/suite/maria/r/maria-recovery2.result:
  Update for new error message.
mysys/stacktrace.c:
  Fixed compiler warning
storage/maria/ha_maria.cc:
  More DBUG_PRINT
  Added STATE_IN_REPAIR flag, which is set on start of repair. This allows us to see if 'crashed' flag was set intentionally.
  Don't log query for dropping temporary table.
storage/maria/ha_maria.h:
  Added prototype for drop_table()
storage/maria/ma_blockrec.c:
  More DBUG_PRINT
  Make read_long_data() inline for most cases. (Trivial speedup optimization)
storage/maria/ma_check.c:
  Better warning if table was marked crashed by unfinnished repair
storage/maria/ma_open.c:
  More DBUG_PRINT
storage/maria/ma_recovery.c:
  Give warning if found crashed table.
  Changed warning for tables that can't be opened.
storage/maria/ma_recovery_util.c:
  Write warnings to DBUG file
storage/maria/maria_chk.c:
  Added STATE_IN_REPAIR flag, which is set on start of repair. This allows us to see if 'crashed' flag was set intentionally.
storage/maria/maria_def.h:
  Added maria_mark_in_repair(x)
storage/maria/maria_read_log.c:
  Added option: --character-sets-dir
storage/maria/trnman.c:
  By default set min_read_from to max value.
  This allows us to remove TRN:s from rows during recovery to get more space.
  This fixes bug LP#602604: RQG: ma_blockrec.c:6187: _ma_apply_redo_insert_row_head_or_tail: Assertion `0' failed on Maria engine recovery
2010-07-30 10:45:27 +03:00
Michael Widenius
d77e3cde5f When one does a drop table, the indexes are not flushed to disk before drop anymore (with MyISAM/Maria)
myisam-recover options changed from OFF to 'DEFAULT' to get less change of data loss when using MyISAM.
(The disadvantage is that changed MyISAM tables will be checked at access time; Use --myisam-recover=OFF for old behavior)
Don't call extra(HA_EXTRA_FORCE_REOPEN) in ALTER TABLE if table is locked as this will mark table as crashed!
Added assert to detect if we accidently would use MyISAM versioning in MySQL

include/my_base.h:
  Mark NOT_USED as USED, as we now use this as a flag to not call extra()
mysql-test/mysql-test-run.pl:
  Don't write all options when there is something wrong with the arguments
mysql-test/r/sp-destruct.result:
  Add missing flush of mysql.proc (as the test copied live tables)
mysql-test/r/variables.result:
  myisam-recover options changed to 'default'
mysql-test/r/view.result:
  Don't show create time in result
mysql-test/suite/maria/t/maria-recovery2-master.opt:
  Don't run test with myisam-recover (as this produces extra warnings during simulated death)
mysql-test/t/sp-destruct.test:
  Add missing flush of mysql.proc (as the test copied live tables)
mysql-test/t/view.test:
  Don't show create time in result
sql/lock.cc:
  Added marker if table was deleted to argument list
sql/mysql_priv.h:
  Added marker if table was deleted to argument list
sql/mysqld.cc:
  myisam-recover options changed from OFF to 'DEFAULT' to get less change of data loss when using MyISAM
  Allow one to specify OFF as argument to myisam-recover (was default before but one couldn't specify it)
sql/sql_base.cc:
  Mark if table is going to be deleted
sql/sql_delete.cc:
  Mark if table is going to be deleted
sql/sql_table.cc:
  Mark if table is going to be deleted
  Don't call extra(HA_EXTRA_FORCE_REOPEN) in ALTER TABLE if table is locked as this will mark table as crashed!
sql/table.cc:
  Signal to handler if table is getting deleted as part of getting droped from table cache.
sql/table.h:
  Added marker if table is going to be deleted.
storage/maria/ha_maria.cc:
  Don't search for transaction handler if file is not transactional or outside of transaction
  (Fixed possible core dump)
storage/maria/ma_blockrec.c:
  Don't write changed information if table is going to be deleted.
storage/maria/ma_close.c:
  Don't write changed information if table is going to be deleted.
storage/maria/ma_extra.c:
  Mark tables that are deleted as crased, to ensure good behavior on restart if we suddenly crash.
storage/maria/ma_locking.c:
  Cleanup
storage/maria/ma_recovery.c:
  We need trnman to be inited during redo phase (to be able to open tables checked with maria_chk)
storage/maria/maria_def.h:
  Added marker if table is going to be deleted.
storage/myisam/mi_close.c:
  Don't write changed information if table is going to be deleted.
storage/myisam/mi_extra.c:
  Mark tables that are deleted as crased, to ensure good behavior on restart if we suddenly crash.
storage/myisam/mi_open.c:
  Added assert to detect if we accidently would use MyISAM versioning in MySQL
storage/myisam/myisamdef.h:
  Added marker if table is going to be deleted.
2010-02-10 21:06:24 +02:00
Michael Widenius
e926af9bf8 Merge with fixes for compiler warnings and 2 fixed test cases
Fixed some additional compiler warnings from OpenSolaris build.


extra/libevent/devpoll.c:
  Fixed compiler warning
mysys/my_file.c:
  Fixed compiler warning
sql/mysqld.cc:
  Fixed compiler warning
sql/rpl_record.cc:
  Removed not used variable
storage/maria/ma_blockrec.c:
  Fixed compiler warning
storage/xtradb/buf/buf0buf.c:
  Fixed compiler warning
storage/xtradb/handler/i_s.cc:
  Fixed compiler warning
support-files/compiler_warnings.supp:
  Added suppression of compiler warnings in InnoDB/XtraDB
  Added suppression of compiler warnings that can safely be ignored.
2010-01-28 13:35:10 +02:00
Michael Widenius
b96f268acc Removed compiler warnings
Fixed sporadic test failure for suit/pbxt/t/lock_multi.test
Fixed sporadic test faulure for suit/rpl/t/do_grant.test
OpenSolaris 5.11-x86 now compiles (tested with 32 bit)

BUILD/compile-solaris-amd64-debug-forte:
  Added execute bit
BUILD/compile-solaris-x86-32:
  Added execute bit
BUILD/compile-solaris-x86-32-debug:
  Added execute bit
BUILD/compile-solaris-x86-32-debug-forte:
  Added execute bit
BUILD/compile-solaris-x86-forte-32:
  Added execute bit
extra/libevent/devpoll.c:
  Removed compiler warning
extra/libevent/evbuffer.c:
  Removed compiler warning
extra/libevent/select.c:
  Removed compiler warning
mysql-test/mysql-test-run.pl:
  Fixed sporadic test faulure for suit/rpl/t/do_grant.test (Seen on OpenSolaris)
mysql-test/suite/pbxt/r/lock_multi.result:
  Fixed sporadic test failure for suit/pbxt/t/lock_multi.test (seen in buildbot)
  This was done by merging the test with main/lock_multi.test
mysql-test/suite/pbxt/t/lock_multi.test:
  Fixed sporadic test failure for suit/pbxt/t/lock_multi.test (seen in buildbot)
  This was done by merging the test with main/lock_multi.test
mysys/my_sync.c:
  Removed compiler warnings
sql/ha_ndbcluster.cc:
  Fixed linking error on OpenSolaris when compiling without ndb
  Bug #34866 Can't compile on Solaris 9/Sparc with gcc
storage/archive/azlib.h:
  Removed compiler warning about redefined symbols
storage/maria/ma_blockrec.c:
  Removed compiler warning
storage/maria/ma_loghandler.c:
  Removed compiler warning
storage/maria/ma_test3.c:
  Removed compiler warning
storage/myisam/mi_test3.c:
  Removed compiler warning
storage/pbxt/src/ha_pbxt.cc:
  Removed compiler warning
  thr_main -> thr_main_pbxt
storage/pbxt/src/restart_xt.cc:
  thr_main -> thr_main_pbxt
storage/pbxt/src/thread_xt.cc:
  thr_main -> thr_main_pbxt
  This was needed as thr_main() is an internal thread function on OpenSolaris()
storage/pbxt/src/thread_xt.h:
  thr_main -> thr_main_pbxt
storage/xtradb/srv/srv0srv.c:
  Use compatiblity macro to get code to work on OpenSolaris
support-files/compiler_warnings.supp:
  Ignore compiler warning from yassl
2010-01-06 23:27:53 +02:00
unknown
59f80387ba Fix some compiler warnings cause by GCC bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
storage/maria/ma_blockrec.c:
  GCC warns about const vs. non-const despite cast
  (but it is in any case cleaner to avoid the cast completely)
support-files/compiler_warnings.supp:
  Silence a wrong compiler warning caused by GCC bug.
2009-10-03 22:13:58 +02:00
unknown
b125770aaa We are now using Valgrind rather than purify, and have for quite some time.
Consequently, rename HAVE_purify to HAVE_valgrind, and related changes.
Leave some comments about purify when not clear that they apply also to Valgrind.
Fix redundant IF_VALGRIND declaration.

Misc. small fixes:
 - Fixes for pool-of-threads patch.
 - Fixes for push of PBXT storage engine.
 - mysql-test-run.pl fix.
 - Fix build problem in compile-pentium64-max.


BUILD/SETUP.sh:
  Rename purify -> valgrind.
BUILD/build_mccge.sh:
  Rename purify -> valgrind.
BUILD/compile-dist:
  Fix that PBXT was missing in source tarball after `BUILD/compile-dist && make dist`
BUILD/compile-pentium64-max:
  Fix a build problem with BUILD/compile-pentium64-max on CentOS/Fedora Core 10 amd64.
        
  On these systems, there is libz.so but no libz.a. Finding libz.so, ./configure decides
  to use system zlib. But since BUILD/compile-pentium64-max builds a fully static binary
  with -all-static, the link of mysqld fails due to missing libz.a.
        
  Fix by using bundled zlib in the build script.
BUILD/compile-solaris-sparc-purify:
  Rename purify -> valgrind.
include/m_string.h:
  Rename purify -> valgrind.
include/my_global.h:
  Rename purify -> valgrind.
mysql-test/Makefile.am:
  Fix that PBXT test suite was missing from `make dist` source tarball.
mysql-test/lib/mtr_unique.pm:
  Better fix to avoid races when chmod'ing the semaphore file.
  (Though using chmod 666 shared files in /tmp/ is still not a very good solution).
mysql-test/t/pool_of_threads.cnf:
  Fix that test case pool_of_threads fails if run on mysqld with no --with-libevent support.
mysys/mf_qsort.c:
  Rename purify -> valgrind.
mysys/my_alloc.c:
  Rename purify -> valgrind.
mysys/my_init.c:
  Rename purify -> valgrind.
mysys/my_rnd.c:
  Rename purify -> valgrind.
mysys/safemalloc.c:
  Rename purify -> valgrind.
scripts/mysql_config.pl.in:
  Rename purify -> valgrind.
scripts/mysql_config.sh:
  Rename purify -> valgrind.
sql/field_conv.cc:
  Rename purify -> valgrind.
sql/filesort.cc:
  Rename purify -> valgrind.
sql/ha_partition.cc:
  Rename purify -> valgrind.
sql/hostname.cc:
  Rename purify -> valgrind.
sql/item_timefunc.cc:
  Rename purify -> valgrind.
sql/log_event.cc:
  Rename purify -> valgrind.
sql/log_event_old.cc:
  Rename purify -> valgrind.
sql/my_decimal.h:
  Rename purify -> valgrind.
sql/mysqld.cc:
  Rename purify -> valgrind.
  Fix redundant IF_VALGRIND declaration.
sql/opt_range.cc:
  Rename purify -> valgrind.
sql/opt_range.h:
  Rename purify -> valgrind.
sql/records.cc:
  Rename purify -> valgrind.
sql/rpl_rli.cc:
  Rename purify -> valgrind.
sql/rpl_rli.h:
  Rename purify -> valgrind.
sql/set_var.cc:
  Fix missing static declaration on pool_of_threads.
sql/slave.cc:
  Rename purify -> valgrind.
sql/sql_base.cc:
  Rename purify -> valgrind.
sql/sql_binlog.cc:
  Rename purify -> valgrind.
sql/sql_class.cc:
  Rename purify -> valgrind.
sql/sql_list.h:
  Rename purify -> valgrind.
sql/sql_load.cc:
  Rename purify -> valgrind.
sql/sql_select.cc:
  Rename purify -> valgrind.
sql/table.cc:
  Rename purify -> valgrind.
storage/archive/azio.c:
  Rename purify -> valgrind.
storage/innobase/buf/buf0buf.c:
  Rename purify -> valgrind.
storage/innobase/include/univ.i:
  Rename purify -> valgrind.
storage/innobase/srv/srv0start.c:
  Rename purify -> valgrind.
storage/maria/ha_maria.cc:
  Rename purify -> valgrind.
storage/maria/ma_blockrec.c:
  Rename purify -> valgrind.
storage/maria/ma_check.c:
  Rename purify -> valgrind.
storage/maria/ma_loghandler.c:
  Rename purify -> valgrind.
storage/maria/ma_packrec.c:
  Rename purify -> valgrind.
storage/maria/ma_page.c:
  Rename purify -> valgrind.
storage/maria/ma_pagecrc.c:
  Rename purify -> valgrind.
storage/maria/ma_search.c:
  Rename purify -> valgrind.
storage/myisam/mi_check.c:
  Rename purify -> valgrind.
storage/myisam/mi_page.c:
  Rename purify -> valgrind.
storage/myisam/mi_search.c:
  Rename purify -> valgrind.
storage/myisammrg/ha_myisammrg.cc:
  Rename purify -> valgrind.
strings/bcmp.c:
  Rename purify -> valgrind.
strings/decimal.c:
  Rename purify -> valgrind.
strings/strmake.c:
  Rename purify -> valgrind.
2009-05-06 14:03:24 +02:00
Michael Widenius
92b2b45e4f Updated comment 2009-04-08 11:47:30 +03:00
Michael Widenius
945fa0d913 Merge with mysql-maria tree
mysql-test/t/variables.test:
  Reset delay_key_write, otherwise maria.maria test may fail
sql/set_var.cc:
  Reset ha_open_options if one resets the delay_key_write variable.
  Before there was no way to reset it without restarting mysqld, which caused some tests to fail
2009-02-19 11:01:25 +02:00
unknown
5564e53c42 merge 2009-02-06 00:38:30 +02:00
Michael Widenius
37db97b0e2 Merge with mysql-maria
Changed _ma_ft_convert_to_ft2() to my_bool

storage/maria/ma_ft_update.c:
  Changed _ma_ft_convert_to_ft2() to my_bool
storage/maria/ma_fulltext.h:
  Changed _ma_ft_convert_to_ft2() to my_bool
storage/maria/ma_write.c:
  Manual merge
  Changed _ma_ft_convert_to_ft2() to my_bool
2009-01-30 23:55:42 +02:00
Guilhem Bichot
a955efc40c Fix for BUG#41493 "Maria: two recovery failures (wrong logging of BLOB pages)" and some more debugging
output related to this.

mysql-test/suite/maria/r/maria-recovery3.result:
  result update
mysql-test/suite/maria/t/maria-recovery3.test:
  Test for bug; before the fix, the "CHECK TABLE EXTENDED" would mention a bad bitmap, because the
  REDO_INSERT_ROW_BLOBS was containing a page number which was actually the one of a tail, so execution of this
  record would mark the tail page as full in bitmap (like if it were a blob page), though it wasn't full.
  Also, the assertion added around ma_blockrec.c:6580 in the present revision fired.
storage/maria/ma_blockrec.c:
  - fix for BUG#41493: if we found out that logging was not needed at this point (blob_length==0 i.e. tail page),
  then we forgot to increment tmp_block, so in the second iteration (assuming two BLOB columns), we would log the
  page range of the first iteration (i.e. the tail page's number) for this second BLOB, which would cause
  Recovery to overwrite the tail page with the second BLOB.
  - assert when marking the table corrupted during REDO phase; this catches some problems earlier
  otherwise they get caught only when a later record wants to use the table.
  - _ma_apply_redo_insert_row_blobs() now fills some synthetic info about the blobs and pages involved
  in a REDO_INSERT_ROW_BLOBS record, for inclusion into maria_recovery.trace: number of blobs, of ranges,
  first and last page (does not tell about any gaps in the middle, but good enough for now). It also asserts
  that it's not overwriting a tail/head page (which happened in the bug).
storage/maria/ma_blockrec.h:
  new prototype for _ma_apply_redo_insert_row_blobs
storage/maria/ma_recovery.c:
  Print info got from _ma_apply_redo_insert_row_blobs() to maria_recovery.trace (so far this file had mentioned
  what head and tail pages a record touched, but not blob pages).
2009-01-15 16:14:47 +01:00
Michael Widenius
dd5b9fc6cd Merge with base MySQL-5.1-maria 2009-01-12 13:12:00 +02:00
Michael Widenius
7eda7f1337 Code cleanup:
- Removed not needed casts
- Indentation fixes
- Changed some buffer variables to uchar, to be able to remove casts


storage/maria/ma_bitmap.c:
  Removed not needed casts
storage/maria/ma_blockrec.c:
  Removed not needed casts
storage/maria/ma_check.c:
  Removed not needed casts.
  Changed type of buffers to be able to remove casts
storage/maria/ma_create.c:
  Removed not needed casts
storage/maria/ma_delete.c:
  Removed not needed casts
storage/maria/ma_dynrec.c:
  Removed not needed casts
storage/maria/ma_extra.c:
  Removed not needed casts
storage/maria/ma_ft_boolean_search.c:
  Removed not needed casts
storage/maria/ma_ft_nlq_search.c:
  Removed not needed casts
storage/maria/ma_ft_parser.c:
  Removed not needed casts
storage/maria/ma_loghandler.c:
  Removed not needed casts
storage/maria/ma_open.c:
  Removed not needed casts
storage/maria/ma_packrec.c:
  Removed not needed casts
storage/maria/ma_pagecache.c:
  Removed not needed casts
storage/maria/ma_preload.c:
  Removed not needed casts
  Removed not needed initialization
storage/maria/ma_rnext_same.c:
  Removed not needed casts
storage/maria/ma_rt_index.c:
  Removed not needed casts
storage/maria/ma_search.c:
  Removed not needed casts
storage/maria/ma_sort.c:
  Removed not needed casts
  Removed not needed if
  Fixed indentation
storage/maria/ma_statrec.c:
  Removed not needed casts
storage/maria/ma_test2.c:
  Removed not needed casts
storage/maria/ma_write.c:
  Removed not needed casts
  Indentation fixes
storage/maria/maria_chk.c:
  Removed not needed casts
storage/maria/maria_pack.c:
  Removed not needed casts
2009-01-09 06:23:25 +02:00
Michael Widenius
7dc83c5043 Fixed bugs from my latest patch found by pushbuild:
Bug #41962 Maria: view-related test failures (insert, view, maria, trigger tests)
Added error handling for wrong update of view.
See Bug #41760 Inserting into multiple-table views is not working

mysql-test/r/delayed.result:
  Fixed test as we are now testing values before fields.
  Added new tests to test all error combinations
mysql-test/suite/maria/r/maria.result:
  Added error handling for not supported update of view.
mysql-test/suite/maria/t/maria.test:
  Added error handling for not supported update of view.
mysql-test/t/delayed.test:
  Fixed test as we are now testing values before fields.
  Added new tests to test all error combinations
sql/sql_base.cc:
  Fixed warning from valgrind
sql/sql_insert.cc:
  Don't test from which table values are in case of INSERT ... SELECT
  Run fix_fields() in values before we do it on fields.
  This is needed becasue check_view_single_update() are accessing values.
storage/maria/ma_blockrec.c:
  Don't call pagecache_delete_pages() if no pages to delete.
  This fixes a DBUG_ASSERT() error in maria_test_recovery
2009-01-09 06:11:37 +02:00
unknown
dd8e57af7b _ma_state_info_write numeric flags changed with constants.
storage/maria/maria_def.h:
  Constants for _ma_state_info_write added.
2009-01-08 10:20:04 +02:00
Michael Widenius
910284e6e6 Fixed bugs found by pushbuild
Added code to detect and give error when doing an insert into a view where we accessed fields in a not yet read table
Disabled test in subselect.test as the CHECK_OPTION for views doesn't work for insert.
This needs to be fixed properly later.

The problem with views are described in Bug #41760 Inserting into multiple-table views is not working

mysql-test/r/insert.result:
  Fixed wrong usage of insert into view.
mysql-test/r/subselect.result:
  Disabled wrong test (temporary)
mysql-test/suite/maria/r/maria.result:
  Added test of size of table
mysql-test/suite/maria/t/maria.test:
  Added test of size of table
mysql-test/t/insert.test:
  Fixed wrong usage of insert into view
  The bug is that during insert/update we currently don't read any of the referenced tables of the view.
  This means that we can't get a value from another table to use as part of the update.
mysql-test/t/subselect.test:
  Disabled not working test until someone has time to fix insert into view properly
  Here we where refering to last used value in t2, which is wrong.
sql/sql_insert.cc:
  Detect if we are trying to update one table in a view based on value in another, not yet read, table.
  This fixes the problem discovered in insert.test
storage/maria/ma_blockrec.c:
  Don't ignore not critical changes to the last page in the table.
  We need to write the last page as otherwise we can during aborting of a row with a duplicate key get
  state.data_file_length and the real length of file out of sync
storage/maria/ma_check.c:
  Flush the page cache even if we got an error during zerofill.
  (This fixes a call to assert() in case of a too short data file)
storage/maria/ma_pagecache.c:
  Mark page as read when we do a write of a full page.
  This fixes a bug when we got an error during read and then used direct write to page to update it
storage/maria/ma_state.c:
  Restore info->lock.type after call to maria_versioning.
  Fixed crash in maria_recover.test
storage/maria/maria_read_log.c:
  Don't write thread id in debug log. (Not needed as maria_read_log is a single treaded program)
2008-12-27 04:05:16 +02:00
Michael Widenius
86fcfb1508 Fix for Bug#40311 Assert in MARIA_RECORD_POS during pushbuild 2 test:
Fixed bug when removing a newly inserted record (in case of duplicate key).
The bug caused a crash for rows with several blobs and the first blob was small enough to fit into the head page.
Don't change state_history if nothing changed (speed optimization that also simplifies logic).
Reset state_history if we added/deleted or updated rows without versioning.
Fixed wrong test in trnman_exists_active_transactions() if state is visible or not.

Other bugs fixed:
Fixed wrong argument to (lock->get_status) when we had to wait for TL_WRITE_CONCURRENT_INSERT.
Item_equal::update_used_tables() didn't calculate const_item_cache properly.
Added assert's to detect if join_read_const_table() was called under wrong assumptions..
Fixed that _ma_setup_live_state() is called from thr_lock() instead of handler::external_lock().
This was needed to get versioning information to be setup correctly.
Fixed error in debug binaries during a call to _ma_check_table_is_closed() when another thread was opening/closing a table.
Fixed wrong test when finding right history_state to use.

mysql-test/suite/maria/r/maria.result:
  Added test for Bug#40311 Assert in MARIA_RECORD_POS during pushbuild 2 test
mysql-test/suite/maria/t/maria.test:
  Added test for Bug#40311 Assert in MARIA_RECORD_POS during pushbuild 2 test
mysys/thr_lock.c:
  Fixed wrong argument to (lock->get_status) when we had to wait for TL_WRITE_CONCURRENT_INSERT
sql/item_cmpfunc.cc:
  Item_equal::update_used_tables() didn't calculate const_item_cache properly, which later caused a wrong result for item->const_item()
sql/sql_base.cc:
  In debug mode, Initilize record buffer with unexpected data to catch usage of uninitialized memory
sql/sql_select.cc:
  Fixed indentation
  Added assert's to detect if join_read_const_table() was called under wrong assumptions.
  One assert() is disabled for now as Item_equal() doesn't behave as expected.
storage/maria/ha_maria.cc:
  Move calling to _ma_setup_live_state() to ma_state.c::_ma_block_get_status()
  This was needed as _ma_setup_live_state() needed to know if the table will be used concurrently or not
storage/maria/ma_blockrec.c:
  Fixed bug when removing a newly inserted record (in case of duplicate key).
  The bug caused a crash for rows with several blobs and the first blob was small enough to fit into the head page.
storage/maria/ma_dbug.c:
  Added mutex to protect the open table list during _ma_check_table_is_closed().
  Without the protection we could get a error in debug binaries during a call to _ma_check_table_is_closed()
storage/maria/ma_delete_table.c:
  Removed not used code
storage/maria/ma_rename.c:
  Removed not used code
storage/maria/ma_state.c:
  Fixed wrong test when finding right history_state to use
  Mark in tables->state_current.no_transid if we are using transid's or not.
  Don't change state_history if nothing changed (speed optimization that also simplifies logic)
  Reset state_history if we added/deleted or updated rows without versioning.
  More DBUG_ASSERT's and more DBUG
  Updated maria_versioning() to initialize environment before calling _ma_blok_get_status(). This was needed because of the new logic in _ma_block_get_status()
storage/maria/ma_state.h:
  Added flags to detect if table changed and/or if we changed table without versioning
storage/maria/ma_write.c:
  Simple cleanups (No logic changes)
storage/maria/trnman.c:
  Fixed wrong test in trnman_exists_active_transactions() if state is visible or not.
2008-12-22 02:17:37 +02:00
Guilhem Bichot
c9a29373e1 Fix for BUG#41159 "Maria: deadlock between checkpoint and maria_write() when extending data file".
No testcase (concurrency, tested by pushbuild2).

storage/maria/ha_maria.cc:
  a comment about what Sanja had discovered a while ago
storage/maria/ma_bitmap.c:
  guard against concurrent flush of bitmap by checkpoint: we must have close_lock here
storage/maria/ma_blockrec.c:
  comment fixed for new behaviour
storage/maria/ma_checkpoint.c:
  Release intern_lock before flushing bitmap, or it deadlocks with allocate_and_write_block_record()
  when that function needs to increase the data file's length (that function makes bitmap non flushable,
  then wants intern_lock to increase data_file_length).
  The checkpoint section which looks at the share's content (bitmap, state) needs to be protected from the possible
  my_free-ing done by a concurrent maria_close(); intern_lock is not enough as
  both maria_close() and checkpoint now have to release it in the middle.
  So the protection is done with close_lock. in_checkpoint is now protected by close_lock
  in places where it was protected by intern_lock.
storage/maria/ma_close.c:
  hold close_lock in maria_close() from start to end, to guard against checkpoint trying to flush
  bitmap while we have my_free'd its structures, for example. intern_lock was not enough as
  both maria_close() and checkpoint have to release it in the middle, to avoid deadlocks.
storage/maria/ma_open.c:
  initialize new mutex
storage/maria/ma_recovery.c:
  a comment about what Sanja had discovered a while ago
storage/maria/maria_def.h:
  comment.
  new mutex protecting the close of a MARIA_SHARE, from _start_ to _end_ of it.
2008-12-09 10:56:02 +01:00
Guilhem Bichot
91bc9cc9e6 Fix for BUG#41037 "Maria: recovery failure (pushbuild2)" (checkpoint bug).
mysql-test/suite/maria/r/maria-recovery3.result:
  result.
mysql-test/suite/maria/t/maria-recovery3-master.opt:
  usual recovery test options
mysql-test/suite/maria/t/maria-recovery3.test:
  Test for BUG#41037. Without the bugfix, the test would hang because Recovery would fail with "undo_key_insert got error 126": Recovery would believe INSERT of 2 is uncommitted, try to execute its UNDO_KEY_INSERT, fail to find the key to delete because DELETE deleted it. That failure of _ma_ck_real_delete() would mark table as corrupted (see
  in d_search()) which is error 126 (HA_ERR_CRASHED).
storage/maria/ma_blockrec.c:
  set trn->rec_lsn to LSN of commit record, when writing it.
storage/maria/ma_blockrec.h:
  new function
storage/maria/ma_commit.c:
  when committing or rolling back, rec_lsn should be LSN_IMPOSSIBLE: assertion is moved here
  from trnman_end_trn(), because now ma_commit() can set rec_lsn and so when we reach trnman_end_trn()
  it's not LSN_IMPOSSIBLE anymore.
  Adding debug possibility to pause between COMMIT record write and trnman_commit_trn(), to be
  able to fire checkpoint in between.
storage/maria/ma_loghandler.c:
  in-write hook for COMMIT records
storage/maria/ma_recovery.c:
  More debugging info in maria_recovery.trace, to see how the starting point of REDO phase is determined
storage/maria/trnman.c:
  assertion cannot be here anymore see ma_commit.c
2008-12-05 22:11:46 +01:00
Guilhem Bichot
8ecda6cd26 _ma_bitmap_unpin_all() needs to unpin not-locked pages which were pinned by other threads
in write_changed_bitmap(), and page cache forbids that. Here we make the page
cache more relaxed. Original patch by Sanja, simplified by me as limited to
not-locked. See comment of ma_bitmap.c.
With that, maria_stress.yy runs until hitting BUG 39665.

storage/maria/ma_bitmap.c:
  A thread which unpins bitmap pages in _ma_bitmap_unpin_all() sometimes
  hit an assertion in the page cache (info!=0 in remove_pin()) which states
  that you can unpin/unlock only what *you* have pinned/locked.
  Fixed by setting the new last parameter of pagecache_unlock_by_link()
  to TRUE in _ma_bitmap_unpin_all().
storage/maria/ma_blockrec.c:
  new prototype and splitting assertion in three (3rd one fires: BUG 39665)
storage/maria/ma_check.c:
  new prototype
storage/maria/ma_key_recover.c:
  new prototype
storage/maria/ma_loghandler.c:
  new prototype
storage/maria/ma_pagecache.c:
  Allow a thread to unpin, with pagecache_unlock_by_link(), a non-locked page pinned by others.
  This is a hack for _ma_bitmap_unpin_all() which needs to unpin pages which were
  pinned by other threads in write_changed_bitmap().
storage/maria/ma_pagecache.h:
  new prototype
storage/maria/ma_preload.c:
  new prototype
storage/maria/unittest/ma_pagecache_rwconsist.c:
  new prototype
storage/maria/unittest/ma_pagecache_single.c:
  new prototype
2008-10-14 17:18:14 +02:00
Guilhem Bichot
ed567bd2a9 Fix for BUG#39210 "Maria deadlock in _ma_bitmap_wait_or_flush". It was a thread
which nobody woke up (see comment of ma_bitmap.c). No testcase, this requires
multiple threads and is automatically tested at push time by maria_stress.yy (pushbuild2).

storage/maria/ma_bitmap.c:
  * _ma_bitmap_wait_or_flush() didn't publish that it was waiting for bitmap to not
  be over-allocated (i.e. didn't modify bitmap->flush_all_requested) so nobody
  (_ma_bitmap_flushable(), _ma_bitmap_release_unused()) knew it had to wake it up
  => it stalled (BUG#39210). In fact the wait in _ma_bitmap_wait_or_flush()
  is not needed, it's ok if this function sends the over-allocated bitmap to page
  cache and keeps pin on it (_ma_bitmap_unpin_all() will unpin it later, and
  the one who added _ma_bitmap_wait_or_flush() didn't know it). Function
  is thus deleted, as _ma_bitmap_flush() can do its job.
  * After fixing that, test runs longer and BUG 39665 happens, which looks like
  a separate page cache bug.
  * Smaller changes: _ma_bitmap_flush_all() called write_changed_bitmap() even
  though it might not be changed; added some DBUG calls in functions; split
  assertions.
  * In _ma_bitmap_release_unused(), it's more logical to test non_flushable_state
  than now_transactional to know if we have to decrement non_flushable
  (it's exactly per the definition of non_flushable_state).
storage/maria/ma_blockrec.c:
  _ma_bitmap_wait_or_flush() is not needed.
  ******
  new prototype and splitting assertion in three (3rd one fires: BUG 39665)
storage/maria/ma_blockrec.h:
  _ma_bitmap_wait_or_flush() is not needed.
2008-10-14 11:38:07 +02:00
Guilhem Bichot
ade71b2522 Fix for BUG#39697 "Maria: hang when failing to insert due to UNIQUE (seen in pushbuild2 too)"
It was a forgotten rw_unlock(), due to the deadlock detector feature (so bug was only in 5.1-maria, not
6.0-maria).

mysql-test/suite/maria/r/maria3.result:
  result, all fine
mysql-test/suite/maria/t/maria3.test:
  Test of BUG#39697: two scenarios (transactional tables, and non-transactional table but dynamic row format so still taking the rwlock) where the hang happened.
  t2 added by this test was masked by a temporary table created earlier in the test, which we forgot to drop.
storage/maria/ha_maria.cc:
  use new macro
storage/maria/ma_blockrec.c:
  use new macro
storage/maria/ma_commit.c:
  use new macro
storage/maria/ma_init.c:
  putting address of dummy_transaction_object in --debug trace can be useful
storage/maria/ma_open.c:
  use new macro
storage/maria/ma_write.c:
  if local_lock_tree is true, we have acquired keyinfo->root_lock so need to release it before "goto err".
  A pair of assertions so that our usage of TrIDs is kept sensible.
storage/maria/maria_def.h:
  A macro so that changes of MARIA_HA::trn can be tracked with --debug. It helped to understand in what cases,
  in maria_write(), we could have !(info->dup_key_trid == info->trn->trid) && !share->now_transactional
  (answer: ALTER TABLE adding UNIQUE index on transactional table).
2008-10-09 22:03:54 +02:00
Sergei Golubchik
4be86917fe merge 2008-08-28 20:52:23 +02:00
Sergei Golubchik
47a82ad552 Bug#38135 Assertion failed: save_errno, file .\ma_update.c, line 200
typo fixed.

mysql-test/r/maria.result:
  new test case
mysql-test/t/maria.test:
  new test case
sql/sql_select.cc:
  ctags friendly
storage/maria/ma_blockrec.c:
  typo fixed
2008-08-11 16:40:32 +02:00
Sergei Golubchik
8347290482 compiler warnings
trnman: remove old lockman code
trnman: replace trid_to_committed_trn hash with trid_to_trn

storage/maria/ma_blockrec.c:
  compiler warnings
storage/maria/ma_loghandler.c:
  compiler warnings
storage/maria/ma_write.c:
  compiler warnings
storage/maria/trnman.c:
  remove old lockman code
  replace trid_to_committed_trn hash with trid_to_trn
storage/maria/trnman.h:
  remove old lockman code
  replace trid_to_committed_trn hash with trid_to_trn
storage/maria/unittest/ma_test_loghandler-t.c:
  compiler warnings
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  compiler warnings
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  compiler warnings
2008-08-04 18:57:41 +02:00
Michael Widenius
7f02282404 Fixes for bug#37276:
- Fixes key corruption where pages wasn't marked that they contained transid.
- Fixed bug in block record that could create too small rows when transid was removed. This fixed some asserts() when testing block length

Added --abort-source-on-error to the mysql client. (Very helpfull when debugging wrong .sql files)

client/client_priv.h:
  Added enum for new option to mysql
client/mysql.cc:
  Added new option --abort-source-on-error to allow one to get 'source' to stop on error. This is 0 by default, to keep old behaviour.
  Print file name and line number when getting an error when doing source filename
sql/field.cc:
  Removed old dead code
sql/sql_class.cc:
  Removed old dead code
storage/maria/ma_blockrec.c:
  Added checking of min block length to check_directory()
  When creating new directory entry, set length to 0; This ensures that the assert checks() on block lengths works properly.
  Added more DBUG_ASSERT() and more calls to check_directory()
  In get_head_or_tail_page(), send in correct min_block_length. This is now safe as the length of new blocks are now 0
storage/maria/ma_delete.c:
  When moving key to parent page, mark page if key has transid
storage/maria/ma_write.c:
  Fixed bug where _ma_find_last_pos() didn't set int_key->flag.
  Simpilifed code by unrolling loop.
2008-07-09 16:09:30 +03:00
Michael Widenius
82d7938905 Bug#37276 maria crash on insert around the time check table is run
Fixed several (but not all) issues found by the test program:
- ASSERT on row_length in ma_blockrec.c::_ma_compact_block_page()
- Fixed bug when splitting node pages
- Fixed hang in 'closeing tables' (conflicting mutex order) by ensuring we first take trnman lock and then share->intern_lock

storage/maria/ma_blockrec.c:
  When compacting a row page when allocating space for a new row, the min length of a the new block may be temporarly smaller than 'min_block_length'.
storage/maria/ma_check.c:
  More DBUG output
storage/maria/ma_checkpoint.c:
  Call new function _ma_remove_not_visible_states_with_lock() to ensure we first take lock on trnman and then on share->intern_lock
  +
storage/maria/ma_close.c:
  Added comment
storage/maria/ma_open.c:
  Added comment
storage/maria/ma_search.c:
  Copy also node data; Caused bug when splitting node pages
storage/maria/ma_state.c:
  Added _ma_remove_not_visible_states_with_lock() to ensure we take locks in right order
storage/maria/ma_state.h:
  Added new prototype
storage/maria/trnman.c:
  Added trnman_lock() and trnman_unlock().
  Needed by _ma_remove_not_visible_states_with_lock() to get mutex in right order
storage/maria/trnman_public.h:
  Added new prototypes
2008-07-05 14:03:21 +03:00
Guilhem Bichot
2425763869 Fix for BUG#37288 "Maria - zerofill corrupts table". Testcase is running ma_test_recovery.pl on Windows.
storage/maria/ma_blockrec.c:
  comment
storage/maria/ma_check.c:
  When zerofilling the data file, _ma_compact_block_page() may increase free space in a
  page so bitmap page needs to be corrected.
2008-06-30 11:25:14 +02:00
Michael Widenius
52cb0c24a6 Added versioning of Maria index
Store max_trid in index file as state.create_trid. This is used to pack all transids in the index pages relative to max possible transid for file.
Enable versioning for transactional tables with index. Tables with an auto-increment key, rtree or fulltext keys are not versioned.
Changed info->lastkey to type MARIA_KEY. Removed info->lastkey_length as this is now part of info->lastkey
Renamed old info->lastkey to info->lastkey_buff
Use exact key lenghts for keys, not USE_WHOLE_KEY
For partial key searches, use SEARCH_PART_KEY
When searching to insert new key on page, use SEARCH_INSERT to mark that key has rowid

Changes done in a lot of files:
- Modified functions to use MARIA_KEY instead of key pointer and key length
- Use keyinfo->root_lock instead of share->key_root_lock[keynr]
- Simplify code by using local variable keyinfo instead if share->keyinfo[i]
- Added #fdef EXTERNAL_LOCKING around removed state elements
- HA_MAX_KEY_BUFF -> MARIA_MAX_KEY_BUFF (to reserve space for transid)
- Changed type of 'nextflag' to uint32 to ensure all SEARCH_xxx flags fits into it

.bzrignore:
  Added missing temporary directory
extra/Makefile.am:
  comp_err is now deleted on make distclean
include/maria.h:
  Added structure MARIA_KEY, which is used for intern key objects in Maria.
  Changed functions to take MARIA_KEY as an argument instead of pointer to packed key.
  Changed some functions that always return true or false to my_bool.
  Added virtual function make_key() to avoid if in _ma_make_key()
  Moved rw_lock_t for locking trees from share->key_root_lock to MARIA_KEYDEF. This makes usage of the locks simpler and faster
include/my_base.h:
  Added HA_RTREE_INDEX flag to mark rtree index. Used for easier checks in ma_check()
  Added SEARCH_INSERT to be used when inserting new keys
  Added SEARCH_PART_KEY for partial searches
  Added SEARCH_USER_KEY_HAS_TRANSID to be used when key we use for searching in btree has a TRANSID
  Added SEARCH_PAGE_KEY_HAS_TRANSID to be used when key we found in btree has a transid
include/my_handler.h:
  Make next_flag 32 bit to make sure we can handle all SEARCH_ bits
mysql-test/include/maria_empty_logs.inc:
  Read and restore current database; Don't assume we are using mysqltest.
  Don't log use databasename to log. Using this include should not cause any result changes.
mysql-test/r/maria-gis-rtree-dynamic.result:
  Updated results after adding some check table commands to help pinpoint errors
mysql-test/r/maria-mvcc.result:
  New tests
mysql-test/r/maria-purge.result:
  New result after adding removal of logs
mysql-test/r/maria-recovery-big.result:
  maria_empty_logs doesn't log 'use mysqltest' anymore
mysql-test/r/maria-recovery-bitmap.result:
  maria_empty_logs doesn't log 'use mysqltest' anymore
mysql-test/r/maria-recovery-rtree-ft.result:
  maria_empty_logs doesn't log 'use mysqltest' anymore
mysql-test/r/maria-recovery.result:
  maria_empty_logs doesn't log 'use mysqltest' anymore
mysql-test/r/maria.result:
  New tests
mysql-test/r/variables-big.result:
  Don't log id as it's not predictable
mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb_2.result:
  Updated results to new binlog results. (Test has not been run in a long time as it requires --big)
mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb_2-master.opt:
  Moved file to ndb replication test directory
mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb_2.test:
  Fixed wrong path to included tests
mysql-test/t/maria-gis-rtree-dynamic.test:
  Added some check table commands to help pinpoint errors
mysql-test/t/maria-mvcc.test:
  New tests
mysql-test/t/maria-purge.test:
  Remove logs to make test results predictable
mysql-test/t/maria.test:
  New tests for some possible problems
mysql-test/t/variables-big.test:
  Don't log id as it's not predictable
mysys/my_handler.c:
  Updated function comment to reflect old code
  Changed nextflag to be uint32 to ensure we can have flags > 16 bit
  Changed checking if we are in insert with NULL keys as next_flag can now include additional bits that have to be ignored.
  Added SEARCH_INSERT flag to be used when inserting new keys in btree. This flag tells us the that the keys includes row position and it's thus safe to remove SEARCH_FIND
  Added comparision of transid. This is only done if the keys actually have a transid, which is indicated by nextflag
mysys/my_lock.c:
  Fixed wrong test (Found by Guilhem)
scripts/Makefile.am:
  Ensure that test programs are deleted by make clean
sql/rpl_rli.cc:
  Moved assignment order to fix compiler warning
storage/heap/hp_write.c:
  Add SEARCH_INSERT to signal ha_key_cmp that we we should also compare rowid for keys
storage/maria/Makefile.am:
  Remove also maria log files when doing make distclean
storage/maria/ha_maria.cc:
  Use 'file->start_state' as default state for transactional tables without versioning
  At table unlock, set file->state to point to live state. (Needed for information schema to pick up right number of rows)
  In ha_maria::implicit_commit() move all locked (ie open) tables to new transaction. This is needed to ensure ha_maria->info doesn't point to a deleted history event.
  Disable concurrent inserts for insert ... select and table changes with subqueries if statement based replication as this would cause wrong results on slave
storage/maria/ma_blockrec.c:
  Updated comment
storage/maria/ma_check.c:
  Compact key pages (removes transid) when doing --zerofill
  Check that 'page_flag' on key pages contains KEYPAGE_FLAG_HAS_TRANSID if there is a single key on the page with a transid
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Use new interface to _ma_rec_pos(), _ma_dpointer(), _ma_ft_del(), ma_update_state_lsn()
  Removed not needed argument from get_record_for_key()
  Fixed that we check doesn't give errors for RTREE; We now treath these like SPATIAL
  Remove some SPATIAL specific code where the virtual functions can handle this in a general manner
  Use info->lastkey_buff instead of info->lastkey
  _ma_dpos() -> _ma_row_pos_from_key()
  _ma_make_key() -> keyinfo->make_key()
  _ma_print_key() -> _ma_print_keydata()
  _ma_move_key() -> ma_copy_copy()
  Add SEARCH_INSERT to signal ha_key_cmp that we we should also compare rowid for keys
  Ensure that data on page doesn't overwrite page checksum position
  Use DBUG_DUMP_KEY instead of DBUG_DUMP
  Use exact key lengths instead of USE_WHOLE_KEY to ha_key_cmp()
  Fixed check if rowid points outside of BLOCK_RECORD data file
  Use info->lastkey_buff instead of key on stack in some safe places
  Added #fdef EXTERNAL_LOCKING around removed state elements
storage/maria/ma_close.c:
  Use keyinfo->root_lock instead of share->key_root_lock[keynr]
storage/maria/ma_create.c:
  Removed assert that is already checked in maria_init()
  Force transactinal tables to be of type BLOCK_RECORD
  Fixed wrong usage of HA_PACK_RECORD (should be HA_OPTION_PACK_RECORD)
  Mark keys that uses HA_KEY_ALG_RTREE with HA_RTREE_INDEX for easier handling of these in ma_check
  Store max_trid in index file as state.create_trid. This is used to pack all transids in the index pages relative to max possible transid for file.
storage/maria/ma_dbug.c:
  Changed _ma_print_key() to use MARIA_KEY
storage/maria/ma_delete.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  info->lastkey2-> info->lastkey_buff2
  Added SEARCH_INSERT to signal ha_key_cmp that we we should also compare rowid for keys
  Use new interface for get_key(), _ma_get_last_key() and others
  _ma_dpos() -> ma_row_pos_from_key()
  Simplify setting of prev_key in del()
  Ensure that KEYPAGE_FLAG_HAS_TRANSID is set in page_flag if key page has transid
  Treath key pages that may have a transid as if keys would be of variable length
storage/maria/ma_delete_all.c:
  Reset history state if maria_delete_all_rows() are called
  Update parameters to _ma_update_state_lsns() call
storage/maria/ma_extra.c:
  Store and restore info->lastkey
storage/maria/ma_ft_boolean_search.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_ft_nlq_search.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Use lastkey_buff2 instead of info->lastkey+info->s->base.max_key_length (same thing)
storage/maria/ma_ft_update.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_ftdefs.h:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_fulltext.h:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_init.c:
  Check if blocksize is legal
  (Moved test here from ma_open())
storage/maria/ma_key.c:
  Added functions for storing/reading of transid 
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Moved _ma_sp_make_key() out of _ma_make_key() as we now use keyinfo->make_key to create keys
  Add transid to keys if table is versioned
  Added _ma_copy_key()
storage/maria/ma_key_recover.c:
  Add logging of page_flag (holds information if there are keys with transid on page)
  Changed DBUG_PRINT("info" -> DBUG_PRINT("redo" as the redo logging can be quite extensive
  Added lots of DBUG_PRINT()
  Added support for index page operations: KEY_OP_SET_PAGEFLAG and KEY_OP_COMPACT_PAGE
storage/maria/ma_key_recover.h:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_locking.c:
  Added new arguments to _ma_update_state_lsns_sub()
storage/maria/ma_loghandler.c:
  Fixed all logging of LSN to look similar in DBUG log
  Changed if (left != 0) to if (left) as the later is used also later in the code
storage/maria/ma_loghandler.h:
  Added new index page operations
storage/maria/ma_open.c:
  Removed allocated "state_dummy" and instead use share->state.common for transactional tables that are not versioned
  This is needed to not get double increments of state.records (one in ma_write.c and on when log is written)
  Changed info->lastkey to MARIA_KEY type
  Removed resetting of MARIA_HA variables that have 0 as default value (as info is zerofilled)
  Enable versioning for transactional tables with index. Tables with an auto-increment key, rtree or fulltext keys are not versioned.
  Check on open that state.create_trid is correct
  Extend share->base.max_key_length in case of transactional table so that it can hold transid
  Removed 4.0 compatible fulltext key mode as this is not relevant for Maria
  Removed old and wrong #ifdef ENABLE_WHEN_WE_HAVE_TRANS_ROW_ID code block
  Initialize all new virtual function pointers
  Removed storing of state->unique, state->process and store state->create_trid instead
storage/maria/ma_page.c:
  Added comment to describe key page structure
  Added functions to compact key page and log the compact operation
storage/maria/ma_range.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Use SEARCH_PART_KEY indicator instead of USE_WHOLE_KEY to detect if we are doing a part key search
  Added handling of pages with transid
storage/maria/ma_recovery.c:
  Don't assert if table we opened are not transactional. This may be a table which has been changed from transactional to not transactinal
  Added new arguments to _ma_update_state_lsns()
storage/maria/ma_rename.c:
  Added new arguments to _ma_update_state_lsns()
storage/maria/ma_rkey.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Don't use USE_WHOLE_KEY, use real length of key
  Use share->row_is_visible() to test if row is visible
  Moved search_flag == HA_READ_KEY_EXACT out of 'read-next-row' loop as this only need to be tested once
  Removed test if last_used_keyseg != 0 as this is always true
storage/maria/ma_rnext.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Simplify code by using local variable keyinfo instead if share->keyinfo[i]
  Use share->row_is_visible() to test if row is visible
storage/maria/ma_rnext_same.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  lastkey2 -> lastkey_buff2
storage/maria/ma_rprev.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Simplify code by using local variable keyinfo instead if share->keyinfo[i]
  Use share->row_is_visible() to test if row is visible
storage/maria/ma_rsame.c:
  Updated comment
  Simplify code by using local variable keyinfo instead if share->keyinfo[i]
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_rsamepos.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_rt_index.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Use better variable names
  Removed not needed casts
  _ma_dpos() -> _ma_row_pos_from_key()
  Use info->last_rtree_keypos to save position to key instead of info->int_keypos
  Simplify err: condition
  Changed return type for maria_rtree_insert() to my_bool as we are only intressed in ok/fail from this function
storage/maria/ma_rt_index.h:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_rt_key.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Simplify maria_rtree_add_key by combining idenitcal code and removing added_len
storage/maria/ma_rt_key.h:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_rt_mbr.c:
  Changed type of 'nextflag' to uint32
  Added 'to' argument to RT_PAGE_MBR_XXX functions to more clearly see which variables changes value
storage/maria/ma_rt_mbr.h:
  Changed type of 'nextflag' to uint32
storage/maria/ma_rt_split.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  key_length -> key_data_length to catch possible errors
storage/maria/ma_rt_test.c:
  Fixed wrong comment
  Reset recinfo to avoid valgrind varnings
  Fixed wrong argument to create_record() that caused test to fail
storage/maria/ma_search.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Added support of keys with optional trid
  Test for SEARCH_PART_KEY instead of USE_WHOLE_KEY to detect part key reads
  _ma_dpos() -> _ma_row_pos_from_key()
  If there may be keys with transid on the page, have _ma_bin_search() call _ma_seq_search()
  Add _ma_skip_xxx() functions to quickly step over keys (faster than calling get_key() in most cases as we don't have to copy key data)
  Combine similar code at end of _ma_get_binary_pack_key()
  Removed not used function _ma_move_key()
  In _ma_search_next() don't call _ma_search() if we aren't on a nod page.
  Update info->cur_row.trid with trid for found key
  
  
  
  Removed some not needed casts
  Added _ma_trid_from_key()
  Use MARIA_SHARE instead of MARIA_HA as arguments to _ma_rec_pos(), _ma_dpointer() and _ma_xxx_keypos_to_recpos() to make functions faster and smaller
storage/maria/ma_sort.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_sp_defs.h:
  _ma_sp_make_key() now fills in and returns (MARIA_KEY *) value
storage/maria/ma_sp_key.c:
  _ma_sp_make_key() now fills in and returns (MARIA_KEY *) value
  Don't test sizeof(double), test against 8 as we are using float8store()
  Use mi_float8store() instead of doing swap of value (same thing but faster)
storage/maria/ma_state.c:
  maria_versioning() now only calls _ma_block_get_status() if table supports versioning
  Added _ma_row_visible_xxx() functions for different occasions
  When emptying history, set info->state to point to the first history event.
storage/maria/ma_state.h:
  Added _ma_row_visible_xxx() prototypes
storage/maria/ma_static.c:
  Indentation changes
storage/maria/ma_statrec.c:
  Fixed arguments to _ma_dpointer() and _ma_rec_pos()
storage/maria/ma_test1.c:
  Call init_thr_lock() if we have versioning
storage/maria/ma_test2.c:
  Call init_thr_lock() if we have versioning
storage/maria/ma_unique.c:
  Modified functions to use MARIA_KEY
storage/maria/ma_update.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
storage/maria/ma_write.c:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Simplify code by using local variable keyinfo instead if share->keyinfo[i]
  In _ma_enlarge_root(), mark in page_flag if new key has transid
  _ma_dpos() -> _ma_row_pos_from_key()
  Changed return type of _ma_ck_write_tree() to my_bool as we are only testing if result is true or not
  Moved 'reversed' to outside block as area was used later
storage/maria/maria_chk.c:
  Added error if trying to sort with HA_BINARY_PACK_KEY
  Use new interface to get_key() and _ma_dpointer()
  _ma_dpos() -> _ma_row_pos_from_key()
storage/maria/maria_def.h:
  Modified functions to use MARIA_KEY instead of key pointer and key length
  Added 'common' to MARIA_SHARE->state for storing state for transactional tables without versioning
  Added create_trid to MARIA_SHARE
  Removed not used state variables 'process' and 'unique'
  Added defines for handling TRID's in index pages
  Changed to use MARIA_SHARE instead of MARIA_HA for some functions
  Added 'have_versioning' flag if table supports versioning
  Moved key_root_lock from MARIA_SHARE to MARIA_KEYDEF
  Changed last_key to be of type MARIA_KEY. Removed lastkey_length
  lastkey -> lastkey_buff, lastkey2 -> lastkey_buff2
  Added _ma_get_used_and_nod_with_flag() for faster access to page data when page_flag is read
  Added DBUG_DUMP_KEY for easier DBUG_DUMP of a key
  Changed 'nextflag' and assocaited variables to uint32
storage/maria/maria_ftdump.c:
  lastkey -> lastkey_buff
storage/maria/trnman.c:
  Fixed wrong initialization of min_read_from and max_commit_trid
  Added trnman_get_min_safe_trid()
storage/maria/unittest/ma_test_all-t:
  Added --start-from
storage/myisam/mi_check.c:
  Added SEARCH_INSERT, as ha_key_cmp() needs it when doing key comparision for inserting key on page in rowid order
storage/myisam/mi_delete.c:
  Added SEARCH_INSERT, as ha_key_cmp() needs it when doing key comparision for inserting key on page in rowid order
storage/myisam/mi_range.c:
  Updated comment
storage/myisam/mi_write.c:
  Added SEARCH_INSERT, as ha_key_cmp() needs it when doing key comparision for inserting key on page in rowid order
storage/myisam/rt_index.c:
  Fixed wrong parameter to rtree_get_req() which could cause crash
2008-06-26 08:18:28 +03:00
Michael Widenius
9977cae802 Fixed build errors/warnings caused by my last push
mysql-test/valgrind.supp:
  Added suppression for not relevant warning for memory leak in dlclose
storage/maria/ma_blockrec.c:
  Fixed build error on Windows
storage/maria/ma_delete_all.c:
  Fixed call to wrong function
storage/maria/ma_state.c:
  Added purcov suppression block
  Removed temporary debug printing
2008-06-02 10:27:41 +03:00
unknown
f83bd712ae Merge bk-internal.mysql.com:/home/bk/mysql-maria
into  mysql.com:/home/my/mysql-maria


mysql-test/r/maria.result:
  Auto merged
mysql-test/suite/ndb/r/ndb_auto_increment.result:
  Auto merged
mysql-test/t/maria.test:
  Auto merged
mysys/hash.c:
  Auto merged
mysys/thr_lock.c:
  Auto merged
sql/field.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster.h:
  Auto merged
sql/ha_partition.cc:
  Auto merged
sql/ha_partition.h:
  Auto merged
sql/handler.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/log_event_old.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/protocol.cc:
  Auto merged
sql/sql_load.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
storage/csv/ha_tina.cc:
  Auto merged
storage/federated/ha_federated.cc:
  Auto merged
storage/maria/Makefile.am:
  Auto merged
storage/maria/ma_check.c:
  Auto merged
storage/maria/ma_control_file.c:
  Auto merged
storage/maria/ma_delete_all.c:
  Auto merged
storage/maria/ma_dynrec.c:
  Auto merged
storage/maria/ma_init.c:
  Auto merged
storage/maria/ma_key_recover.c:
  Auto merged
storage/maria/ma_open.c:
  Auto merged
storage/maria/ma_page.c:
  Auto merged
storage/maria/ma_range.c:
  Auto merged
storage/maria/ma_recovery.c:
  Auto merged
storage/maria/ma_test1.c:
  Auto merged
storage/maria/maria_read_log.c:
  Auto merged
storage/maria/unittest/ma_test_all-t:
  Auto merged
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Auto merged
storage/maria/unittest/ma_test_recovery.pl:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/myisamdef.h:
  Auto merged
include/my_base.h:
  Manual merge where error code are kept same as in 5.1
mysys/my_handler.c:
  No changes
sql/item.cc:
  Manual merge
sql/sql_class.cc:
  Manual merge
sql/sql_insert.cc:
  Manual merge
storage/maria/ha_maria.cc:
  Manual merge
storage/maria/ma_blockrec.c:
  Manual merge
storage/maria/ma_delete.c:
  Manual merge
storage/maria/ma_write.c:
  Manual merge
2008-05-29 21:39:25 +03:00
unknown
5099033c26 WL#3138: Maria - fast "SELECT COUNT(*) FROM t;" and "CHECKSUM TABLE t"
Added argument to maria_end_bulk_insert() to know if the table will be deleted after the operation
Fixed wrong call to strmake
Don't call bulk insert in case of inserting only one row (speed optimization as starting/stopping bulk insert
Allow storing year 2155 in year field
When running with purify/valgrind avoid copying structures over themself
Added hook 'trnnam_end_trans_hook' that is called when transaction ends
Added trn->used_tables that is used to an entry for all tables used by transaction
Fixed that ndb doesn't crash on duplicate key error when start_bulk_insert/end_bulk_insert are not called


include/maria.h:
  Added argument to maria_end_bulk_insert() to know if the table will be deleted after the operation
include/my_tree.h:
  Added macro 'reset_free_element()' to be able to ignore calls to the external free function.
  Is used to optimize end-bulk-insert in case of failures, in which case we don't want write the remaining keys in the tree
mysql-test/install_test_db.sh:
  Upgrade to new mysql_install_db options
mysql-test/r/maria-mvcc.result:
  New tests
mysql-test/r/maria.result:
  New tests
mysql-test/suite/ndb/r/ndb_auto_increment.result:
  Fixed error message now when bulk insert is not always called
mysql-test/suite/ndb/t/ndb_auto_increment.test:
  Fixed error message now when bulk insert is not always called
mysql-test/t/maria-mvcc.test:
  Added testing of versioning of count(*)
mysql-test/t/maria-page-checksum.test:
  Added comment
mysql-test/t/maria.test:
  More tests
mysys/hash.c:
  Code style change
sql/field.cc:
  Allow storing year 2155 in year field
sql/ha_ndbcluster.cc:
  Added new argument to end_bulk_insert() to signal if the bulk insert should ignored
sql/ha_ndbcluster.h:
  Added new argument to end_bulk_insert() to signal if the bulk insert should ignored
sql/ha_partition.cc:
  Added new argument to end_bulk_insert() to signal if the bulk insert should ignored
sql/ha_partition.h:
  Added new argument to end_bulk_insert() to signal if the bulk insert should ignored
sql/handler.cc:
  Don't call get_dup_key() if there is no table object. This can happen if the handler generates a duplicate key error on commit
sql/handler.h:
  Added new argument to end_bulk_insert() to signal if the bulk insert should ignored (ie, the table will be deleted)
sql/item.cc:
  Style fix
  Removed compiler warning
sql/log_event.cc:
  Added new argument to ha_end_bulk_insert()
sql/log_event_old.cc:
  Added new argument to ha_end_bulk_insert()
sql/mysqld.cc:
  Removed compiler warning
sql/protocol.cc:
  Added DBUG
sql/sql_class.cc:
  Added DBUG
  Fixed wrong call to strmake
sql/sql_insert.cc:
  Don't call bulk insert in case of inserting only one row (speed optimization as starting/stopping bulk insert involves a lot of if's)
  Added new argument to ha_end_bulk_insert()
sql/sql_load.cc:
  Added new argument to ha_end_bulk_insert()
sql/sql_parse.cc:
  Style fixes
  Avoid goto in common senario
sql/sql_select.cc:
  When running with purify/valgrind avoid copying structures over themself.  This is not a real bug in itself, but it's a waste of cycles and causes valgrind warnings
sql/sql_select.h:
  Avoid copying structures over themself.  This is not a real bug in itself, but it's a waste of cycles and causes valgrind warnings
sql/sql_table.cc:
  Call HA_EXTRA_PREPARE_FOR_DROP if table created by ALTER TABLE is going to be dropped
  Added new argument to ha_end_bulk_insert()
storage/archive/ha_archive.cc:
  Added new argument to end_bulk_insert()
storage/archive/ha_archive.h:
  Added new argument to end_bulk_insert()
storage/federated/ha_federated.cc:
  Added new argument to end_bulk_insert()
storage/federated/ha_federated.h:
  Added new argument to end_bulk_insert()
storage/maria/Makefile.am:
  Added ma_state.c and ma_state.h
storage/maria/ha_maria.cc:
  Versioning of count(*) and checksum
  - share->state.state is now assumed to be correct, not handler->state
  - Call _ma_setup_live_state() in external lock to get count(*)/checksum versioning. In case of
    not versioned and not concurrent insertable table, file->s->state.state contains the correct state information
  
  Other things:
  - file->s -> share
  - Added DBUG_ASSERT() for unlikely case
  - Optimized end_bulk_insert() to not write anything if table is going to be deleted (as in failed alter table)
  - Indentation changes in external_lock becasue of removed 'goto' caused a big conflict even if very little was changed
storage/maria/ha_maria.h:
  New argument to end_bulk_insert()
storage/maria/ma_blockrec.c:
  Update for versioning of count(*) and checksum
  Keep share->state.state.data_file_length up to date (not info->state->data_file_length)
  Moved _ma_block_xxxx_status() and maria_versioning() functions to ma_state.c
storage/maria/ma_check.c:
  Update and use share->state.state instead of info->state
  info->s to share
  Update info->state at end of repair
  Call _ma_reset_state() to update share->state_history at end of repair
storage/maria/ma_checkpoint.c:
  Call _ma_remove_not_visible_states() on checkpoint to clean up not visible state history from tables
storage/maria/ma_close.c:
  Remember state history for running transaction even if table is closed
storage/maria/ma_commit.c:
  Ensure we always call trnman_commit_trn() even if other calls fails. If we don't do that, the translog and state structures will not be freed
storage/maria/ma_delete.c:
  Versioning of count(*) and checksum:
  - Always update info->state->checksum and info->state->records
storage/maria/ma_delete_all.c:
  Versioning of count(*) and checksum:
  - Ensure that share->state.state is updated, as here is where we store the primary information
storage/maria/ma_dynrec.c:
  Use lock_key_trees instead of concurrent_insert to check if trees should be locked.
  This allows us to lock trees both for concurrent_insert and for index versioning.
storage/maria/ma_extra.c:
  Versioning of count(*) and checksum:
  - Use share->state.state instead of info->state
  - share->concurrent_insert -> share->non_transactional_concurrent_insert
  - Don't update share->state.state from info->state if transactional table
  
  Optimization:
  - Don't flush io_cache or bitmap if we are using FLUSH_IGNORE_CHANGED
storage/maria/ma_info.c:
  Get most state information from current state
storage/maria/ma_init.c:
  Add hash table and free function to store states for closed tables
  Install hook for transaction commit/rollback to update history state
storage/maria/ma_key_recover.c:
  Versioning of count(*) and checksum:
  - Use share->state.state instead of info->state
storage/maria/ma_locking.c:
  Versioning of count(*) and checksum:
  - Call virtual functions (if exists) to restore/update status
  - Move _ma_xxx_status() functions to ma_state.c
  
  info->s -> share
storage/maria/ma_open.c:
  Versioning of count(*) and checksum:
  - For not transactional tables, set info->state to point to new allocated state structure.
  - Initialize new info->state_start variable that points to state at start of transaction
  - Copy old history states from hash table (maria_stored_states) first time the table is opened
  - Split flag share->concurrent_insert to non_transactional_concurrent_insert & lock_key_tree
  - For now, only enable versioning of tables without keys (to be fixed in soon!)
  - Added new virtual function to restore status in maria_lock_database)
  
  More DBUG
storage/maria/ma_page.c:
  Versioning of count(*) and checksum:
  - Use share->state.state instead of info->state
  - Modify share->state.state.key_file_length under share->intern_lock
storage/maria/ma_range.c:
  Versioning of count(*) and checksum:
  - Lock trees based on share->lock_key_trees
  
  info->s -> share
storage/maria/ma_recovery.c:
  Versioning of count(*) and checksum:
  - Use share->state.state instead of info->state
  - Update state information on close and when reenabling logging
storage/maria/ma_rkey.c:
  Versioning of count(*) and checksum:
  - Lock trees based on share->lock_key_trees
storage/maria/ma_rnext.c:
  Versioning of count(*) and checksum:
  - Lock trees based on share->lock_key_trees
storage/maria/ma_rnext_same.c:
  Versioning of count(*) and checksum:
  - Lock trees based on share->lock_key_trees
  - Only skip rows based on file length if non_transactional_concurrent_insert is set
storage/maria/ma_rprev.c:
  Versioning of count(*) and checksum:
  - Lock trees based on share->lock_key_trees
storage/maria/ma_rsame.c:
  Versioning of count(*) and checksum:
  - Lock trees based on share->lock_key_trees
storage/maria/ma_sort.c:
  Use share->state.state instead of info->state
  Fixed indentation
storage/maria/ma_static.c:
  Added maria_stored_state
storage/maria/ma_update.c:
  Versioning of count(*) and checksum:
  - Always update info->state->checksum and info->state->records
  - Remove optimization for index file update as it doesn't work for transactional tables
storage/maria/ma_write.c:
  Versioning of count(*) and checksum:
  - Always update info->state->checksum and info->state->records
storage/maria/maria_def.h:
  Move MARIA_STATUS_INFO to ma_state.h
  
  Changes to MARIA_SHARE:
  - Added state_history to store count(*)/checksum states
  - Added in_trans as counter if table is used by running transactions
  - Split concurrent_insert into lock_key_trees and on_transactional_concurrent_insert.
  - Added virtual function lock_restore_status
  
  Changes to MARIA_HA:
  - save_state -> state_save
  - Added state_start to store state at start of transaction
storage/maria/maria_pack.c:
  Versioning of count(*) and checksum:
  - Use share->state.state instead of info->state
  
  Indentation fixes
storage/maria/trnman.c:
  Added hook 'trnnam_end_trans_hook' that is called when transaction ends
  Added trn->used_tables that is used to an entry for all tables used by transaction
  More DBUG
  Changed return type of trnman_end_trn() to my_bool
  Added trnman_get_min_trid() to get minimum trid in use.
  Added trnman_exists_active_transactions() to check if there exist a running transaction started between two commit id
storage/maria/trnman.h:
  Added 'used_tables'
  Moved all pointers into same groups to get better memory alignment
storage/maria/trnman_public.h:
  Added prototypes for new functions and variables
  Chagned return type of trnman_end_trn() to my_bool
storage/myisam/ha_myisam.cc:
  Added argument to end_bulk_insert() if operation should be aborted
storage/myisam/ha_myisam.h:
  Added argument to end_bulk_insert() if operation should be aborted
storage/maria/ma_state.c:
  Functions to handle state of count(*) and checksum
storage/maria/ma_state.h:
  Structures and declarations to handle state of count(*) and checksum
2008-05-29 18:33:33 +03:00
unknown
c9a825810d WL#3072 - Maria Recovery
Recovery of R-tree and fulltext indices.
Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using
repair-with-keycache method".
Fix for bug (see ma_rt_index.c) where we could have a wrong
page_link pointer causing wrong memory access during some R-tree
index insert/delete.
Making ma_rt_test work again (it had been neglected over time) and
adding options (record type etc) to prepare it for integration into
ma_test_all-t (but there is BUG#36321 about "ma_rt_test -M" crash)


mysql-test/r/maria.result:
  correct result
mysql-test/t/maria.test:
  now we get no error
storage/maria/ma_blockrec.c:
  delete_dir_entry() and delete_head_or_tail() don't use info->keyread_buff.
  ma_get_length() does not change **packet, marking it with 'const' to
  remove some casts in callers of this function. The
  (const uchar**)&header casts will be removed when Monty changes 'header'
  to const uchar*.
  _ma_apply_redo_purge_row_head_or_tail() sets 'buff' from pagecache_read()
  so its initialization was superfluous.
storage/maria/ma_check.c:
  Fix for BUG#35551 "Maria: crash in REPAIR TABLE/ENABLE KEYS if using repair-with-keycache method"
  (see comment in code)
storage/maria/ma_create.c:
  FULLTEXT and SPATIAL indices have logging now, they are recoverable.
storage/maria/ma_delete.c:
  Logging done by _ma_ck_delete() is moved to a function
  (_ma_write_undo_key_delete()), for reusal by R-tree logging.
  _ma_log_delete() is made non-static for same
  reason, and some of its parameters are made pointers to const.
  Removed wrong comment ("Note that for delete key" etc, contradicted by
  code and comment "Log also position to row" a few lines above)
storage/maria/ma_ft_update.c:
  unneeded cast, comment for future
storage/maria/ma_key_recover.c:
  Comment about possible deadlock.
  Write bad page to DBUG trace if KEY_OP_CHECK founds bad CRC.
  Support operation KEY_OP_MULTI_COPY.
  When we execute, in UNDO phase, UNDO_KEY_DELETE|INSERT, we must call
  the proper key insertion|deletion depending on if this is R-tree
  or B-tree.
  Explanation of of _ma_[un]lock_key_del() work, maybe useful for
  mortals like me.
storage/maria/ma_key_recover.h:
  change of prototypes
storage/maria/ma_loghandler.h:
  New operation which can be stored in REDO_INDEX log records: KEY_OP_MULTI_COPY
storage/maria/ma_page.c:
  Comments
storage/maria/ma_pagecache.c:
  typo
storage/maria/ma_rt_index.c:
  Fix for bug: the page_link pointer in maria_rtree_insert_req()
  could be wrong when we set its 'changed' member; for the solution
  see ma_key_recover.h. It is needed only in cases when we manipulate
  several pages.
  Logging of changes done to pages by key insert/delete.
  maria_rtree_delete()'s main work is moved to a new function
  maria_rtree_real_delete(), which is used by maria_rtree_delete()
  and by applying of UNDO_KEY_INSERT.
storage/maria/ma_rt_index.h:
  new prototypes and macros for ma_rt_index.c
storage/maria/ma_rt_key.c:
  Logging of maria_rtree_add_key() and maria_rtree_delete_key().
  When inserting, split is necessary if there is not enough room for key:
  take checksum's occupied space in this calculation.
storage/maria/ma_rt_key.h:
  new prototypes (those functions need to know the page's id
  because they do logging)
storage/maria/ma_rt_mbr.c:
  Comments about what the functions change.
storage/maria/ma_rt_split.c:
  maria_rtree_split_page() needs to know the page's id, because
  it does logging.
  Logging of what a split operation does to the split page (see
  comment of _ma_log_rt_split(): moves of keys inside the page,
  sometimes insertion of the new key, and shrinking of the page)
  and to the new page (receives some keys from split page, and
  sometimes the new key).
storage/maria/ma_rt_test.c:
  ma_rt_test had been forgotten when maria_rkey() was changed some months ago
  (0->HA_WHOLE_KEY change), and when calls to maria_rnd(,,HA_OFFSET_ERROR)
  were rewritten to maria_scan() calls (which implies maria_scan_init()).
  The 'max_i' change is to adapt to the fact that maria_scan() does
  not return deleted records for BLOCK_RECORD but does so for other formats;
  the initial code assumed a certain number of deleted records would be
  returned, we change it to rather count only non-deleted ones.
  We also add more features to this test, like ma_test1 (the plan
  is to run ma_rt_test in ma_test_all-t):
  options to choose records' format, table checksum, transactions,
  checkpoints, end at specific stages, abort without committing,
  and debug trace.
storage/maria/ma_test1.c:
  MY_INIT() does my_init().
storage/maria/ma_write.c:
  Logging done by _ma_ck_write_btree_with_log() is moved to a function
  (_ma_write_undo_key_insert()), for reusal by R-tree logging.
  _ma_log_new() and _ma_log_change() are made non-static for same
  reason. Some parameters of logging functions are made pointers to const.
  If EXTRA_DEBUG_KEY_CHANGES, we now log CRC in _ma_log_change() too
  (better checks, bigger record).
storage/maria/maria_read_log.c:
  Program takes no arguments, bail out if any, instead of silently discarding them
storage/myisam/rt_test.c:
  rt_test had been forgotten when mi_rkey() was changed some months ago
  (0->HA_WHOLE_KEY change).
  The 'max_i' change is to make it symmetric with ma_rt_test.c
mysql-test/r/maria-gis-rtree-dynamic.result:
  correct result
mysql-test/r/maria-gis-rtree-trans.result:
  correct result
mysql-test/r/maria-recovery-rtree-ft.result:
  almost correct result (hitting BUG# in the end)
mysql-test/t/maria-gis-rtree-dynamic.test:
  test R-tree & dynamic row format
mysql-test/t/maria-gis-rtree-trans.test:
  Test R-tree and page row format and transactional
mysql-test/t/maria-recovery-rtree-ft-master.opt:
  usual options for recovery testing
mysql-test/t/maria-recovery-rtree-ft.test:
  test of recovery of R-tree and fulltext indices.
2008-04-24 17:22:51 +02:00