diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-12-03 02:09:22 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-12-03 02:09:22 +0300 |
commit | 7f628ac2ddf0cd70ccfb43d48792f45943d6ca48 (patch) | |
tree | 1e05474e5b3edbfa7abdae09ac17ff8033754c46 /sql/ha_partition.cc | |
parent | e91294243f9905356a31d1a9944b2bea9cbfe859 (diff) | |
download | mariadb-git-7f628ac2ddf0cd70ccfb43d48792f45943d6ca48.tar.gz |
Backport of:
----------------------------------------------------------
revno: 2630.4.38
committer: Konstantin Osipov <konstantin@mysql.com>
branch nick: mysql-6.0-4144
timestamp: Wed 2008-06-25 22:07:06 +0400
message:
WL#4144 - Lock MERGE engine children.
Committing a version of the patch merged with WL#3726
on behalf of Ingo.
Step #1: Move locking from parent to children.
MERGE children are now left in the query list of tables
after inserted there in open_tables(). So they are locked
by lock_tables() as all other tables are.
The MERGE parent does not store locks any more. It appears
in a MYSQL_LOCK with zero lock data. This is kind of a "dummy"
lock.
All other lock handling is also done directly on the children.
To protect against parent or child modifications during LOCK
TABLES, the children are detached after every statement and
attached before every statement, even under LOCK TABLES.
The children table list is removed from the query list of tables
on every detach and on close of the parent.
Step #2: Move MERGE specific functionality from SQL layer
into table handler.
Functionality moved from SQL layer (mainly sql_base.cc)
to the table handler (ha_myisammrg.cc).
Unnecessary code is removed from the SQL layer.
Step #3: Moved all MERGE specific members from TABLE
to ha_myisammrg.
Moved members from TABLE to ha_myisammrg.
Renamed some mebers.
Fixed comments.
Step #4: Valgrind and coverage testing
Valgrind did not uncover new problems.
Added purecov comments.
Added a new test for DATA/INDEX DIRECTORY options.
Changed handling of ::reset() for non-attached children.
Fixed the merge-big test.
Step #5: Fixed crashes detected during review
Changed detection when to attach/detach.
Added new tests.
Backport also the fix for Bug#44040 "MySQL allows creating a
MERGE table upon VIEWs but crashes when using it"
include/my_base.h:
WL#4144 - Lock MERGE engine children
Added HA_EXTRA_ADD_CHILDREN_LIST and HA_EXTRA_IS_ATTACHED_CHILDREN
for MERGE table support
mysql-test/r/merge.result:
WL#4144 - Lock MERGE engine children
Fixed test result.
mysql-test/t/disabled.def:
Enable merge.test, which now is working again (WL#4144).
mysql-test/t/merge-big.test:
Fix the messages for wait_condition (merge with WL#3726).
mysql-test/t/merge.test:
WL#4144 - Lock MERGE engine children
Fixed one test to meet coding standards for tests
(upper case keywords, engine names as in SHOW ENGINES).
Fixed error codes.
Added a test for DATA/INDEX DIRECTORY.
mysys/thr_lock.c:
WL#4144 - Lock MERGE engine children
Added purecov comments.
sql/ha_partition.cc:
WL#4144 - Lock MERGE engine children
Added MERGE specific extra operations to ha_partition::extra().
Extended comments.
Changed function comment to doxygen style.
Fixed nomenclature: 'parameter' -> 'operation'.
sql/mysql_priv.h:
WL#4144 - Lock MERGE engine children
Removed declarations for removed functions.
sql/sql_base.cc:
WL#4144 - Lock MERGE engine children
Leave the children in the query list of tables after open_tables().
Set proper back links (prev_global).
Attach MERGE children before and detach them after every
statement. Even under LOCK TABLES.
Remove children from the query list when they are detached.
Remove lock forwarding from children to parent.
Moved MERGE specific functions to ha_myisammrg.cc.
Added purecov comments.
Backport the fix for Bug#44040 "MySQL allows creating a MERGE table upon VIEWs but crashes when using it"
sql/sql_table.cc:
WL#4144 - Lock MERGE engine children
Changed detection of MERGE tables.
sql/table.cc:
WL#4144 - Lock MERGE engine children
Moved is_children_attached() method from TABLE to ha_myisammrg.
sql/table.h:
WL#4144 - Lock MERGE engine children
Moved all MERGE specific members from TABLE to ha_myisammrg.
storage/myisammrg/ha_myisammrg.cc:
WL#4144 - Lock MERGE engine children
Set proper back links in the child list (prev_global).
Added a function for removal of the child list from the query list.
Remove children from the query list when the parent is closed.
Make parent lock handling a dummy (zero locks).
Moved MERGE specific functionality from SQL layer to here.
Moved all MERGE specific members from TABLE to ha_myisammrg.
Renamed children list pointers.
Added initialization and free for the children list mem_root.
Fixed comments.
Added purecov comments.
storage/myisammrg/ha_myisammrg.h:
WL#4144 - Lock MERGE engine children
Added method add_children_list().
Moved all MERGE specific members from TABLE to ha_myisammrg.
Renamed children list pointers.
Added a mem_root for the children list.
storage/myisammrg/myrg_extra.c:
WL#4144 - Lock MERGE engine children
Changed handling of ::reset() for non-attached children.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 1514651c1c5..8760b398ec9 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5265,34 +5265,35 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, } -/* - General function to prepare handler for certain behavior +/** + General function to prepare handler for certain behavior. - SYNOPSIS - extra() + @param[in] operation operation to execute operation Operation type for extra call - RETURN VALUE - >0 Error code - 0 Success + @return status + @retval 0 success + @retval >0 error code + + @detail - DESCRIPTION extra() is called whenever the server wishes to send a hint to the storage engine. The MyISAM engine implements the most hints. We divide the parameters into the following categories: - 1) Parameters used by most handlers - 2) Parameters used by some non-MyISAM handlers - 3) Parameters used only by MyISAM - 4) Parameters only used by temporary tables for query processing - 5) Parameters only used by MyISAM internally - 6) Parameters not used at all - 7) Parameters only used by federated tables for query processing - 8) Parameters only used by NDB + 1) Operations used by most handlers + 2) Operations used by some non-MyISAM handlers + 3) Operations used only by MyISAM + 4) Operations only used by temporary tables for query processing + 5) Operations only used by MyISAM internally + 6) Operations not used at all + 7) Operations only used by federated tables for query processing + 8) Operations only used by NDB + 9) Operations only used by MERGE The partition handler need to handle category 1), 2) and 3). - 1) Parameters used by most handlers + 1) Operations used by most handlers ----------------------------------- HA_EXTRA_RESET: This option is used by most handlers and it resets the handler state @@ -5331,7 +5332,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, ensure disk based tables are flushed at end of query execution. Currently is never used. - 2) Parameters used by some non-MyISAM handlers + 2) Operations used by some non-MyISAM handlers ---------------------------------------------- HA_EXTRA_KEYREAD_PRESERVE_FIELDS: This is a strictly InnoDB feature that is more or less undocumented. @@ -5350,7 +5351,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, SQL constructs. Not used by MyISAM. - 3) Parameters used only by MyISAM + 3) Operations used only by MyISAM --------------------------------- HA_EXTRA_NORMAL: Only used in MyISAM to reset quick mode, not implemented by any other @@ -5481,7 +5482,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, Only used by MyISAM, called when altering table, closing tables to enforce a reopen of the table files. - 4) Parameters only used by temporary tables for query processing + 4) Operations only used by temporary tables for query processing ---------------------------------------------------------------- HA_EXTRA_RESET_STATE: Same as reset() except that buffers are not released. If there is @@ -5512,7 +5513,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, tables used in query processing. Not handled by partition handler. - 5) Parameters only used by MyISAM internally + 5) Operations only used by MyISAM internally -------------------------------------------- HA_EXTRA_REINIT_CACHE: This call reinitializes the READ CACHE described above if there is one @@ -5547,19 +5548,19 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, HA_EXTRA_CHANGE_KEY_TO_UNIQUE: Only used by MyISAM, never called. - 6) Parameters not used at all + 6) Operations not used at all ----------------------------- HA_EXTRA_KEY_CACHE: HA_EXTRA_NO_KEY_CACHE: This parameters are no longer used and could be removed. - 7) Parameters only used by federated tables for query processing + 7) Operations only used by federated tables for query processing ---------------------------------------------------------------- HA_EXTRA_INSERT_WITH_UPDATE: Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY. - 8) Parameters only used by NDB + 8) Operations only used by NDB ------------------------------ HA_EXTRA_DELETE_CANNOT_BATCH: HA_EXTRA_UPDATE_CANNOT_BATCH: @@ -5567,6 +5568,14 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, and should perform them immediately. This may be needed when table has AFTER DELETE/UPDATE triggers which access to subject table. These flags are reset by the handler::extra(HA_EXTRA_RESET) call. + + 9) Operations only used by MERGE + ------------------------------ + HA_EXTRA_ADD_CHILDREN_LIST: + HA_EXTRA_ATTACH_CHILDREN: + HA_EXTRA_IS_ATTACHED_CHILDREN: + HA_EXTRA_DETACH_CHILDREN: + Special actions for MERGE tables. Ignore. */ int ha_partition::extra(enum ha_extra_function operation) @@ -5659,13 +5668,22 @@ int ha_partition::extra(enum ha_extra_function operation) /* Category 7), used by federated handlers */ case HA_EXTRA_INSERT_WITH_UPDATE: DBUG_RETURN(loop_extra(operation)); - /* Category 8) Parameters only used by NDB */ + /* Category 8) Operations only used by NDB */ case HA_EXTRA_DELETE_CANNOT_BATCH: case HA_EXTRA_UPDATE_CANNOT_BATCH: { /* Currently only NDB use the *_CANNOT_BATCH */ break; } + /* Category 9) Operations only used by MERGE */ + case HA_EXTRA_ADD_CHILDREN_LIST: + case HA_EXTRA_ATTACH_CHILDREN: + case HA_EXTRA_IS_ATTACHED_CHILDREN: + case HA_EXTRA_DETACH_CHILDREN: + { + /* Special actions for MERGE tables. Ignore. */ + break; + } /* http://dev.mysql.com/doc/refman/5.1/en/partitioning-limitations.html says we no longer support logging to partitioned tables, so we fail |