summaryrefslogtreecommitdiff
path: root/innobase/trx
diff options
context:
space:
mode:
authorunknown <jan@hundin.mysql.fi>2005-07-22 14:10:03 +0300
committerunknown <jan@hundin.mysql.fi>2005-07-22 14:10:03 +0300
commit6fd13aaa3ccc470f03c51686f781651c9709154e (patch)
tree883851cd5501311efd796192fc3f483fd158d9d6 /innobase/trx
parentadf5fdcd7413c110b2b27f118f41eb249c781e4e (diff)
downloadmariadb-git-6fd13aaa3ccc470f03c51686f781651c9709154e.tar.gz
Implement MySQL framework to support consistent read views in
cursors for InnoDB. The idea of the patch is that if MySQL requests a consistent read view, we open one when open a cursor, set is as the active view to a transaction when fetch from the cursor, and close together with cursor close. This patch is associated to bugs #11813, #11832, and #11833. Contains after review fixes.
Diffstat (limited to 'innobase/trx')
-rw-r--r--innobase/trx/trx0trx.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
index 10fbf3468c0..f95491443ee 100644
--- a/innobase/trx/trx0trx.c
+++ b/innobase/trx/trx0trx.c
@@ -159,7 +159,8 @@ trx_create(
trx->auto_inc_lock = NULL;
- trx->read_view_heap = mem_heap_create(256);
+ trx->global_read_view_heap = mem_heap_create(256);
+ trx->global_read_view = NULL;
trx->read_view = NULL;
/* Set X/Open XA transaction identification to NULL */
@@ -318,10 +319,12 @@ trx_free(
ut_a(UT_LIST_GET_LEN(trx->trx_locks) == 0);
- if (trx->read_view_heap) {
- mem_heap_free(trx->read_view_heap);
+ if (trx->global_read_view_heap) {
+ mem_heap_free(trx->global_read_view_heap);
}
+ trx->global_read_view = NULL;
+
ut_a(trx->read_view == NULL);
mem_free(trx);
@@ -831,10 +834,23 @@ trx_commit_off_kernel(
lock_release_off_kernel(trx);
if (trx->read_view) {
+ /* If transaction has a global read view this case
+ means that transaction has been using a consistent
+ read view associated to a cursor. Only the global
+ read view associated to a transaction is closed
+ and read view is then removed from the transaction.
+ If read view associated to a cursor is still used
+ it must be re-registered to another transaction. */
+
+ if (UNIV_LIKELY_NULL(trx->global_read_view)) {
+ trx->read_view = trx->global_read_view;
+ }
+
read_view_close(trx->read_view);
- mem_heap_empty(trx->read_view_heap);
+ mem_heap_empty(trx->global_read_view_heap);
trx->read_view = NULL;
+ trx->global_read_view = NULL;
}
if (must_flush_log) {
@@ -964,7 +980,9 @@ trx_assign_read_view(
mutex_enter(&kernel_mutex);
if (!trx->read_view) {
- trx->read_view = read_view_open_now(trx, trx->read_view_heap);
+ trx->read_view = read_view_open_now(trx,
+ trx->global_read_view_heap);
+ trx->global_read_view = trx->read_view;
}
mutex_exit(&kernel_mutex);