~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/rem/rem0rec.c

  • Committer: Brian Aker
  • Date: 2010-10-06 18:16:00 UTC
  • mto: (1818.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1819.
  • Revision ID: brian@tangent.org-20101006181600-q7zuzw31zlq030ra
Convert sql_string to use size_t (this should clean up ICC warnings).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
212
212
                        const dict_col_t*       col
213
213
                                = dict_field_get_col(field);
214
214
                        len = *lens--;
215
 
                        /* If the maximum length of the field is up
216
 
                        to 255 bytes, the actual length is always
217
 
                        stored in one byte. If the maximum length is
218
 
                        more than 255 bytes, the actual length is
219
 
                        stored in one byte for 0..127.  The length
220
 
                        will be encoded in two bytes when it is 128 or
221
 
                        more, or when the field is stored externally. */
222
215
                        if (UNIV_UNLIKELY(col->len > 255)
223
216
                            || UNIV_UNLIKELY(col->mtype == DATA_BLOB)) {
224
217
                                if (len & 0x80) {
301
294
                        const dict_col_t*       col
302
295
                                = dict_field_get_col(field);
303
296
                        len = *lens--;
304
 
                        /* If the maximum length of the field is up
305
 
                        to 255 bytes, the actual length is always
306
 
                        stored in one byte. If the maximum length is
307
 
                        more than 255 bytes, the actual length is
308
 
                        stored in one byte for 0..127.  The length
309
 
                        will be encoded in two bytes when it is 128 or
310
 
                        more, or when the field is stored externally. */
311
297
                        if (UNIV_UNLIKELY(col->len > 255)
312
298
                            || UNIV_UNLIKELY(col->mtype
313
299
                                             == DATA_BLOB)) {
439
425
                                const dict_col_t*       col
440
426
                                        = dict_field_get_col(field);
441
427
                                len = *lens--;
442
 
                                /* If the maximum length of the field
443
 
                                is up to 255 bytes, the actual length
444
 
                                is always stored in one byte. If the
445
 
                                maximum length is more than 255 bytes,
446
 
                                the actual length is stored in one
447
 
                                byte for 0..127.  The length will be
448
 
                                encoded in two bytes when it is 128 or
449
 
                                more, or when the field is stored
450
 
                                externally. */
451
428
                                if (UNIV_UNLIKELY(col->len > 255)
452
429
                                    || UNIV_UNLIKELY(col->mtype
453
430
                                                     == DATA_BLOB)) {
578
555
                                                     MEM_HEAP_DYNAMIC,
579
556
                                                     file, line);
580
557
                }
581
 
                offsets = static_cast<unsigned long *>(mem_heap_alloc(*heap, size * sizeof(ulint)));
 
558
                offsets = mem_heap_alloc(*heap, size * sizeof(ulint));
582
559
                rec_offs_set_n_alloc(offsets, size);
583
560
        }
584
561
 
670
647
                        const dict_col_t*       col
671
648
                                = dict_field_get_col(field);
672
649
                        len = *lens++;
673
 
                        /* If the maximum length of the field is up
674
 
                        to 255 bytes, the actual length is always
675
 
                        stored in one byte. If the maximum length is
676
 
                        more than 255 bytes, the actual length is
677
 
                        stored in one byte for 0..127.  The length
678
 
                        will be encoded in two bytes when it is 128 or
679
 
                        more, or when the field is stored externally. */
680
650
                        if (UNIV_UNLIKELY(col->len > 255)
681
651
                            || UNIV_UNLIKELY(col->mtype == DATA_BLOB)) {
682
652
                                if (len & 0x80) {
725
695
        ulint   os;
726
696
        ulint   next_os;
727
697
 
728
 
        ut_ad(len);
729
 
        ut_a(rec);
730
 
        ut_a(n < rec_get_n_fields_old(rec));
 
698
        ut_ad(rec && len);
 
699
        ut_ad(n < rec_get_n_fields_old(rec));
 
700
 
 
701
        if (UNIV_UNLIKELY(n > REC_MAX_N_FIELDS)) {
 
702
                fprintf(stderr, "Error: trying to access field %lu in rec\n",
 
703
                        (ulong) n);
 
704
                ut_error;
 
705
        }
 
706
 
 
707
        if (UNIV_UNLIKELY(rec == NULL)) {
 
708
                fputs("Error: rec is NULL pointer\n", stderr);
 
709
                ut_error;
 
710
        }
731
711
 
732
712
        if (rec_get_1byte_offs_flag(rec)) {
733
713
                os = rec_1_get_field_start_offs(rec, n);
811
791
 
812
792
                ut_ad(len <= col->len || col->mtype == DATA_BLOB);
813
793
 
814
 
                /* If the maximum length of a variable-length field
815
 
                is up to 255 bytes, the actual length is always stored
816
 
                in one byte. If the maximum length is more than 255
817
 
                bytes, the actual length is stored in one byte for
818
 
                0..127.  The length will be encoded in two bytes when
819
 
                it is 128 or more, or when the field is stored externally. */
820
 
 
821
794
                if (field->fixed_len) {
822
795
                        ut_ad(len == field->fixed_len);
823
796
                        /* dict_index_add_col() should guarantee this */
824
797
                        ut_ad(!field->prefix_len
825
798
                              || field->fixed_len == field->prefix_len);
826
799
                } else if (dfield_is_ext(&fields[i])) {
827
 
                        ut_ad(col->len >= 256 || col->mtype == DATA_BLOB);
828
800
                        extra_size += 2;
829
801
                } else if (len < 128
830
802
                           || (col->len < 256 && col->mtype != DATA_BLOB)) {
1124
1096
        /* Store the data and the offsets */
1125
1097
 
1126
1098
        for (i = 0, field = fields; i < n_fields; i++, field++) {
1127
 
                const dict_field_t*     ifield;
1128
 
 
1129
1099
                type = dfield_get_type(field);
1130
1100
                len = dfield_get_len(field);
1131
1101
 
1160
1130
                /* only nullable fields can be null */
1161
1131
                ut_ad(!dfield_is_null(field));
1162
1132
 
1163
 
                ifield = dict_index_get_nth_field(index, i);
1164
 
                fixed_len = ifield->fixed_len;
1165
 
                /* If the maximum length of a variable-length field
1166
 
                is up to 255 bytes, the actual length is always stored
1167
 
                in one byte. If the maximum length is more than 255
1168
 
                bytes, the actual length is stored in one byte for
1169
 
                0..127.  The length will be encoded in two bytes when
1170
 
                it is 128 or more, or when the field is stored externally. */
 
1133
                fixed_len = dict_index_get_nth_field(index, i)->fixed_len;
 
1134
 
1171
1135
                if (fixed_len) {
1172
1136
                        ut_ad(len == fixed_len);
1173
1137
                        ut_ad(!dfield_is_ext(field));
1174
1138
                } else if (dfield_is_ext(field)) {
1175
 
                        ut_ad(ifield->col->len >= 256
1176
 
                              || ifield->col->mtype == DATA_BLOB);
1177
1139
                        ut_ad(len <= REC_MAX_INDEX_COL_LEN
1178
1140
                              + BTR_EXTERN_FIELD_REF_SIZE);
1179
1141
                        *lens-- = (byte) (len >> 8) | 0xc0;
1263
1225
                mem_heap_t*     heap    = NULL;
1264
1226
                ulint           offsets_[REC_OFFS_NORMAL_SIZE];
1265
1227
                const ulint*    offsets;
1266
 
                ulint           i;
1267
1228
                rec_offs_init(offsets_);
1268
1229
 
1269
1230
                offsets = rec_get_offsets(rec, index,
1270
1231
                                          offsets_, ULINT_UNDEFINED, &heap);
1271
1232
                ut_ad(rec_validate(rec, offsets));
1272
 
                ut_ad(dtuple_get_n_fields(dtuple)
1273
 
                      == rec_offs_n_fields(offsets));
1274
 
 
1275
 
                for (i = 0; i < rec_offs_n_fields(offsets); i++) {
1276
 
                        ut_ad(!dfield_is_ext(dtuple_get_nth_field(dtuple, i))
1277
 
                              == !rec_offs_nth_extern(offsets, i));
1278
 
                }
1279
 
 
1280
1233
                if (UNIV_LIKELY_NULL(heap)) {
1281
1234
                        mem_heap_free(heap);
1282
1235
                }
1362
1315
                        mem_free(*buf);
1363
1316
                }
1364
1317
 
1365
 
                *buf = static_cast<byte *>(mem_alloc2(prefix_len, buf_size));
 
1318
                *buf = mem_alloc2(prefix_len, buf_size);
1366
1319
        }
1367
1320
 
1368
1321
        ut_memcpy(*buf, rec - area_start, prefix_len);
1459
1412
                        prefix_len += field->fixed_len;
1460
1413
                } else {
1461
1414
                        ulint   len = *lens--;
1462
 
                        /* If the maximum length of the column is up
1463
 
                        to 255 bytes, the actual length is always
1464
 
                        stored in one byte. If the maximum length is
1465
 
                        more than 255 bytes, the actual length is
1466
 
                        stored in one byte for 0..127.  The length
1467
 
                        will be encoded in two bytes when it is 128 or
1468
 
                        more, or when the column is stored externally. */
1469
1415
                        if (col->len > 255 || col->mtype == DATA_BLOB) {
1470
1416
                                if (len & 0x80) {
1471
1417
                                        /* 1exxxxxx */
1488
1434
                        mem_free(*buf);
1489
1435
                }
1490
1436
 
1491
 
                *buf = static_cast<byte *>(mem_alloc2(prefix_len, buf_size));
 
1437
                *buf = mem_alloc2(prefix_len, buf_size);
1492
1438
        }
1493
1439
 
1494
1440
        memcpy(*buf, lens + 1, prefix_len);
1749
1695
void
1750
1696
rec_print(
1751
1697
/*======*/
1752
 
        FILE*                   file,   /*!< in: file where to print */
1753
 
        const rec_t*            rec,    /*!< in: physical record */
1754
 
        const dict_index_t*     index)  /*!< in: record descriptor */
 
1698
        FILE*           file,   /*!< in: file where to print */
 
1699
        const rec_t*    rec,    /*!< in: physical record */
 
1700
        dict_index_t*   index)  /*!< in: record descriptor */
1755
1701
{
1756
1702
        ut_ad(index);
1757
1703