~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/data/data0data.c

  • Committer: Brian Aker
  • Date: 2010-10-20 20:26:18 UTC
  • mfrom: (1859.2.13 refactor)
  • Revision ID: brian@tangent.org-20101020202618-9222n39lm329urv5
Merge for Brian 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1994, 2009, 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
306
306
/*=========*/
307
307
        const dfield_t* dfield) /*!< in: dfield */
308
308
{
 
309
        const byte*     data;
 
310
        ulint           len;
309
311
        ulint           i;
310
312
 
311
 
        ulint len = dfield_get_len(dfield);
312
 
        const byte *data = static_cast<const byte *>(dfield_get_data(dfield));
 
313
        len = dfield_get_len(dfield);
 
314
        data = dfield_get_data(dfield);
313
315
 
314
316
        if (dfield_is_null(dfield)) {
315
317
                fputs("NULL", stderr);
354
356
        ibool           print_also_hex;
355
357
 
356
358
        len = dfield_get_len(dfield);
357
 
        data = static_cast<const byte *>(dfield_get_data(dfield));
 
359
        data = dfield_get_data(dfield);
358
360
 
359
361
        if (dfield_is_null(dfield)) {
360
362
                fputs("NULL", stderr);
364
366
 
365
367
        prtype = dtype_get_prtype(dfield_get_type(dfield));
366
368
 
367
 
        ib_id_t id= 0;
368
 
        ulint val= 0;
369
 
        static const ulint UNSIGNED_MASK= 0x80000000;
370
 
 
371
369
        switch (dtype_get_mtype(dfield_get_type(dfield))) {
 
370
                dulint  id;
372
371
        case DATA_INT:
373
372
                switch (len) {
 
373
                        ulint   val;
374
374
                case 1:
375
375
                        val = mach_read_from_1(data);
376
376
 
407
407
                case 4:
408
408
                        val = mach_read_from_4(data);
409
409
 
 
410
                        static const ulint UNSIGNED_MASK= 0x80000000;
 
411
 
410
412
                        if (!(prtype & DATA_UNSIGNED)) {
411
413
                                val &= ~UNSIGNED_MASK;
412
414
                                fprintf(stderr, "%ld", (long) val);
417
419
 
418
420
                case 6:
419
421
                        id = mach_read_from_6(data);
420
 
                        fprintf(stderr, "%llu", (ullint) id);
 
422
                        fprintf(stderr, "{%lu %lu}",
 
423
                                ut_dulint_get_high(id),
 
424
                                ut_dulint_get_low(id));
421
425
                        break;
422
426
 
423
427
                case 7:
424
428
                        id = mach_read_from_7(data);
425
 
                        fprintf(stderr, "%llu", (ullint) id);
 
429
                        fprintf(stderr, "{%lu %lu}",
 
430
                                ut_dulint_get_high(id),
 
431
                                ut_dulint_get_low(id));
426
432
                        break;
427
433
                case 8:
428
434
                        id = mach_read_from_8(data);
429
 
                        fprintf(stderr, "%llu", (ullint) id);
 
435
                        fprintf(stderr, "{%lu %lu}",
 
436
                                ut_dulint_get_high(id),
 
437
                                ut_dulint_get_low(id));
430
438
                        break;
431
439
                default:
432
440
                        goto print_hex;
438
446
                case DATA_TRX_ID:
439
447
                        id = mach_read_from_6(data);
440
448
 
441
 
                        fprintf(stderr, "trx_id " TRX_ID_FMT, id);
 
449
                        fprintf(stderr, "trx_id " TRX_ID_FMT,
 
450
                                TRX_ID_PREP_PRINTF(id));
442
451
                        break;
443
452
 
444
453
                case DATA_ROLL_PTR:
445
454
                        id = mach_read_from_7(data);
446
455
 
447
 
                        fprintf(stderr, "roll_ptr " TRX_ID_FMT, id);
 
456
                        fprintf(stderr, "roll_ptr {%lu %lu}",
 
457
                                ut_dulint_get_high(id), ut_dulint_get_low(id));
448
458
                        break;
449
459
 
450
460
                case DATA_ROW_ID:
451
461
                        id = mach_read_from_6(data);
452
462
 
453
 
                        fprintf(stderr, "row_id " TRX_ID_FMT, id);
 
463
                        fprintf(stderr, "row_id {%lu %lu}",
 
464
                                ut_dulint_get_high(id), ut_dulint_get_low(id));
454
465
                        break;
455
466
 
456
467
                default:
457
 
                        id = mach_ull_read_compressed(data);
 
468
                        id = mach_dulint_read_compressed(data);
458
469
 
459
 
                        fprintf(stderr, "mix_id " TRX_ID_FMT, id);
 
470
                        fprintf(stderr, "mix_id {%lu %lu}",
 
471
                                ut_dulint_get_high(id), ut_dulint_get_low(id));
460
472
                }
461
473
                break;
462
474
 
484
496
                        break;
485
497
                }
486
498
 
487
 
                data = static_cast<const byte *>(dfield_get_data(dfield));
 
499
                data = dfield_get_data(dfield);
488
500
                /* fall through */
489
501
 
490
502
        case DATA_BINARY:
607
619
        heap = mem_heap_create(size + dtuple_get_n_fields(entry)
608
620
                               * sizeof(big_rec_field_t) + 1000);
609
621
 
610
 
        vector = static_cast<big_rec_t *>(mem_heap_alloc(heap, sizeof(big_rec_t)));
 
622
        vector = mem_heap_alloc(heap, sizeof(big_rec_t));
611
623
 
612
624
        vector->heap = heap;
613
 
        vector->fields = static_cast<big_rec_field_t *>(mem_heap_alloc(heap, dtuple_get_n_fields(entry)
614
 
                                        * sizeof(big_rec_field_t)));
 
625
        vector->fields = mem_heap_alloc(heap, dtuple_get_n_fields(entry)
 
626
                                        * sizeof(big_rec_field_t));
615
627
 
616
628
        /* Decide which fields to shorten: the algorithm is to look for
617
629
        a variable-length field that yields the biggest savings when
656
668
                                goto skip_field;
657
669
                        }
658
670
 
659
 
                        /* In DYNAMIC and COMPRESSED format, store
660
 
                        locally any non-BLOB columns whose maximum
661
 
                        length does not exceed 256 bytes.  This is
662
 
                        because there is no room for the "external
663
 
                        storage" flag when the maximum length is 255
664
 
                        bytes or less. This restriction trivially
665
 
                        holds in REDUNDANT and COMPACT format, because
666
 
                        there we always store locally columns whose
667
 
                        length is up to local_len == 788 bytes.
668
 
                        @see rec_init_offsets_comp_ordinary */
669
 
                        if (ifield->col->mtype != DATA_BLOB
670
 
                            && ifield->col->len < 256) {
671
 
                                goto skip_field;
672
 
                        }
673
 
 
674
 
                        /* In DYNAMIC and COMPRESSED format, store
675
 
                        locally any non-BLOB columns whose maximum
676
 
                        length does not exceed 256 bytes.  This is
677
 
                        because there is no room for the "external
678
 
                        storage" flag when the maximum length is 255
679
 
                        bytes or less. This restriction trivially
680
 
                        holds in REDUNDANT and COMPACT format, because
681
 
                        there we always store locally columns whose
682
 
                        length is up to local_len == 788 bytes.
683
 
                        @see rec_init_offsets_comp_ordinary */
684
 
                        if (ifield->col->mtype != DATA_BLOB
685
 
                            && ifield->col->len < 256) {
686
 
                                goto skip_field;
687
 
                        }
688
 
 
689
 
                        /* In DYNAMIC and COMPRESSED format, store
690
 
                        locally any non-BLOB columns whose maximum
691
 
                        length does not exceed 256 bytes.  This is
692
 
                        because there is no room for the "external
693
 
                        storage" flag when the maximum length is 255
694
 
                        bytes or less. This restriction trivially
695
 
                        holds in REDUNDANT and COMPACT format, because
696
 
                        there we always store locally columns whose
697
 
                        length is up to local_len == 788 bytes.
698
 
                        @see rec_init_offsets_comp_ordinary */
699
 
                        if (ifield->col->mtype != DATA_BLOB
700
 
                            && ifield->col->len < 256) {
701
 
                                goto skip_field;
702
 
                        }
703
 
 
704
671
                        longest_i = i;
705
672
                        longest = savings;
706
673
 
732
699
                b->data = (char*) dfield_get_data(dfield) + local_prefix_len;
733
700
 
734
701
                /* Allocate the locally stored part of the column. */
735
 
                data = static_cast<unsigned char *>(mem_heap_alloc(heap, local_len));
 
702
                data = mem_heap_alloc(heap, local_len);
736
703
 
737
704
                /* Copy the local prefix. */
738
705
                memcpy(data, dfield_get_data(dfield), local_prefix_len);
767
734
void
768
735
dtuple_convert_back_big_rec(
769
736
/*========================*/
770
 
        dict_index_t*   /*index __attribute__((unused))*/,      /*!< in: index */
 
737
        dict_index_t*   index __attribute__((unused)),  /*!< in: index */
771
738
        dtuple_t*       entry,  /*!< in: entry whose data was put to vector */
772
739
        big_rec_t*      vector) /*!< in, own: big rec vector; it is
773
740
                                freed in this function */