~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: lbieber
  • Date: 2010-10-05 22:23:12 UTC
  • mfrom: (1813.1.4 build)
  • Revision ID: lbieber@orisndriz08-20101005222312-weuq0ardk3gcryau
Merge Travis - 621861 - convert structs to classes
Merge Billy - 621331 - Replace use of stringstream with boost::lexical_cast
Merge Travis - 621861 = To change C structs to C++ classes in Drizzle
Merge Andrew - fix bug 653300 - Syntax error on inport of a SQL file produced by drizzledump

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
 
408
408
                        val = mach_read_from_4(data);
409
409
 
410
410
                        if (!(prtype & DATA_UNSIGNED)) {
411
 
                                val &= ~UNSIGNED_MASK;
 
411
                                val &= ~0x80000000;
412
412
                                fprintf(stderr, "%ld", (long) val);
413
413
                        } else {
414
414
                                fprintf(stderr, "%lu", (ulong) val);
417
417
 
418
418
                case 6:
419
419
                        id = mach_read_from_6(data);
420
 
                        fprintf(stderr, "%llu", (ullint) id);
 
420
                        fprintf(stderr, "{%lu %lu}",
 
421
                                ut_dulint_get_high(id),
 
422
                                ut_dulint_get_low(id));
421
423
                        break;
422
424
 
423
425
                case 7:
424
426
                        id = mach_read_from_7(data);
425
 
                        fprintf(stderr, "%llu", (ullint) id);
 
427
                        fprintf(stderr, "{%lu %lu}",
 
428
                                ut_dulint_get_high(id),
 
429
                                ut_dulint_get_low(id));
426
430
                        break;
427
431
                case 8:
428
432
                        id = mach_read_from_8(data);
429
 
                        fprintf(stderr, "%llu", (ullint) id);
 
433
                        fprintf(stderr, "{%lu %lu}",
 
434
                                ut_dulint_get_high(id),
 
435
                                ut_dulint_get_low(id));
430
436
                        break;
431
437
                default:
432
438
                        goto print_hex;
438
444
                case DATA_TRX_ID:
439
445
                        id = mach_read_from_6(data);
440
446
 
441
 
                        fprintf(stderr, "trx_id " TRX_ID_FMT, id);
 
447
                        fprintf(stderr, "trx_id " TRX_ID_FMT,
 
448
                                TRX_ID_PREP_PRINTF(id));
442
449
                        break;
443
450
 
444
451
                case DATA_ROLL_PTR:
445
452
                        id = mach_read_from_7(data);
446
453
 
447
 
                        fprintf(stderr, "roll_ptr " TRX_ID_FMT, id);
 
454
                        fprintf(stderr, "roll_ptr {%lu %lu}",
 
455
                                ut_dulint_get_high(id), ut_dulint_get_low(id));
448
456
                        break;
449
457
 
450
458
                case DATA_ROW_ID:
451
459
                        id = mach_read_from_6(data);
452
460
 
453
 
                        fprintf(stderr, "row_id " TRX_ID_FMT, id);
 
461
                        fprintf(stderr, "row_id {%lu %lu}",
 
462
                                ut_dulint_get_high(id), ut_dulint_get_low(id));
454
463
                        break;
455
464
 
456
465
                default:
457
 
                        id = mach_ull_read_compressed(data);
 
466
                        id = mach_dulint_read_compressed(data);
458
467
 
459
 
                        fprintf(stderr, "mix_id " TRX_ID_FMT, id);
 
468
                        fprintf(stderr, "mix_id {%lu %lu}",
 
469
                                ut_dulint_get_high(id), ut_dulint_get_low(id));
460
470
                }
461
471
                break;
462
472
 
484
494
                        break;
485
495
                }
486
496
 
487
 
                data = static_cast<const byte *>(dfield_get_data(dfield));
 
497
                data = dfield_get_data(dfield);
488
498
                /* fall through */
489
499
 
490
500
        case DATA_BINARY:
607
617
        heap = mem_heap_create(size + dtuple_get_n_fields(entry)
608
618
                               * sizeof(big_rec_field_t) + 1000);
609
619
 
610
 
        vector = static_cast<big_rec_t *>(mem_heap_alloc(heap, sizeof(big_rec_t)));
 
620
        vector = mem_heap_alloc(heap, sizeof(big_rec_t));
611
621
 
612
622
        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)));
 
623
        vector->fields = mem_heap_alloc(heap, dtuple_get_n_fields(entry)
 
624
                                        * sizeof(big_rec_field_t));
615
625
 
616
626
        /* Decide which fields to shorten: the algorithm is to look for
617
627
        a variable-length field that yields the biggest savings when
656
666
                                goto skip_field;
657
667
                        }
658
668
 
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
669
                        longest_i = i;
705
670
                        longest = savings;
706
671
 
732
697
                b->data = (char*) dfield_get_data(dfield) + local_prefix_len;
733
698
 
734
699
                /* Allocate the locally stored part of the column. */
735
 
                data = static_cast<unsigned char *>(mem_heap_alloc(heap, local_len));
 
700
                data = mem_heap_alloc(heap, local_len);
736
701
 
737
702
                /* Copy the local prefix. */
738
703
                memcpy(data, dfield_get_data(dfield), local_prefix_len);
767
732
void
768
733
dtuple_convert_back_big_rec(
769
734
/*========================*/
770
 
        dict_index_t*   /*index __attribute__((unused))*/,      /*!< in: index */
 
735
        dict_index_t*   index __attribute__((unused)),  /*!< in: index */
771
736
        dtuple_t*       entry,  /*!< in: entry whose data was put to vector */
772
737
        big_rec_t*      vector) /*!< in, own: big rec vector; it is
773
738
                                freed in this function */