#include "univ.i"#include "ut0byte.h"#include "ut0lst.h"#include "trx0trx.h"#include "read0types.h"Include dependency graph for read0read.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| struct | read_view_struct |
| struct | cursor_view_struct |
Defines | |
| #define | VIEW_NORMAL 1 |
| #define | VIEW_HIGH_GRANULARITY 2 |
Functions | |
| read_view_t * | read_view_open_now (dulint cr_trx_id, mem_heap_t *heap) |
| read_view_t * | read_view_oldest_copy_or_open_new (dulint cr_trx_id, mem_heap_t *heap) |
| void | read_view_close (read_view_t *view) |
| void | read_view_close_for_mysql (trx_t *trx) |
| UNIV_INLINE ibool | read_view_sees_trx_id (read_view_t *view, dulint trx_id) |
| void | read_view_print (read_view_t *view) |
| cursor_view_t * | read_cursor_view_create_for_mysql (trx_t *cr_trx) |
| void | read_cursor_view_close_for_mysql (trx_t *trx, cursor_view_t *curview) |
| void | read_cursor_set_for_mysql (trx_t *trx, cursor_view_t *curview) |
| #define VIEW_HIGH_GRANULARITY 2 |
Definition at line 145 of file read0read.h.
Referenced by read_cursor_view_create_for_mysql(), read_view_print(), and row_vers_build_for_consistent_read().
| #define VIEW_NORMAL 1 |
| void read_cursor_set_for_mysql | ( | trx_t * | trx, | |
| cursor_view_t * | curview | |||
| ) |
Definition at line 516 of file read0read.c.
References trx_struct::global_read_view, kernel_mutex, mutex_enter, mutex_exit(), NULL, trx_struct::read_view, cursor_view_struct::read_view, and ut_a.
00518 : transaction where cursor is set */ 00519 cursor_view_t* curview)/* in: consistent cursor view to be set */ 00520 { 00521 ut_a(trx); 00522 00523 mutex_enter(&kernel_mutex); 00524 00525 if (UNIV_LIKELY(curview != NULL)) { 00526 trx->read_view = curview->read_view; 00527 } else { 00528 trx->read_view = trx->global_read_view; 00529 } 00530 00531 mutex_exit(&kernel_mutex); 00532 }
Here is the call graph for this function:

| void read_cursor_view_close_for_mysql | ( | trx_t * | trx, | |
| cursor_view_t * | curview | |||
| ) |
Definition at line 487 of file read0read.c.
References trx_struct::global_read_view, cursor_view_struct::heap, kernel_mutex, mem_heap_free, mutex_enter, mutex_exit(), trx_struct::n_mysql_tables_in_use, cursor_view_struct::n_mysql_tables_in_use, cursor_view_struct::read_view, trx_struct::read_view, read_view_close(), and ut_a.
00489 : trx */ 00490 cursor_view_t* curview)/* in: cursor view to be closed */ 00491 { 00492 ut_a(curview); 00493 ut_a(curview->read_view); 00494 ut_a(curview->heap); 00495 00496 /* Add cursor's tables to the global count of active tables that 00497 belong to this transaction */ 00498 trx->n_mysql_tables_in_use += curview->n_mysql_tables_in_use; 00499 00500 mutex_enter(&kernel_mutex); 00501 00502 read_view_close(curview->read_view); 00503 trx->read_view = trx->global_read_view; 00504 00505 mutex_exit(&kernel_mutex); 00506 00507 mem_heap_free(curview->heap); 00508 }
Here is the call graph for this function:

| cursor_view_t* read_cursor_view_create_for_mysql | ( | trx_t * | cr_trx | ) |
Definition at line 394 of file read0read.c.
References read_view_struct::can_be_too_old, trx_struct::conc_state, read_view_struct::creator_trx_id, FALSE, cursor_view_struct::heap, trx_struct::id, kernel_mutex, read_view_struct::low_limit_id, read_view_struct::low_limit_no, trx_sys_struct::max_trx_id, mem_heap_alloc(), mem_heap_create, mutex_enter, mutex_exit(), n, cursor_view_struct::n_mysql_tables_in_use, trx_struct::n_mysql_tables_in_use, read_view_struct::n_trx_ids, trx_struct::no, cursor_view_struct::read_view, read_view_create_low(), TRX_ACTIVE, TRX_PREPARED, trx_sys, read_view_struct::type, read_view_struct::undo_no, trx_struct::undo_no, read_view_struct::up_limit_id, ut_a, ut_dulint_cmp(), UT_LIST_ADD_FIRST, UT_LIST_GET_FIRST, UT_LIST_GET_LEN, UT_LIST_GET_NEXT, and VIEW_HIGH_GRANULARITY.
00396 : trx where cursor view is created */ 00397 { 00398 cursor_view_t* curview; 00399 read_view_t* view; 00400 mem_heap_t* heap; 00401 trx_t* trx; 00402 ulint n; 00403 00404 ut_a(cr_trx); 00405 00406 /* Use larger heap than in trx_create when creating a read_view 00407 because cursors are quite long. */ 00408 00409 heap = mem_heap_create(512); 00410 00411 curview = (cursor_view_t*) mem_heap_alloc(heap, sizeof(cursor_view_t)); 00412 curview->heap = heap; 00413 00414 /* Drop cursor tables from consideration when evaluating the need of 00415 auto-commit */ 00416 curview->n_mysql_tables_in_use = cr_trx->n_mysql_tables_in_use; 00417 cr_trx->n_mysql_tables_in_use = 0; 00418 00419 mutex_enter(&kernel_mutex); 00420 00421 curview->read_view = read_view_create_low( 00422 UT_LIST_GET_LEN(trx_sys->trx_list), 00423 curview->heap); 00424 00425 view = curview->read_view; 00426 view->creator_trx_id = cr_trx->id; 00427 view->type = VIEW_HIGH_GRANULARITY; 00428 view->undo_no = cr_trx->undo_no; 00429 00430 /* No future transactions should be visible in the view */ 00431 00432 view->low_limit_no = trx_sys->max_trx_id; 00433 view->low_limit_id = view->low_limit_no; 00434 00435 view->can_be_too_old = FALSE; 00436 00437 n = 0; 00438 trx = UT_LIST_GET_FIRST(trx_sys->trx_list); 00439 00440 /* No active transaction should be visible */ 00441 00442 while (trx) { 00443 00444 if (trx->conc_state == TRX_ACTIVE 00445 || trx->conc_state == TRX_PREPARED) { 00446 00447 read_view_set_nth_trx_id(view, n, trx->id); 00448 00449 n++; 00450 00451 /* NOTE that a transaction whose trx number is < 00452 trx_sys->max_trx_id can still be active, if it is 00453 in the middle of its commit! Note that when a 00454 transaction starts, we initialize trx->no to 00455 ut_dulint_max. */ 00456 00457 if (ut_dulint_cmp(view->low_limit_no, trx->no) > 0) { 00458 00459 view->low_limit_no = trx->no; 00460 } 00461 } 00462 00463 trx = UT_LIST_GET_NEXT(trx_list, trx); 00464 } 00465 00466 view->n_trx_ids = n; 00467 00468 if (n > 0) { 00469 /* The last active transaction has the smallest id: */ 00470 view->up_limit_id = read_view_get_nth_trx_id(view, n - 1); 00471 } else { 00472 view->up_limit_id = view->low_limit_id; 00473 } 00474 00475 UT_LIST_ADD_FIRST(view_list, trx_sys->view_list, view); 00476 00477 mutex_exit(&kernel_mutex); 00478 00479 return(curview); 00480 }
Here is the call graph for this function:

| void read_view_close | ( | read_view_t * | view | ) |
Definition at line 311 of file read0read.c.
References kernel_mutex, trx_sys, ut_ad, and UT_LIST_REMOVE.
Referenced by read_cursor_view_close_for_mysql(), read_view_close_for_mysql(), trx_commit_off_kernel(), and trx_purge().
00313 : read view */ 00314 { 00315 #ifdef UNIV_SYNC_DEBUG 00316 ut_ad(mutex_own(&kernel_mutex)); 00317 #endif /* UNIV_SYNC_DEBUG */ 00318 UT_LIST_REMOVE(view_list, trx_sys->view_list, view); 00319 }
Here is the caller graph for this function:

| void read_view_close_for_mysql | ( | trx_t * | trx | ) |
Definition at line 326 of file read0read.c.
References trx_struct::global_read_view, trx_struct::global_read_view_heap, kernel_mutex, mem_heap_empty(), mutex_enter, mutex_exit(), NULL, trx_struct::read_view, read_view_close(), and ut_a.
00328 : trx which has a read view */ 00329 { 00330 ut_a(trx->global_read_view); 00331 00332 mutex_enter(&kernel_mutex); 00333 00334 read_view_close(trx->global_read_view); 00335 00336 mem_heap_empty(trx->global_read_view_heap); 00337 00338 trx->read_view = NULL; 00339 trx->global_read_view = NULL; 00340 00341 mutex_exit(&kernel_mutex); 00342 }
Here is the call graph for this function:

| read_view_t* read_view_oldest_copy_or_open_new | ( | dulint | cr_trx_id, | |
| mem_heap_t * | heap | |||
| ) |
Definition at line 150 of file read0read.c.
References read_view_struct::can_be_too_old, read_view_struct::creator_trx_id, FALSE, kernel_mutex, read_view_struct::low_limit_id, read_view_struct::low_limit_no, n, read_view_struct::n_trx_ids, NULL, read_view_create_low(), read_view_open_now(), TRUE, trx_sys, read_view_struct::up_limit_id, ut_ad, ut_dulint_cmp(), ut_dulint_create(), UT_LIST_ADD_LAST, and UT_LIST_GET_LAST.
Referenced by trx_purge(), and trx_purge_sys_create().
00152 : read view struct */ 00153 dulint cr_trx_id, /* in: trx_id of creating 00154 transaction, or (0, 0) used in purge*/ 00155 mem_heap_t* heap) /* in: memory heap from which 00156 allocated */ 00157 { 00158 read_view_t* old_view; 00159 read_view_t* view_copy; 00160 ibool needs_insert = TRUE; 00161 ulint insert_done = 0; 00162 ulint n; 00163 ulint i; 00164 00165 #ifdef UNIV_SYNC_DEBUG 00166 ut_ad(mutex_own(&kernel_mutex)); 00167 #endif /* UNIV_SYNC_DEBUG */ 00168 old_view = UT_LIST_GET_LAST(trx_sys->view_list); 00169 00170 if (old_view == NULL) { 00171 00172 return(read_view_open_now(cr_trx_id, heap)); 00173 } 00174 00175 n = old_view->n_trx_ids; 00176 00177 if (ut_dulint_cmp(old_view->creator_trx_id, 00178 ut_dulint_create(0,0)) != 0) { 00179 n++; 00180 } else { 00181 needs_insert = FALSE; 00182 } 00183 00184 view_copy = read_view_create_low(n, heap); 00185 00186 /* Insert the id of the creator in the right place of the descending 00187 array of ids, if needs_insert is TRUE: */ 00188 00189 i = 0; 00190 while (i < n) { 00191 if (needs_insert 00192 && (i >= old_view->n_trx_ids 00193 || ut_dulint_cmp(old_view->creator_trx_id, 00194 read_view_get_nth_trx_id(old_view, i)) 00195 > 0)) { 00196 00197 read_view_set_nth_trx_id(view_copy, i, 00198 old_view->creator_trx_id); 00199 needs_insert = FALSE; 00200 insert_done = 1; 00201 } else { 00202 read_view_set_nth_trx_id(view_copy, i, 00203 read_view_get_nth_trx_id(old_view, 00204 i - insert_done)); 00205 } 00206 00207 i++; 00208 } 00209 00210 view_copy->creator_trx_id = cr_trx_id; 00211 00212 view_copy->low_limit_no = old_view->low_limit_no; 00213 view_copy->low_limit_id = old_view->low_limit_id; 00214 00215 view_copy->can_be_too_old = FALSE; 00216 00217 if (n > 0) { 00218 /* The last active transaction has the smallest id: */ 00219 view_copy->up_limit_id = read_view_get_nth_trx_id( 00220 view_copy, n - 1); 00221 } else { 00222 view_copy->up_limit_id = old_view->up_limit_id; 00223 } 00224 00225 UT_LIST_ADD_LAST(view_list, trx_sys->view_list, view_copy); 00226 00227 return(view_copy); 00228 }
Here is the call graph for this function:

Here is the caller graph for this function:

| read_view_t* read_view_open_now | ( | dulint | cr_trx_id, | |
| mem_heap_t * | heap | |||
| ) |
Definition at line 235 of file read0read.c.
References read_view_struct::can_be_too_old, trx_struct::conc_state, read_view_struct::creator_trx_id, FALSE, trx_struct::id, kernel_mutex, read_view_struct::low_limit_id, read_view_struct::low_limit_no, trx_sys_struct::max_trx_id, n, read_view_struct::n_trx_ids, trx_struct::no, read_view_create_low(), TRX_ACTIVE, TRX_PREPARED, trx_sys, read_view_struct::type, read_view_struct::undo_no, read_view_struct::up_limit_id, ut_ad, ut_dulint_cmp(), ut_dulint_create(), UT_LIST_ADD_FIRST, UT_LIST_GET_FIRST, UT_LIST_GET_LEN, UT_LIST_GET_NEXT, and VIEW_NORMAL.
Referenced by read_view_oldest_copy_or_open_new(), row_search_check_if_query_cache_permitted(), and trx_assign_read_view().
00237 : read view struct */ 00238 dulint cr_trx_id, /* in: trx_id of creating 00239 transaction, or (0, 0) used in 00240 purge */ 00241 mem_heap_t* heap) /* in: memory heap from which 00242 allocated */ 00243 { 00244 read_view_t* view; 00245 trx_t* trx; 00246 ulint n; 00247 #ifdef UNIV_SYNC_DEBUG 00248 ut_ad(mutex_own(&kernel_mutex)); 00249 #endif /* UNIV_SYNC_DEBUG */ 00250 view = read_view_create_low(UT_LIST_GET_LEN(trx_sys->trx_list), heap); 00251 00252 view->creator_trx_id = cr_trx_id; 00253 view->type = VIEW_NORMAL; 00254 view->undo_no = ut_dulint_create(0, 0); 00255 00256 /* No future transactions should be visible in the view */ 00257 00258 view->low_limit_no = trx_sys->max_trx_id; 00259 view->low_limit_id = view->low_limit_no; 00260 00261 view->can_be_too_old = FALSE; 00262 00263 n = 0; 00264 trx = UT_LIST_GET_FIRST(trx_sys->trx_list); 00265 00266 /* No active transaction should be visible, except cr_trx */ 00267 00268 while (trx) { 00269 if (ut_dulint_cmp(trx->id, cr_trx_id) != 0 00270 && (trx->conc_state == TRX_ACTIVE 00271 || trx->conc_state == TRX_PREPARED)) { 00272 00273 read_view_set_nth_trx_id(view, n, trx->id); 00274 00275 n++; 00276 00277 /* NOTE that a transaction whose trx number is < 00278 trx_sys->max_trx_id can still be active, if it is 00279 in the middle of its commit! Note that when a 00280 transaction starts, we initialize trx->no to 00281 ut_dulint_max. */ 00282 00283 if (ut_dulint_cmp(view->low_limit_no, trx->no) > 0) { 00284 00285 view->low_limit_no = trx->no; 00286 } 00287 } 00288 00289 trx = UT_LIST_GET_NEXT(trx_list, trx); 00290 } 00291 00292 view->n_trx_ids = n; 00293 00294 if (n > 0) { 00295 /* The last active transaction has the smallest id: */ 00296 view->up_limit_id = read_view_get_nth_trx_id(view, n - 1); 00297 } else { 00298 view->up_limit_id = view->low_limit_id; 00299 } 00300 00301 00302 UT_LIST_ADD_FIRST(view_list, trx_sys->view_list, view); 00303 00304 return(view); 00305 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void read_view_print | ( | read_view_t * | view | ) |
Definition at line 348 of file read0read.c.
References read_view_struct::low_limit_id, read_view_struct::low_limit_no, read_view_struct::n_trx_ids, read_view_struct::type, read_view_struct::undo_no, read_view_struct::up_limit_id, ut_dulint_get_high(), ut_dulint_get_low(), and VIEW_HIGH_GRANULARITY.
Referenced by trx_purge_sys_print().
00350 : read view */ 00351 { 00352 ulint n_ids; 00353 ulint i; 00354 00355 if (view->type == VIEW_HIGH_GRANULARITY) { 00356 fprintf(stderr, 00357 "High-granularity read view undo_n:o %lu %lu\n", 00358 (ulong) ut_dulint_get_high(view->undo_no), 00359 (ulong) ut_dulint_get_low(view->undo_no)); 00360 } else { 00361 fprintf(stderr, "Normal read view\n"); 00362 } 00363 00364 fprintf(stderr, "Read view low limit trx n:o %lu %lu\n", 00365 (ulong) ut_dulint_get_high(view->low_limit_no), 00366 (ulong) ut_dulint_get_low(view->low_limit_no)); 00367 00368 fprintf(stderr, "Read view up limit trx id %lu %lu\n", 00369 (ulong) ut_dulint_get_high(view->up_limit_id), 00370 (ulong) ut_dulint_get_low(view->up_limit_id)); 00371 00372 fprintf(stderr, "Read view low limit trx id %lu %lu\n", 00373 (ulong) ut_dulint_get_high(view->low_limit_id), 00374 (ulong) ut_dulint_get_low(view->low_limit_id)); 00375 00376 fprintf(stderr, "Read view individually stored trx ids:\n"); 00377 00378 n_ids = view->n_trx_ids; 00379 00380 for (i = 0; i < n_ids; i++) { 00381 fprintf(stderr, "Read view trx id %lu %lu\n", 00382 (ulong) ut_dulint_get_high(read_view_get_nth_trx_id(view, i)), 00383 (ulong) ut_dulint_get_low(read_view_get_nth_trx_id(view, i))); 00384 } 00385 }
Here is the call graph for this function:

Here is the caller graph for this function:

| UNIV_INLINE ibool read_view_sees_trx_id | ( | read_view_t * | view, | |
| dulint | trx_id | |||
| ) |
Referenced by lock_clust_rec_cons_read_sees(), row_vers_build_for_consistent_read(), and trx_purge_update_undo_must_exist().
Here is the caller graph for this function:

1.4.7

