2692
2692
ut_ad(prebuilt->mysql_template);
2693
2693
ut_ad(prebuilt->default_rec);
2694
2694
ut_ad(rec_offs_validate(rec, NULL, offsets));
2695
ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
2697
2696
if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) {
2698
2697
mem_heap_free(prebuilt->blob_heap);
2699
2698
prebuilt->blob_heap = NULL;
2702
/* init null bytes with default values as they might be
2703
left uninitialized in some cases and these uninited bytes
2704
might be copied into mysql record buffer that leads to
2705
valgrind warnings */
2706
memcpy(mysql_rec, prebuilt->default_rec, prebuilt->null_bitmap_len);
2708
2701
for (i = 0; i < prebuilt->n_template ; i++) {
2710
2703
templ = prebuilt->mysql_template + i;
3607
3601
row_sel_try_search_shortcut_for_mysql().
3608
3602
The latch will not be released until
3609
3603
mtr_commit(&mtr). */
3604
ut_ad(!rec_get_deleted_flag(rec, comp));
3611
3606
if (!row_sel_store_mysql_rec(buf, prebuilt,
3612
3607
rec, offsets)) {
3723
3718
clust_index = dict_table_get_first_index(index->table);
3720
/* Do some start-of-statement preparations */
3722
if (!prebuilt->sql_stat_start) {
3723
/* No need to set an intention lock or assign a read view */
3725
if (trx->read_view == NULL
3726
&& prebuilt->select_lock_type == LOCK_NONE) {
3728
fputs("InnoDB: Error: MySQL is trying to"
3729
" perform a consistent read\n"
3730
"InnoDB: but the read view is not assigned!\n",
3732
trx_print(stderr, trx, 600);
3733
fputc('\n', stderr);
3736
} else if (prebuilt->select_lock_type == LOCK_NONE) {
3737
/* This is a consistent read */
3738
/* Assign a read view for the query */
3740
trx_assign_read_view(trx);
3741
prebuilt->sql_stat_start = FALSE;
3744
err = lock_table(0, index->table,
3745
prebuilt->select_lock_type == LOCK_S
3746
? LOCK_IS : LOCK_IX, thr);
3748
if (err != DB_SUCCESS) {
3750
table_lock_waited = TRUE;
3751
goto lock_table_wait;
3753
prebuilt->sql_stat_start = FALSE;
3756
/* Open or restore index cursor position */
3725
3758
if (UNIV_LIKELY(direction != 0)) {
3726
3759
ibool need_to_process = sel_restore_position_for_mysql(
3727
3760
&same_user_rec, BTR_SEARCH_LEAF,
3800
if (!prebuilt->sql_stat_start) {
3801
/* No need to set an intention lock or assign a read view */
3803
if (trx->read_view == NULL
3804
&& prebuilt->select_lock_type == LOCK_NONE) {
3806
fputs("InnoDB: Error: MySQL is trying to"
3807
" perform a consistent read\n"
3808
"InnoDB: but the read view is not assigned!\n",
3810
trx_print(stderr, trx, 600);
3811
fputc('\n', stderr);
3814
} else if (prebuilt->select_lock_type == LOCK_NONE) {
3815
/* This is a consistent read */
3816
/* Assign a read view for the query */
3818
trx_assign_read_view(trx);
3819
prebuilt->sql_stat_start = FALSE;
3822
if (prebuilt->select_lock_type == LOCK_S) {
3823
lock_mode = LOCK_IS;
3825
lock_mode = LOCK_IX;
3827
err = lock_table(0, index->table, lock_mode, thr);
3829
if (err != DB_SUCCESS) {
3831
goto lock_wait_or_error;
3833
prebuilt->sql_stat_start = FALSE;
3837
3834
/*-------------------------------------------------------------*/
3838
3835
/* PHASE 4: Look for matching records in a loop */
4249
4246
rec = old_vers;
4251
} else if (!lock_sec_rec_cons_read_sees(rec, trx->read_view)) {
4252
4249
/* We are looking into a non-clustered index,
4253
4250
and to get the right version of the record we
4254
4251
have to look also into the clustered index: this
4379
4380
ULINT_UNDEFINED, &heap);
4380
4381
result_rec = rec;
4384
/* result_rec can legitimately be delete-marked
4385
now that it has been established that it points to a
4386
clustered index record that exists in the read view. */
4383
4388
result_rec = rec;
4389
ut_ad(!rec_get_deleted_flag(rec, comp));
4386
4392
/* We found a qualifying record 'result_rec'. At this point,
4574
4581
thr->lock_state = QUE_THR_LOCK_NOLOCK;
4575
4582
mtr_start(&mtr);
4584
/* Table lock waited, go try to obtain table lock
4586
if (table_lock_waited) {
4587
table_lock_waited = FALSE;
4589
goto wait_table_again;
4577
4592
sel_restore_position_for_mysql(&same_user_rec,
4578
4593
BTR_SEARCH_LEAF, pcur,
4579
4594
moves_up, &mtr);