~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/row/row0sel.c

Merge Stewart - Update innobase plugin to be based on innodb 1.1.4 from MySQL 5.5.8 

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
        ulint   len;
105
105
        byte    buf[DICT_MAX_INDEX_COL_LEN];
106
106
 
 
107
        ut_a(clust_len >= BTR_EXTERN_FIELD_REF_SIZE);
 
108
 
 
109
        if (UNIV_UNLIKELY
 
110
            (!memcmp(clust_field + clust_len - BTR_EXTERN_FIELD_REF_SIZE,
 
111
                     field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE))) {
 
112
                /* The externally stored field was not written yet.
 
113
                This record should only be seen by
 
114
                recv_recovery_rollback_active() or any
 
115
                TRX_ISO_READ_UNCOMMITTED transactions. */
 
116
                return(FALSE);
 
117
        }
 
118
 
107
119
        len = btr_copy_externally_stored_field_prefix(buf, sizeof buf,
108
120
                                                      zip_size,
109
121
                                                      clust_field, clust_len);
2677
2689
        row_prebuilt_t* prebuilt,       /*!< in: prebuilt struct */
2678
2690
        const rec_t*    rec,            /*!< in: Innobase record in the index
2679
2691
                                        which was described in prebuilt's
2680
 
                                        template; must be protected by
2681
 
                                        a page latch */
 
2692
                                        template, or in the clustered index;
 
2693
                                        must be protected by a page latch */
 
2694
        ibool           rec_clust,      /*!< in: TRUE if rec is in the
 
2695
                                        clustered index instead of
 
2696
                                        prebuilt->index */
2682
2697
        const ulint*    offsets)        /*!< in: array returned by
2683
 
                                        rec_get_offsets() */
 
2698
                                        rec_get_offsets(rec) */
2684
2699
{
2685
 
        mysql_row_templ_t*      templ;
2686
 
        mem_heap_t*             extern_field_heap       = NULL;
2687
 
        mem_heap_t*             heap;
2688
 
        const byte*             data;
2689
 
        ulint                   len;
2690
 
        ulint                   i;
 
2700
        mem_heap_t*     extern_field_heap       = NULL;
 
2701
        mem_heap_t*     heap;
 
2702
        ulint           i;
2691
2703
 
2692
2704
        ut_ad(prebuilt->mysql_template);
2693
2705
        ut_ad(prebuilt->default_rec);
2694
2706
        ut_ad(rec_offs_validate(rec, NULL, offsets));
 
2707
        ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
2695
2708
 
2696
2709
        if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) {
2697
2710
                mem_heap_free(prebuilt->blob_heap);
2700
2713
 
2701
2714
        for (i = 0; i < prebuilt->n_template ; i++) {
2702
2715
 
2703
 
                templ = prebuilt->mysql_template + i;
2704
 
 
2705
 
                if (UNIV_UNLIKELY(rec_offs_nth_extern(offsets,
2706
 
                                                      templ->rec_field_no))) {
 
2716
                const mysql_row_templ_t*templ = prebuilt->mysql_template + i;
 
2717
                const byte*             data;
 
2718
                ulint                   len;
 
2719
                ulint                   field_no;
 
2720
 
 
2721
                field_no = rec_clust
 
2722
                        ? templ->clust_rec_field_no : templ->rec_field_no;
 
2723
 
 
2724
                if (UNIV_UNLIKELY(rec_offs_nth_extern(offsets, field_no))) {
2707
2725
 
2708
2726
                        /* Copy an externally stored field to the temporary
2709
2727
                        heap */
2731
2749
                        data = btr_rec_copy_externally_stored_field(
2732
2750
                                rec, offsets,
2733
2751
                                dict_table_zip_size(prebuilt->table),
2734
 
                                templ->rec_field_no, &len, heap);
 
2752
                                field_no, &len, heap);
2735
2753
 
2736
2754
                        if (UNIV_UNLIKELY(!data)) {
2737
2755
                                /* The externally stored field
2767
2785
                } else {
2768
2786
                        /* Field is stored in the row. */
2769
2787
 
2770
 
                        data = rec_get_nth_field(rec, offsets,
2771
 
                                                 templ->rec_field_no, &len);
 
2788
                        data = rec_get_nth_field(rec, offsets, field_no, &len);
2772
2789
 
2773
2790
                        if (UNIV_UNLIKELY(templ->type == DATA_BLOB)
2774
2791
                            && len != UNIV_SQL_NULL) {
3130
3147
        row_prebuilt_t* prebuilt)       /*!< in: prebuilt struct */
3131
3148
{
3132
3149
        ulint                   i;
3133
 
        mysql_row_templ_t*      templ;
 
3150
        const mysql_row_templ_t*templ;
3134
3151
        byte*                   cached_rec;
3135
3152
        ut_ad(prebuilt->n_fetch_cached > 0);
3136
3153
        ut_ad(prebuilt->mysql_prefix_len <= prebuilt->mysql_row_len);
3190
3207
row_sel_push_cache_row_for_mysql(
3191
3208
/*=============================*/
3192
3209
        row_prebuilt_t* prebuilt,       /*!< in: prebuilt struct */
3193
 
        const rec_t*    rec,            /*!< in: record to push; must
3194
 
                                        be protected by a page latch */
3195
 
        const ulint*    offsets)        /*!<in: rec_get_offsets() */
 
3210
        const rec_t*    rec,            /*!< in: record to push, in the index
 
3211
                                        which was described in prebuilt's
 
3212
                                        template, or in the clustered index;
 
3213
                                        must be protected by a page latch */
 
3214
        ibool           rec_clust,      /*!< in: TRUE if rec is in the
 
3215
                                        clustered index instead of
 
3216
                                        prebuilt->index */
 
3217
        const ulint*    offsets)        /*!< in: rec_get_offsets(rec) */
3196
3218
{
3197
3219
        byte*   buf;
3198
3220
        ulint   i;
3199
3221
 
3200
3222
        ut_ad(prebuilt->n_fetch_cached < MYSQL_FETCH_CACHE_SIZE);
3201
3223
        ut_ad(rec_offs_validate(rec, NULL, offsets));
 
3224
        ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
3202
3225
        ut_a(!prebuilt->templ_contains_blob);
3203
3226
 
3204
3227
        if (prebuilt->fetch_cache[0] == NULL) {
3227
3250
        if (UNIV_UNLIKELY(!row_sel_store_mysql_rec(
3228
3251
                                  prebuilt->fetch_cache[
3229
3252
                                          prebuilt->n_fetch_cached],
3230
 
                                  prebuilt, rec, offsets))) {
 
3253
                                  prebuilt, rec, rec_clust, offsets))) {
3231
3254
                return(FALSE);
3232
3255
        }
3233
3256
 
3604
3627
                                ut_ad(!rec_get_deleted_flag(rec, comp));
3605
3628
 
3606
3629
                                if (!row_sel_store_mysql_rec(buf, prebuilt,
3607
 
                                                             rec, offsets)) {
 
3630
                                                             rec, FALSE,
 
3631
                                                             offsets)) {
3608
3632
                                        /* Only fresh inserts may contain
3609
3633
                                        incomplete externally stored
3610
3634
                                        columns. Pretend that such
4252
4276
                        is necessary, because we can only get the undo
4253
4277
                        information via the clustered index record. */
4254
4278
 
4255
 
                        ut_ad(index != clust_index);
4256
4279
                        ut_ad(!dict_index_is_clust(index));
4257
4280
                        if (!lock_sec_rec_cons_read_sees(
4258
4281
                                    rec, trx->read_view)) {
4367
4390
                        goto next_rec;
4368
4391
                }
4369
4392
 
4370
 
                if (prebuilt->need_to_access_clustered) {
4371
 
 
4372
 
                        result_rec = clust_rec;
4373
 
 
4374
 
                        ut_ad(rec_offs_validate(result_rec, clust_index,
4375
 
                                                offsets));
4376
 
                } else {
4377
 
                        /* We used 'offsets' for the clust rec, recalculate
4378
 
                        them for 'rec' */
4379
 
                        offsets = rec_get_offsets(rec, index, offsets,
4380
 
                                                  ULINT_UNDEFINED, &heap);
4381
 
                        result_rec = rec;
4382
 
                }
4383
 
 
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. */
 
4393
                result_rec = clust_rec;
 
4394
                ut_ad(rec_offs_validate(result_rec, clust_index, offsets));
4387
4395
        } else {
4388
4396
                result_rec = rec;
4389
 
                ut_ad(!rec_get_deleted_flag(rec, comp));
4390
4397
        }
4391
4398
 
4392
4399
        /* We found a qualifying record 'result_rec'. At this point,
4395
4402
        ut_ad(rec_offs_validate(result_rec,
4396
4403
                                result_rec != rec ? clust_index : index,
4397
4404
                                offsets));
 
4405
        ut_ad(!rec_get_deleted_flag(result_rec, comp));
4398
4406
 
4399
4407
        /* At this point, the clustered index record is protected
4400
4408
        by a page latch that was acquired when pcur was positioned.
4418
4426
                cursor. */
4419
4427
 
4420
4428
                if (!row_sel_push_cache_row_for_mysql(prebuilt, result_rec,
 
4429
                                                      result_rec != rec,
4421
4430
                                                      offsets)) {
4422
4431
                        /* Only fresh inserts may contain incomplete
4423
4432
                        externally stored columns. Pretend that such
4435
4444
 
4436
4445
                goto next_rec;
4437
4446
        } else {
4438
 
                if (prebuilt->template_type == ROW_MYSQL_DUMMY_TEMPLATE) {
 
4447
                if (UNIV_UNLIKELY
 
4448
                    (prebuilt->template_type == ROW_MYSQL_DUMMY_TEMPLATE)) {
 
4449
                        /* CHECK TABLE: fetch the row */
 
4450
 
 
4451
                        if (result_rec != rec
 
4452
                            && !prebuilt->need_to_access_clustered) {
 
4453
                                /* We used 'offsets' for the clust
 
4454
                                rec, recalculate them for 'rec' */
 
4455
                                offsets = rec_get_offsets(rec, index, offsets,
 
4456
                                                          ULINT_UNDEFINED,
 
4457
                                                          &heap);
 
4458
                                result_rec = rec;
 
4459
                        }
 
4460
 
4439
4461
                        memcpy(buf + 4, result_rec
4440
4462
                               - rec_offs_extra_size(offsets),
4441
4463
                               rec_offs_size(offsets));
4442
4464
                        mach_write_to_4(buf,
4443
4465
                                        rec_offs_extra_size(offsets) + 4);
4444
4466
                } else {
4445
 
                        if (!row_sel_store_mysql_rec(buf, prebuilt,
4446
 
                                                     result_rec, offsets)) {
 
4467
                        /* Returning a row to MySQL */
 
4468
 
 
4469
                        if (!row_sel_store_mysql_rec(buf, prebuilt, result_rec,
 
4470
                                                     result_rec != rec,
 
4471
                                                     offsets)) {
4447
4472
                                /* Only fresh inserts may contain
4448
4473
                                incomplete externally stored
4449
4474
                                columns. Pretend that such records do