Commit graph

43 commits

Author SHA1 Message Date
Monty
3ce14a66ef Fixed bug in lock tables + alter table with Aria tables.
MDEV-18451 Server crashes in maria_create_trn_for_mysql
upon ALTER TABLE

Problem was that when table was locked many times, not all
instances where removed from the transaction by
_ma_remove_table_from_trnman()
2019-10-16 18:40:31 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Vicențiu Ciorbaru
f177f125d4 Merge branch '5.5' into 10.1 2019-05-11 19:15:57 +03:00
Michal Schorm
17b4f99928 Update FSF address
This commit is based on the work of Michal Schorm, rebased on the
earliest MariaDB version.

Th command line used to generate this diff was:

find ./ -type f \
  -exec sed -i -e 's/Foundation, Inc., 59 Temple Place, Suite 330, Boston, /Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, /g' {} \; \
  -exec sed -i -e 's/Foundation, Inc. 59 Temple Place.* Suite 330, Boston, /Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, /g' {} \; \
  -exec sed -i -e 's/MA.*.....-1307.*USA/MA 02110-1335 USA/g' {} \; \
  -exec sed -i -e 's/Foundation, Inc., 59 Temple/Foundation, Inc., 51 Franklin/g' {} \; \
  -exec sed -i -e 's/Place, Suite 330, Boston, MA.*02111-1307.*USA/Street, Fifth Floor, Boston, MA 02110-1335 USA/g' {} \; \
  -exec sed -i -e 's/MA.*.....-1307/MA 02110-1335/g' {} \;
2019-05-10 20:52:00 +03:00
Monty
494c981d23 Merge remote-tracking branch 'origin/10.1' into 10.2 2018-05-24 18:57:52 +03:00
Monty
e744c687ca Merge remote-tracking branch 'origin/10.0' into 10.1 2018-05-24 11:08:02 +03:00
Monty
2f3779d31c Fixes for Aria transaction handling with lock tables
MDEV-10130 Assertion `share->in_trans == 0' failed in storage/maria/ma_close.c
MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt

The problem was that maria_handler->trn was not properly reset
at commit/rollback and ha_maria::exernal_lock() could get confused
because.

There was some old code in ha_maria::implicit_commit() that tried
to take care of this, but it was not bullet proof.

Fixed by adding list of all tables that is part of the maria transaction to
TRN.

A nice side effect was of the fix is that loops in
ha_maria::implict_commit() got to be much simpler.

Other things:
- Fixed a bug in mysql_admin_table() where argument open_for_modify
  was wrongly reset for the next table in the chain
- rollback admin command also in case of fatal error.
- Split _ma_set_trn_for_table() to three version to simplify code
  and debugging.
- Several new asserts to detect the original problem (that file was
  not properly removed from trn before calling ma_close())
2018-05-22 23:05:48 +03:00
Sergei Golubchik
4771ae4b22 Merge branch 'github/10.1' into 10.2 2018-02-06 14:50:50 +01:00
Sergei Golubchik
d4df7bc9b1 Merge branch 'github/10.0' into 10.1 2018-02-02 10:09:44 +01:00
Monty
1f18bd630a MDEV-8200 aria bug with insert select and lock tables
This bug happens when locking the same Aria "transactional" table
(page format) more then once with LOCK TABLES and inserting into one
of them with INSERT ... SELECT when the table is empty.

Fixed by ensuring we don't use fast bulk insert if table is opened
twice with LOCK TABLES (as this changes table->s->state)

Code changes:
- Added use_count to MARIA_USED_TABLES to be able to check if
  table is opened twice for a statement/lock table
- Don't clear history or reset info->start_state if we
  don't have versioning. One reason for the bug was
  was that info->start_state was set to point to different
  states for the two tables.  If there is no versioning
  info->start_state should always point to info->s->state.common.

Other things:
- Fixed also some typos that was noticed while scanning the code
- More DBUG_PRINT
2018-01-11 16:39:29 +02:00
Vladislav Vaintroub
eba44874ca MDEV-13844 : Fix Windows warnings. Fix DBUG_PRINT.
- Fix win64 pointer truncation warnings
(usually coming from misusing 0x%lx and long cast in DBUG)

- Also fix printf-format warnings

Make the above mentioned warnings fatal.

- fix pthread_join on Windows to set return value.
2017-09-28 17:20:46 +00:00
Monty
dd8474b1dc Added tmp_disk_table_size to limit size of Aria temp tables in tmpdir
- Added variable tmp_disk_table_size
- Added variable tmp_memory_table_size as an alias for tmp_table_size
- Changed internal variable tmp_table_size to tmp_memory_table_size
- create_info.data_file_length is now set with tmp_disk_table_size
- Fixed that Aria doesn't reset max_data_file_length for internal tables
- Added status flag if table is full so that we can detect this on next insert.
  This ensures that the table is always 'correct', but we get the error one
  row after the row that grow the table too big.
- Removed some mutex lock for internal temporary tables
2017-06-30 22:31:37 +03:00
iangilfillan
f0ec34002a Correct FSF address 2017-03-10 18:21:29 +01:00
Michael Widenius
5364315229 Fix for MDEV-6493: Assertion `table->file->stats.records > 0 || error' failure, or 'Invalid write' valgrind warnings, or crash on scenario with Aria table, view, LOCK TABLES
This bug only happens in case of paritioned tables used in LOCK TABLES and implicit_commit() was called
(as part of trying to execute a CREATE TABLE withing lock tables)

The problem was that Aria could not move the tables from one transaction to the new one, as thd->open_tables contained
a partitioned tables and not an Aria table.

Fix:
- Store a list of all open tables that are part of a share in share->open_tables
- In maria::implict_commit() use transaction->used_tables & share->open_tables to find out which tables
  was part of the current transaction instead of using thd->open_tables, which may contain partitioned tables.


mysql-test/suite/maria/maria_partition.result:
  Added test case
mysql-test/suite/maria/maria_partition.test:
  Added test case
storage/maria/ha_maria.cc:
  Use trn->used tables and share->open_tables to find out which tables was part of the current transaction instead of using thd->open_tables.
storage/maria/ma_close.c:
  Remove closed table from share->open_list
storage/maria/ma_open.c:
  Add table to share->open_list
storage/maria/ma_state.c:
  Added comment
storage/maria/maria_def.h:
  Added share->open_list, a list of all tables that is using this share.
2014-07-30 13:27:52 +03:00
Michael Widenius
3bd6e4b8ee MDEV-3999: Valgrind errors 'invalid write' or assorted server crashes on concurrent flow with partitioned Aria tables
MDEV-3989: Server crashes on import from MariaDB mysqldump export with partitioned Aria table.

Problem was that bulk insert in aria was not properly protected against concurrent selects.


storage/maria/ha_maria.cc:
  Move settings of file->state to _ma_block_start_trans() to ensure that lock_key_trees is not changed by a concurrent bulk_insert.
storage/maria/ma_check.c:
  Added DBUG_ASSERT()
storage/maria/ma_open.c:
  Set start_trans to ma_start_trans for default behaviour.
storage/maria/ma_pagecrc.c:
  Removed test for 'non_transactional' as a now_transactinal could be reset while a flush was happening.
storage/maria/ma_state.c:
  Moved setting of info->state from external_lock to start_trans to protect against concurrent running bulk inserts.
  This works as the other threads will wait in thr_lock() until bulk_insert is done and keys are re-generated.
storage/maria/ma_state.h:
  Added _ma_start_trans()
2013-05-12 11:29:16 +03:00
Michael Widenius
690d8cc6ba Fixed lp:947474 "Assertion `table->file->stats.records > 0 || error' failed in join_read_const_table on concurrent SELECT and ALTER, constant Aria table"
Remove Aria state history for drop/rename

mysql-test/suite/maria/r/maria-recovery2.result:
  Updated old (wrong) test result
sql/handler.cc:
  Fixed wrong argument to implict_commit
storage/maria/ha_maria.cc:
  Ensure that we don't use file->trn if THD_TRN is 0. (This means that implict_commit() has been called and the trn object is not ours anymore)
storage/maria/ma_extra.c:
  Remove Aria state history for drop/rename
storage/maria/ma_rename.c:
  Remove Aria state history for rename
storage/maria/ma_state.c:
  More DBUG_PRINT
2012-03-20 16:04:50 +02:00
Sergei Golubchik
a844635637 use PSI wrappers in aria and other non-MySQL code 2011-07-13 21:10:18 +02:00
Sergei Golubchik
0accbd0364 lots of post-merge changes 2011-04-25 17:22:25 +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
0d3039d49d This patch fixes LP#613408 Memory corruption with (M)aria storage engine and virtual columns in MariaDB 5.2
Fixed compiler warnings
Disabled some tests that doesn't work on windows (uses shell tools or strange characters)



client/mysqlshow.c:
  Fixed compiler warnings
client/mysqlslap.c:
  Fixed compiler warnings
mysql-test/mysql-test-run.pl:
  Use an error file instead of /dev/null
  (Fixes problem on Windows and the output may be usefull)
mysql-test/suite/maria/r/maria.result:
  Test case for bug LP#613408 (not complete)
mysql-test/suite/maria/t/maria.test:
  Test case for bug LP#613408 (not complete)
mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_log_slow_slave_statements.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_slow_query_log-long_query_time.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test:
  This test doesn't work one windows (needs shell tools)
mysql-test/t/ctype_filesystem.test:
  This test doesn't work one windows (problem with character sets)
mysql-test/t/events_time_zone.test:
  Use longer times to get predictable tests
mysql-test/t/show_check-master.opt:
  set long query time to get more predictable tests
storage/maria/ma_check.c:
  Restore info->s->lock_key_trees after repair.
  Disable logging to temp tables for all repair cases (safety fix)
storage/maria/ma_state.c:
  Ensurethat info->state_start doesn't point to freed memory. (Could happen after running an internal repair to fast create indexes)
storage/maria/trnman.c:
  Added longer comment
2010-08-07 17:42:30 +03:00
Michael Widenius
cfbee9359c Fixed compiler warnings
sql/log_event.cc:
  Fixed compiler warning on windows
storage/maria/ma_state.c:
  Fixed compiler warning
storage/maria/maria_chk.c:
  Fixed compiler warning
storage/myisam/mi_dynrec.c:
  Fixed compiler warning
support-files/compiler_warnings.supp:
  Fixed suppression rule
2010-06-16 01:00:51 +03:00
Michael Widenius
ec281a3c34 Fixed some bugs in the Maria storage engine
- Changed default recovery mode from OFF to NORMAL to get automatic repair of not properly closed tables.
- Fixed a rase condition when two threads calls external_lock and thr_lock() in different order. When this happend the transaction that called external lock first
  and thr_lock() last did not see see the rows from the other transaction, even if if it had to wait in thr_lock() for other to complete.
- Fixed that one can run maria_chk on an automatcally recovered tables without warnings about too small transaction id
- Don't give warning that crashed table could not be repaired if repair was disabled (and thus not run)
- Fixed a error result from flush_key_cache() which caused a DBUG_ASSERT() when one was using concurrent reads on non transactional tables that was updated.

client/mysqldump.c:
  Add "" around error message to make it more readable
client/mysqltest.cc:
  Free environment variables
mysql-test/r/mysqldump.result:
  Updated results
mysql-test/r/openssl_1.result:
  Updated results
mysql-test/suite/maria/r/maria-recover.result:
  Updated results
mysql-test/suite/maria/r/maria3.result:
  Updated results
mysql-test/suite/maria/t/maria3.test:
  Added more test of temporary tables
storage/maria/ha_maria.cc:
  Changed default recovery mode from OFF to NORMAL to get automatic repair of not properly closed tables.
  Start transaction in ma_block_get_status() instead of in ha_maria::external_lock().
  - This fixes a rase condition when two threads calls external lock and thr_lock() in different order. When this happend the transaction that called external lock first and thr_lock() last did not see see the rows from the other transaction, even if if it had to wait in thr_lock() for other to complete.
  Store latest transaction id in controll file if recovery was done.
  - This allows one to run maria_chk on an automatcally recovered tables without warnings about too small transaction id
storage/maria/ha_maria.h:
  Don't give warning that crashed table could not be repaired if repair was disabled (and thus not run)
storage/maria/ma_blockrec.h:
  Added new function "_ma_block_get_status_no_versioning()"
storage/maria/ma_init.c:
  Added hook to create trn in ma_block_get_status() if we are using MariaDB
storage/maria/ma_open.c:
  Ensure we call _ma_block_get_status_no_versioning() for transactional tables without versioning (like tables with fulltext)
storage/maria/ma_pagecache.c:
  Allow one to flush blocks that are pinned for read.
  This fixed a error result from flush_key_cache() which caused a DBUG_ASSERT() when one was using concurrent reads on non transactional tables that was updated.
storage/maria/ma_recovery.c:
  Set maria_recovery_changed_data to 1 if recover changed something.
  Set max_trid_in_control_file to max found trn if we found a bigger trn.
  The allows will ensure that the control file is up to date after recovery which allows one to run maria_chk on the tables without warnings about too big trn
storage/maria/ma_state.c:
  Call maria_create_trn_hook() in _ma_setup_live_state() instead of ha_maria::external_lock()
  This ensures that 'state' and trn are in sync and thus fixes the race condition mentioned for ha_maria.cc
storage/maria/ma_static.c:
  Added maria_create_trn_hook() and maria_recovery_changed_data
storage/maria/maria_def.h:
  Added MARIA_HANDLER->external_ptr, which is used to hold MariaDB thd.
  Added some new external variables
  Removed reference to non existing function: maria_concurrent_inserts()
2010-06-14 01:13:32 +03:00
Michael Widenius
d13c54351d Remove compiler warnings (Including some warnings from -Wstrict-aliasing)
Don't use static link by default (in compile-pentium) as some new systems doesn't have all static libraries available
Change type for functions in plugin.h:str_mysql_ftparser_param() to const unsigned char and string lengths to size_t.
One effect of the above change is that one needs to include mysql_global.h or define size_t before including plugin.h
This fixes a case where mysql_client_test failed with newer gcc that enables strict-aliasing by default


BUILD/compile-pentium:
  Don't use static link by default as some new systems doesn't have all static libraries available
client/mysql_upgrade.c:
  Remove not used variable
cmd-line-utils/readline/config_readline.h:
  Define some constants to get rid of compiler warnings on Linux
cmd-line-utils/readline/display.c:
  Get rid of compiler warnings
cmd-line-utils/readline/history.c:
  Got rid of compiler warnings:
  - Defining some strings as const
  - Added cast
cmd-line-utils/readline/rlmbutil.h:
  Added cast to get rid of compiler warnings
cmd-line-utils/readline/text.c:
  Remove not needed initialization to get rid of compiler warnings
cmd-line-utils/readline/xmalloc.c:
  Changed types to 'const char* to get rid of compiler warnings
configure.in:
  Ensure that we use MariaDB as suffix
include/mysql/plugin.h:
  Changed types to 'const unsigned char* to get rid of compiler warnings (in other parts of the code)
  Change length for not \0 terminated string to size_t
include/mysql/plugin.h.pp:
  Update related to plugin.h
libmysql/libmysql.c:
  Fixed bug that caused core dump with newer gcc when strict aliasing is not turned off
mysql-test/t/information_schema.test:
  Test is depending on innodb
mysql-test/t/not_partition.test:
  Fixed wrong directory name
  (Not noticed before as we don't ususally run this test)
mysys/lf_hash.c:
  Got rid of compiler warnings from -Wstrict-aliasing
mysys/my_redel.c:
  Removed not used variable
regex/engine.c:
  Changed types to 'const char* to get rid of compiler warnings
regex/engine.ih:
  Changed types to 'const char* to get rid of compiler warnings
sql/sp_head.cc:
  Got rid of compiler warning from -Wstrict-aliasing
sql/sql_base.cc:
  Got rid of compiler warnings from -Wstrict-aliasing
  (The original code was probably wrong as nj_col->table_field was
sql/sql_builtin.cc.in:
  plugin.h needs to have size_t defined
sql/sql_parse.cc:
  Remove used variable
sql/sql_select.cc:
  Got rid of compiler warnings from -Wstrict-aliasing
sql/sql_show.cc:
  Added #ifdef to get rid of compiler warning when not using partition engine
sql/table.cc:
  Got rid of compiler warning from -Wstrict-aliasing
storage/maria/ha_maria.cc:
  Got rid of compiler warnings from -Wstrict-aliasing:
  - Use the thd_killed() API function
storage/maria/lockman.c:
  Got rid of compiler warnings from -Wstrict-aliasing
storage/maria/ma_check.c:
  Got rid of compiler warnings from -Wstrict-aliasing
  Change to use new version of _ma_killed_ptr; Don't call it as often as before
storage/maria/ma_check_standalone.h:
  Update to compatible _ma_killed_ptr() from ha_maria.cc
storage/maria/ma_ft_boolean_search.c:
  Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts)
storage/maria/ma_ft_nlq_search.c:
  Got rid of compiler warnings from -Wstrict-aliasing
  Ensure that 'subkeys' is 32 bit
storage/maria/ma_ft_parser.c:
  Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts)
storage/maria/ma_ftdefs.h:
  Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts)
storage/maria/ma_sort.c:
  Change to use new version of _ma_killed_ptr; Don't call it as often as before
storage/maria/ma_state.c:
  Got rid of compiler warnings from -Wstrict-aliasing
storage/maria/maria_def.h:
  Redefine ma_killed_ptr()
storage/maria/maria_ftdump.c:
  Got rid of compiler warnings from -Wstrict-aliasing
storage/maria/trnman.c:
  Got rid of compiler warnings from -Wstrict-aliasing
storage/myisam/ft_boolean_search.c:
  Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts)
storage/myisam/ft_nlq_search.c:
  Got rid of compiler warnings from -Wstrict-aliasing
storage/myisam/ft_parser.c:
  Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts)
storage/myisam/ft_stopwords.c:
  Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts)
storage/myisam/ftdefs.h:
  Changed pointers from char -> const char* and length to size_t (to get rid of compiler warnings and casts)
storage/myisam/ha_myisam.cc:
  Got rid of compiler warnings from -Wstrict-aliasing:
  - Use the thd_killed() API function
storage/myisam/mi_check.c:
  Use new killed_ptr() function
storage/myisam/myisam_ftdump.c:
  Got rid of compiler warnings from -Wstrict-aliasing
storage/myisam/myisamchk.c:
  Update to compatible killed_ptr() from ha_myisam.cc
storage/myisam/myisamdef.h:
  Redefine killed_ptr()
storage/myisam/myisamlog.c:
  Got rid of compiler warnings from -Wstrict-aliasing
storage/myisam/sort.c:
  Change to use new version of killed_ptr; Don't call it as often as before
storage/xtradb/fil/fil0fil.c:
  Fixedc ompiler warning
storage/xtradb/trx/trx0i_s.c:
  Include mysql_plugin.h later to ensure that size_t is defined
2009-11-30 01:08:56 +02:00
unknown
0c0e1f2e35 BUG#39249 Maria:query cache returns out of date results
BUG#41098 Query Cache returns wrong result with concurent insert

BUILD/SETUP.sh:
  test build without query cache setup
BUILD/compile-pentium-debug-max-no-qc:
  test build without query cache
sql/mysql_priv.h:
  removed double declaration
storage/maria/ha_maria.cc:
  query cache invalidation fixed
storage/maria/ma_state.c:
  query cache invalidation fixed
storage/maria/maria_def.h:
  last transaction ID added
  invalidation fixed
storage/myisam/ha_myisam.cc:
  invalidation fixed
storage/myisam/mi_locking.c:
  invalidation fixed
storage/myisam/myisamdef.h:
  invalidation fixed
2009-10-06 09:57:22 +03: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
Michael Widenius
7f91cf0861 Merge with main Maria tree 2008-12-09 14:36:51 +02:00
unknown
131a6a57a4 merge 2008-12-08 22:12:23 +02:00
unknown
c9b0c5a15c Fixed mutexes lock order in maria_close(): LOCK_trn_list -> MARIA_SHARE::intern_lock (then will be WL to revert the order).
(BUG#40981 Maria: deadlock between checkpoint and maria_close() when freeing state info)

storage/maria/ma_checkpoint.c:
  The argument added to the function to use it in maria_close().
storage/maria/ma_close.c:
  Locking/unlocking MARIA_SHARE::intern_lock added to use correct order of the mutexes taking.
storage/maria/ma_state.c:
  Removed assert becase now we have externally locked mutex in maria_close().
  The argument added to the _ma_remove_not_visible_states_with_lock() to use it in maria_close().
  _ma_remove_not_visible_states_with_lock() fixed tio be usable from maria_chk where transaction manager is not initialized.
storage/maria/ma_state.h:
  The argument added to the function to use it in maria_close().
storage/maria/maria_def.h:
  Fixed comment to the variable.
storage/maria/trnman.c:
  The debugging assert added.
  New function to detect transaction manager initialization added (maria_chk do not initialize it).
storage/maria/trnman_public.h:
  New function to detect transaction manager initialization added (maria_chk do not initialize it).
2008-12-08 22:09:59 +02:00
Michael Widenius
d0fb8270df Fixed problem with crash in Maria _ma_setup_live_state() where history link didn't include needed state
mysql-test/mysql-test-run.pl:
  Remove warnings in log about depricated mysqld options
storage/maria/ma_state.c:
  More DBUG_PRINT
storage/maria/trnman.c:
  Fixed wrong test if commit_trid is visible
2008-12-08 20:31:16 +02:00
Michael Widenius
32f81bab7d WL#3262 add mutex lock order checking to safemutex (also called safe_mutex_deadlock_detector)
This writes a warning on stderr if one uses mutex in different order,
like if one in one case would lock mutex in the order A,B and in another case
would lock mutex in the order B,A
This is inspired by and loosely based on the LOCKDEP patch by Jonas
Wrong mutex order is either fixed or mutex are marked with MYF_NO_DEADLOCK_DETECTION
if used inconsistently (need to be fixed by server team)

KNOWN_BUGS.txt:
  Added information that one need to dump and restore Maria tables
include/hash.h:
  Added prototype function for walking over all elements in a hash
include/my_pthread.h:
  Added my_pthread_mutex_init() and my_pthread_mutex_lock(); These should be used if one wants to disable mutex order checking.
  Changed names of the nonposix mutex_init functions to not conflict with my_phread_mutex_init()
  Added and extended structures for mutex deadlock detection.
  New arguments to sage_mutex_init() and safe_mutex_lock() to allow one to disable mutex order checking.
  Added variable 'safe_mutex_deadlock_detector' to enable/disable deadlock detection for all pthread_mutex_init()
mysys/Makefile.am:
  Added cleaning of test files
  Added test_thr_mutex
mysys/hash.c:
  Added hash_iterate() to iterate over all elements in a hash
  More comments
mysys/my_init.c:
  Added calls to destory all mutex uses by mysys()
  Added waiting for threads to end before calling TERMINATE() to list not freed memory
mysys/my_pthread.c:
  Changed names to free my_pthread_mutex_init() for mutex-lock-order-checking
mysys/my_sleep.c:
  Fixed too long wait if using 1000000L as argument
mysys/my_thr_init.c:
  Mark THR_LOCK_threads and THR_LOCK_malloc to not have mutex deadlock detection.
  (We can't have it enabled for this as these are internal mutex used by the detector  
  Call my_thread_init() early as we need thread specific variables enabled for the following pthread_mutex_init()
  Move code to wait for threads to end to my_wait_for_other_threads_to_die()
  Don't destroy mutex and conditions unless all threads have died
  Added my_thread_destroy_mutex() to destroy all mutex used by the mysys thread system
  Name the thread specific mutex as "mysys_var->mutex"
  Added my_thread_var_mutex_in_use() to return pointer to mutex in use or 0 if thread variables are not initialized
mysys/mysys_priv.h:
  Added prototypes for functions used internally with mutex-wrong-usage detection
mysys/thr_mutex.c:
  Added runtime detection of mutex used in conflicting order
  See WL#3262 or test_thr_mutex.c for examples
  The base idea is for each mutex have two hashes:
  - mutex->locked_mutex points to all mutex used after this one
  - mutex->used_mutex points to all mutex which has this mutex in it's mutex->locked_mutex
  There is a wrong mutex order if any mutex currently locked before this mutex is in the mutex->locked_mutex hash
sql/event_queue.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/event_scheduler.cc:
  Declare the right order to take the mutex
sql/events.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/ha_ndbcluster_binlog.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/log.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/mysqld.cc:
  Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread
  This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex.
  Added call to free sp cache.
  Add destruction of LOCK_server_started and COND_server_started.
  Added register_mutex_order() function to register in which order mutex should be taken
  (to initiailize mutex_deadlock_detector).
  Added option to turn off safe_mutex_deadlock_detector
sql/protocol.cc:
  Fixed wrong argument to DBUG_PRINT (found by valgrind)
sql/rpl_mi.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/set_var.cc:
  Remove wrong locking of LOCK_global_system_variables when reading and setting log variables
  (would cause inconsistent mutex order).
  Update global variables outside of logger.unlock() as LOCK_global_system_variables has to be taken before logger locks
  Reviewed by gluh
sql/sp_cache.cc:
  Added function to destroy mutex used by sp cache
sql/sp_cache.h:
  Added function to destroy mutex used by sp cache
sql/sql_class.cc:
  Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread
  This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex.
  Register order in which LOCK_delete and mysys_var->mutex is taken
sql/sql_insert.cc:
  Give a name for Delayed_insert::mutex
  Mark mutex used inconsistently (need to be fixed by server team)
  Move closing of tables outside of di->mutex (to avoid wrong mutex order)
sql/sql_show.cc:
  Don't keep LOCK_global_system_variables locked over value->show_type() as this leads to wrong mutex order
storage/innobase/handler/ha_innodb.cc:
  Disable safe_muted_deadlock_detector for innobase intern mutex (to speed up page cache initialization)
storage/maria/ha_maria.cc:
  Added flag to ha_maria::info() to signal if we need to lock table share or not.
  This is needed to avoid locking mutex in wrong order
storage/maria/ha_maria.h:
  Added flag to ha_maria::info() to signal if we need to lock table share or not.
storage/maria/ma_close.c:
  Destroy key_del_lock
  Simplify freeing ftparser_param
storage/maria/ma_key.c:
  Better comment
storage/maria/ma_loghandler.c:
  Mark mutex used inconsistently (need to be fixed by sanja)
storage/maria/ma_state.c:
  More comments
storage/maria/ma_test1.c:
  Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety)
storage/maria/ma_test2.c:
  Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety)
2008-12-03 00:02:52 +02:00
Michael Widenius
d5456c5d1b Fixed bug introduced in last push.
storage/maria/ha_maria.cc:
  Use file->s->lock_key_trees instead of file->s->lock.get_status to detect if we are using versioning
storage/maria/ma_state.c:
  Fixed function prototype
storage/maria/ma_state.h:
  Fixed function prototype
2008-11-03 15:53:22 +02:00
Michael Widenius
2b521320fb Added ha_maria::is_changed() (needed for Query cache)
storage/maria/ha_maria.cc:
  Added ha_maria::is_changed()
storage/maria/ha_maria.h:
  Added ha_maria::is_changed()
storage/maria/ma_delete.c:
  Mark that table changed
storage/maria/ma_open.c:
  Ensure that info->state->changed is always reset from thr_lock()
storage/maria/ma_state.c:
  Reset handler->state->changed at first usage of transactional table
  Reset handler->state->changed when taking lock for not transactional table
storage/maria/ma_state.h:
  Added variable and function to track changes of table
storage/maria/ma_update.c:
  Mark that table changed
storage/maria/ma_write.c:
  Mark that table changed
2008-11-01 01:14:58 +02:00
Sergei Golubchik
4be86917fe merge 2008-08-28 20:52:23 +02:00
Michael Widenius
ea31b1e6ec Fixes for Bug #38016 Maria: trying to access freed memory when committing a transaction
Don't write out states if they haven't changed

sql/sql_base.cc:
  Call extra(HA_EXTRA_PREPARE_FOR_DROP) before doing a drop of a table
  More DBUG
sql/sql_table.cc:
  Call extra(HA_EXTRA_PREPARE_FOR_RENAME) before renaming a table
storage/maria/ha_maria.cc:
  Ensure that file->trn is set when we call extra(HA_EXTRA_PREPARE_FOR_DROP/RENAME)
storage/maria/ma_close.c:
  When doing close, assert if we have pointers in trn->table_list that points to the MARIA_SHARE
storage/maria/ma_extra.c:
  Reset info->state_start in case of drop/rename. This fixes the problem of accessing freed memory in repair
  Don't write state changed if they haven't changed
storage/maria/ma_open.c:
  Reset share->changed after we have written out a state (speed optimization to not write states when they haven't changed)
storage/maria/ma_state.c:
  Decrement share->in_trans properly in DBUG_BINARY to ensure that the DBUG_ASSERT() in maria_close() works
  More DBUG
2008-08-19 01:21:22 +03:00
Sergei Golubchik
3971e262e9 maria: deadlock detection when waiting on unique key (useless until we can rollback)
include/my_pthread.h:
  cleanup
include/waiting_threads.h:
  header guard
mysys/waiting_threads.c:
  bug - kill strategy were not applied to deadlocks of length 1.
  cast timeout to ulonglong.
storage/maria/ma_static.c:
  declare WT_RESOURCE_TYPE ma_rc_dup_unique
storage/maria/ma_write.c:
  deadlock detection when waiting on unique key (useless until we can rollback)
storage/maria/maria_def.h:
  deadlock detection when waiting on unique key (useless until we can rollback)
storage/maria/trnman.c:
  use deadlock detector.
  protect state transitions of a TRN with a mutex.
  trnman_trid_to_trn() function.
storage/maria/trnman.h:
  trnman_trid_to_trn() function
  protect state transitions of a TRN with a mutex
  use deadlock detector.
storage/maria/trnman_public.h:
  trnman_trid_to_trn()
2008-08-06 21:30:05 +02:00
Michael Widenius
50fa1eb8b5 Fixing bug when using alter table on locked maria table
Reset history when we reenable logging for transactional tables (safety fix)

mysql-test/r/maria2.result:
  New results
mysql-test/t/maria2.test:
  Added test case for alter table on locked maria table
mysql-test/valgrind.supp:
  Added suppression rules for warnings in libc / libld
storage/maria/ma_extra.c:
  Remove table from trnman list if we are going to drop or rename it; We don't want not existing shares in the list when we do commit!
storage/maria/ma_recovery.c:
  Ensure that info->state don't point to history event when we disable logging for a table;  This is needed as alter table will first do commit and then unlock, which would cause us to access a non existing object when we reenable logging.
  Reset history when we reenable logging (safety fix)
storage/maria/ma_state.c:
  Do less work when share->now_transactional is not set. (Safety fix)
  Added function to remove shares to be deleted from trnman->used_tables
  Added function to reset history to current context
storage/maria/ma_state.h:
  Prototypes for new function
2008-07-12 17:14:28 +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
Michael Widenius
1d72603832 Merge; No notable changes
.bzr-mysql/default.conf:
  Automatic merge
config/ac-macros/plugins.m4:
  Automatic merge
configure.in:
  Automatic merge
include/my_global.h:
  Automatic merge
mysql-test/include/maria_empty_logs.inc:
  Use Guilmhems version, but don't echo use database
mysql-test/r/maria-no-logging.result:
  Automatic merge
mysql-test/r/maria-page-checksum.result:
  Automatic merge
mysql-test/r/maria-recover.result:
  Automatic merge
mysql-test/r/maria2.result:
  Automatic merge
mysql-test/t/maria-no-logging.test:
  Automatic merge
mysql-test/t/maria-page-checksum.test:
  Automatic merge
mysql-test/t/maria-purge.test:
  Automatic merge
mysql-test/t/maria-recover.test:
  Automatic merge
mysql-test/t/maria2.test:
  Automatic merge
sql/sql_table.cc:
  Automatic merge
storage/maria/CMakeLists.txt:
  Automatic merge
storage/maria/ma_ft_parser.c:
  Automatic merge
storage/maria/ma_loghandler.c:
  Automatic merge
storage/maria/ma_recovery.c:
  Automatic merge
storage/maria/ma_rt_test.c:
  Manual merge
storage/maria/ma_state.c:
  Automatic merge
storage/maria/ma_test_force_start.pl:
  Automatic merge
storage/maria/plug.in:
  Automatic merge
storage/maria/unittest/CMakeLists.txt:
  Automatic merge
storage/maria/unittest/Makefile.am:
  Automatic merge
storage/maria/unittest/ma_test_all-t:
  Automatic merge
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Automatic merge
storage/maria/unittest/ma_test_recovery.pl:
  Automatic merge
storage/myisam/rt_test.c:
  Automatic merge
2008-06-26 12:32:22 +03: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
Guilhem Bichot
5f26e7384f Fix for build failures under Windows
storage/maria/CMakeLists.txt:
  add missing file
storage/maria/ma_state.c:
  two include files are in storage/maria, not in include/, so they need "" not <>, or compiler misses them.
2008-06-09 11:06:06 +02: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
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