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)));
2696
2697
if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) {
2697
2698
mem_heap_free(prebuilt->blob_heap);
2698
2699
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);
2701
2708
for (i = 0; i < prebuilt->n_template ; i++) {
2703
2710
templ = prebuilt->mysql_template + i;
3601
3607
row_sel_try_search_shortcut_for_mysql().
3602
3608
The latch will not be released until
3603
3609
mtr_commit(&mtr). */
3604
ut_ad(!rec_get_deleted_flag(rec, comp));
3606
3611
if (!row_sel_store_mysql_rec(buf, prebuilt,
3607
3612
rec, offsets)) {
3718
3723
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 */
3758
3725
if (UNIV_LIKELY(direction != 0)) {
3759
3726
ibool need_to_process = sel_restore_position_for_mysql(
3760
3727
&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;
3834
3837
/*-------------------------------------------------------------*/
3835
3838
/* PHASE 4: Look for matching records in a loop */
4246
4249
rec = old_vers;
4251
} else if (!lock_sec_rec_cons_read_sees(rec, trx->read_view)) {
4249
4252
/* We are looking into a non-clustered index,
4250
4253
and to get the right version of the record we
4251
4254
have to look also into the clustered index: this
4380
4379
ULINT_UNDEFINED, &heap);
4381
4380
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. */
4388
4383
result_rec = rec;
4389
ut_ad(!rec_get_deleted_flag(rec, comp));
4392
4386
/* We found a qualifying record 'result_rec'. At this point,
4581
4574
thr->lock_state = QUE_THR_LOCK_NOLOCK;
4582
4575
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;
4592
4577
sel_restore_position_for_mysql(&same_user_rec,
4593
4578
BTR_SEARCH_LEAF, pcur,
4594
4579
moves_up, &mtr);