~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Lee Bieber
  • Date: 2010-12-03 01:16:19 UTC
  • mfrom: (1819.9.81 update-innobase)
  • Revision ID: kalebral@gmail.com-20101203011619-n6v584rijwdet05b
Merge Stewart - update Innobase plugin based on InnoDB 1.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
/*========================*/
89
89
        ulint           mtype,          /*!< in: main type */
90
90
        ulint           prtype,         /*!< in: precise type */
91
 
        ulint           mbminlen,       /*!< in: minimum length of a
92
 
                                        multi-byte character */
93
 
        ulint           mbmaxlen,       /*!< in: maximum length of a
94
 
                                        multi-byte character */
 
91
        ulint           mbminmaxlen,    /*!< in: minimum and maximum length of
 
92
                                        a multi-byte character */
95
93
        const byte*     clust_field,    /*!< in: the locally stored part of
96
94
                                        the clustered index column, including
97
95
                                        the BLOB pointer; the clustered
119
117
                return(FALSE);
120
118
        }
121
119
 
122
 
        len = dtype_get_at_most_n_mbchars(prtype, mbminlen, mbmaxlen,
 
120
        len = dtype_get_at_most_n_mbchars(prtype, mbminmaxlen,
123
121
                                          sec_len, len, (const char*) buf);
124
122
 
125
123
        return(!cmp_data_data(mtype, prtype, buf, len, sec_field, sec_len));
202
200
                        }
203
201
 
204
202
                        len = dtype_get_at_most_n_mbchars(
205
 
                                col->prtype, col->mbminlen, col->mbmaxlen,
 
203
                                col->prtype, col->mbminmaxlen,
206
204
                                ifield->prefix_len, len, (char*) clust_field);
207
205
 
208
206
                        if (rec_offs_nth_extern(clust_offs, clust_pos)
209
207
                            && len < sec_len) {
210
208
                                if (!row_sel_sec_rec_is_for_blob(
211
209
                                            col->mtype, col->prtype,
212
 
                                            col->mbminlen, col->mbmaxlen,
 
210
                                            col->mbminmaxlen,
213
211
                                            clust_field, clust_len,
214
212
                                            sec_field, sec_len,
215
213
                                            dict_table_zip_size(
1731
1729
                                            &mtr);
1732
1730
                mtr_has_extra_clust_latch = TRUE;
1733
1731
 
1734
 
                if (err != DB_SUCCESS) {
1735
 
 
 
1732
                switch (err) {
 
1733
                case DB_SUCCESS_LOCKED_REC:
 
1734
                        err = DB_SUCCESS;
 
1735
                case DB_SUCCESS:
 
1736
                        break;
 
1737
                default:
1736
1738
                        goto lock_wait_or_error;
1737
1739
                }
1738
1740
 
1917
1919
                        thr->run_node = que_node_get_parent(node);
1918
1920
                }
1919
1921
 
 
1922
                err = DB_SUCCESS;
1920
1923
                goto func_exit;
1921
1924
        }
1922
1925
 
2074
2077
                        /* Reset the aggregate total values */
2075
2078
                        sel_reset_aggregate_vals(node);
2076
2079
                }
 
2080
 
 
2081
                err = DB_SUCCESS;
2077
2082
        }
2078
2083
 
2079
2084
        err = row_sel(node, thr);
2527
2532
        ulint           len)    /*!< in: length of the data */
2528
2533
{
2529
2534
        byte*   ptr;
2530
 
        byte*   field_end;
2531
 
        byte*   pad_ptr;
2532
2535
 
2533
2536
        ut_ad(len != UNIV_SQL_NULL);
2534
2537
        UNIV_MEM_ASSERT_RW(data, len);
2535
2538
 
2536
2539
        switch (templ->type) {
 
2540
                const byte*     field_end;
 
2541
                byte*           pad;
2537
2542
        case DATA_INT:
2538
2543
                /* Convert integer data from Innobase to a little-endian
2539
2544
                format, sign bit restored to normal */
2577
2582
                unused end of a >= 5.0.3 true VARCHAR column, just in case
2578
2583
                MySQL expects its contents to be deterministic. */
2579
2584
 
2580
 
                pad_ptr = dest + len;
 
2585
                pad = dest + len;
2581
2586
 
2582
2587
                ut_ad(templ->mbminlen <= templ->mbmaxlen);
2583
2588
 
2584
 
                /* We handle UCS2 charset strings differently. */
2585
 
                if (templ->mbminlen == 2) {
2586
 
                        /* A space char is two bytes, 0x0020 in UCS2 */
 
2589
                /* We treat some Unicode charset strings specially. */
 
2590
                switch (templ->mbminlen) {
 
2591
                case 4:
 
2592
                        /* InnoDB should never have stripped partial
 
2593
                        UTF-32 characters. */
 
2594
                        ut_a(!(len & 3));
 
2595
                        break;
 
2596
                case 2:
 
2597
                        /* A space char is two bytes,
 
2598
                        0x0020 in UCS2 and UTF-16 */
2587
2599
 
2588
 
                        if (len & 1) {
 
2600
                        if (UNIV_UNLIKELY(len & 1)) {
2589
2601
                                /* A 0x20 has been stripped from the column.
2590
2602
                                Pad it back. */
2591
2603
 
2592
 
                                if (pad_ptr < field_end) {
2593
 
                                        *pad_ptr = 0x20;
2594
 
                                        pad_ptr++;
 
2604
                                if (pad < field_end) {
 
2605
                                        *pad++ = 0x20;
2595
2606
                                }
2596
2607
                        }
2597
 
 
2598
 
                        /* Pad the rest of the string with 0x0020 */
2599
 
 
2600
 
                        while (pad_ptr < field_end) {
2601
 
                                *pad_ptr = 0x00;
2602
 
                                pad_ptr++;
2603
 
                                *pad_ptr = 0x20;
2604
 
                                pad_ptr++;
2605
 
                        }
2606
 
                } else {
2607
 
                        ut_ad(templ->mbminlen == 1);
2608
 
                        /* space=0x20 */
2609
 
 
2610
 
                        memset(pad_ptr, 0x20, field_end - pad_ptr);
2611
2608
                }
 
2609
 
 
2610
                row_mysql_pad_col(templ->mbminlen, pad, field_end - pad);
2612
2611
                break;
2613
2612
 
2614
2613
        case DATA_BLOB:
2633
2632
                      || !(templ->mysql_col_len % templ->mbmaxlen));
2634
2633
                ut_ad(len * templ->mbmaxlen >= templ->mysql_col_len);
2635
2634
 
2636
 
                if (templ->mbminlen != templ->mbmaxlen) {
 
2635
                if (templ->mbminlen == 1 && templ->mbmaxlen != 1) {
2637
2636
                        /* Pad with spaces. This undoes the stripping
2638
 
                        done in row0mysql.ic, function
 
2637
                        done in row0mysql.c, function
2639
2638
                        row_mysql_store_col_in_innobase_format(). */
2640
2639
 
2641
2640
                        memset(dest + len, 0x20, templ->mysql_col_len - len);
2756
2755
                                return(FALSE);
2757
2756
                        }
2758
2757
 
 
2758
                        if (UNIV_UNLIKELY(!data)) {
 
2759
                                /* The externally stored field
 
2760
                                was not written yet. This
 
2761
                                record should only be seen by
 
2762
                                recv_recovery_rollback_active()
 
2763
                                or any TRX_ISO_READ_UNCOMMITTED
 
2764
                                transactions. */
 
2765
 
 
2766
                                if (extern_field_heap) {
 
2767
                                        mem_heap_free(extern_field_heap);
 
2768
                                }
 
2769
 
 
2770
                                return(FALSE);
 
2771
                        }
 
2772
 
2759
2773
                        ut_a(len != UNIV_SQL_NULL);
2760
2774
                } else {
2761
2775
                        /* Field is stored in the row. */
4142
4156
                                clust_index, prebuilt, rec,
4143
4157
                                &offsets, &heap, &old_vers, &mtr);
4144
4158
 
4145
 
                        if (err != DB_SUCCESS) {
4146
 
 
 
4159
                        switch (err) {
 
4160
                        case DB_SUCCESS_LOCKED_REC:
 
4161
                                err = DB_SUCCESS;
 
4162
                        case DB_SUCCESS:
 
4163
                                break;
 
4164
                        default:
4147
4165
                                goto lock_wait_or_error;
4148
4166
                        }
4149
4167
 
4213
4231
                                        prebuilt, rec, &offsets, &heap,
4214
4232
                                        &old_vers, &mtr);
4215
4233
 
4216
 
                                if (err != DB_SUCCESS) {
4217
 
 
 
4234
                                switch (err) {
 
4235
                                case DB_SUCCESS_LOCKED_REC:
 
4236
                                case DB_SUCCESS:
 
4237
                                        break;
 
4238
                                default:
4218
4239
                                        goto lock_wait_or_error;
4219
4240
                                }
4220
4241
 
4671
4692
        IX type locks actually would require ret = FALSE. */
4672
4693
 
4673
4694
        if (UT_LIST_GET_LEN(table->locks) == 0
4674
 
            && ut_dulint_cmp(trx->id,
4675
 
                             table->query_cache_inv_trx_id) >= 0) {
 
4695
            && trx->id >= table->query_cache_inv_trx_id) {
4676
4696
 
4677
4697
                ret = TRUE;
4678
4698