~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/trx/trx0rec.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) 1996, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 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
242
242
 
243
243
        /* Store first some general parameters to the undo log */
244
244
        *ptr++ = TRX_UNDO_INSERT_REC;
245
 
        ptr += mach_ull_write_much_compressed(ptr, trx->undo_no);
246
 
        ptr += mach_ull_write_much_compressed(ptr, index->table->id);
 
245
        ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no);
 
246
        ptr += mach_dulint_write_much_compressed(ptr, index->table->id);
247
247
        /*----------------------------------------*/
248
248
        /* Store then the fields required to uniquely determine the record
249
249
        to be inserted in the clustered index */
289
289
        ibool*          updated_extern, /*!< out: TRUE if we updated an
290
290
                                        externally stored fild */
291
291
        undo_no_t*      undo_no,        /*!< out: undo log record number */
292
 
        table_id_t*     table_id)       /*!< out: table id */
 
292
        dulint*         table_id)       /*!< out: table id */
293
293
{
294
294
        byte*           ptr;
295
295
        ulint           type_cmpl;
309
309
        *type = type_cmpl & (TRX_UNDO_CMPL_INFO_MULT - 1);
310
310
        *cmpl_info = type_cmpl / TRX_UNDO_CMPL_INFO_MULT;
311
311
 
312
 
        *undo_no = mach_ull_read_much_compressed(ptr);
313
 
        ptr += mach_ull_get_much_compressed_size(*undo_no);
 
312
        *undo_no = mach_dulint_read_much_compressed(ptr);
 
313
        ptr += mach_dulint_get_much_compressed_size(*undo_no);
314
314
 
315
 
        *table_id = mach_ull_read_much_compressed(ptr);
316
 
        ptr += mach_ull_get_much_compressed_size(*table_id);
 
315
        *table_id = mach_dulint_read_much_compressed(ptr);
 
316
        ptr += mach_dulint_get_much_compressed_size(*table_id);
317
317
 
318
318
        return(ptr);
319
319
}
350
350
 
351
351
                ut_ad(*orig_len >= BTR_EXTERN_FIELD_REF_SIZE);
352
352
                ut_ad(*len > *orig_len);
353
 
                /* @see dtuple_convert_big_rec() */
354
 
                ut_ad(*len >= BTR_EXTERN_FIELD_REF_SIZE * 2);
355
 
                /* we do not have access to index->table here
356
 
                ut_ad(dict_table_get_format(index->table) >= DICT_TF_FORMAT_ZIP
357
 
                      || *len >= REC_MAX_INDEX_COL_LEN
 
353
                ut_ad(*len >= REC_MAX_INDEX_COL_LEN
358
354
                      + BTR_EXTERN_FIELD_REF_SIZE);
359
 
                */
360
355
 
361
356
                *len += UNIV_EXTERN_STORAGE_FIELD;
362
357
                break;
598
593
        type_cmpl_ptr = ptr;
599
594
 
600
595
        *ptr++ = (byte) type_cmpl;
601
 
        ptr += mach_ull_write_much_compressed(ptr, trx->undo_no);
 
596
        ptr += mach_dulint_write_much_compressed(ptr, trx->undo_no);
602
597
 
603
 
        ptr += mach_ull_write_much_compressed(ptr, table->id);
 
598
        ptr += mach_dulint_write_much_compressed(ptr, table->id);
604
599
 
605
600
        /*----------------------------------------*/
606
601
        /* Store the state of the info bits */
620
615
        by some other trx as it must have committed by now for us to
621
616
        allow an over-write. */
622
617
        if (ignore_prefix) {
623
 
                ignore_prefix = (trx_id != trx->id);
 
618
                ignore_prefix = ut_dulint_cmp(trx_id, trx->id) != 0;
624
619
        }
625
 
        ptr += mach_ull_write_compressed(ptr, trx_id);
 
620
        ptr += mach_dulint_write_compressed(ptr, trx_id);
626
621
 
627
622
        field = rec_get_nth_field(rec, offsets,
628
623
                                  dict_index_get_sys_col_pos(
629
624
                                          index, DATA_ROLL_PTR), &flen);
630
625
        ut_ad(flen == DATA_ROLL_PTR_LEN);
631
626
 
632
 
        ptr += mach_ull_write_compressed(ptr, trx_read_roll_ptr(field));
 
627
        ptr += mach_dulint_write_compressed(ptr, trx_read_roll_ptr(field));
633
628
 
634
629
        /*----------------------------------------*/
635
630
        /* Store then the fields required to uniquely determine the
848
843
 
849
844
        /* Read the values of the system columns */
850
845
 
851
 
        *trx_id = mach_ull_read_compressed(ptr);
852
 
        ptr += mach_ull_get_compressed_size(*trx_id);
 
846
        *trx_id = mach_dulint_read_compressed(ptr);
 
847
        ptr += mach_dulint_get_compressed_size(*trx_id);
853
848
 
854
 
        *roll_ptr = mach_ull_read_compressed(ptr);
855
 
        ptr += mach_ull_get_compressed_size(*roll_ptr);
 
849
        *roll_ptr = mach_dulint_read_compressed(ptr);
 
850
        ptr += mach_dulint_get_compressed_size(*roll_ptr);
856
851
 
857
852
        return(ptr);
858
853
}
938
933
        /* Store first trx id and roll ptr to update vector */
939
934
 
940
935
        upd_field = upd_get_nth_field(update, n_fields);
941
 
        buf = static_cast<byte *>(mem_heap_alloc(heap, DATA_TRX_ID_LEN));
 
936
        buf = mem_heap_alloc(heap, DATA_TRX_ID_LEN);
942
937
        trx_write_trx_id(buf, trx_id);
943
938
 
944
939
        upd_field_set_field_no(upd_field,
947
942
        dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN);
948
943
 
949
944
        upd_field = upd_get_nth_field(update, n_fields + 1);
950
 
        buf = static_cast<byte *>(mem_heap_alloc(heap, DATA_ROLL_PTR_LEN));
 
945
        buf = mem_heap_alloc(heap, DATA_ROLL_PTR_LEN);
951
946
        trx_write_roll_ptr(buf, roll_ptr);
952
947
 
953
948
        upd_field_set_field_no(
982
977
                        fprintf(stderr, "\n"
983
978
                                "InnoDB: n_fields = %lu, i = %lu, ptr %p\n",
984
979
                                (ulong) n_fields, (ulong) i, ptr);
985
 
                        *upd = NULL;
986
980
                        return(NULL);
987
981
                }
988
982
 
1080
1074
                        /* If the prefix of this column is indexed,
1081
1075
                        ensure that enough prefix is stored in the
1082
1076
                        undo log record. */
1083
 
                        if (!ignore_prefix && col->ord_part) {
1084
 
                                ut_a(dfield_get_len(dfield)
1085
 
                                     >= 2 * BTR_EXTERN_FIELD_REF_SIZE);
1086
 
                                ut_a(dict_table_get_format(index->table)
1087
 
                                     >= DICT_TF_FORMAT_ZIP
1088
 
                                     || dfield_get_len(dfield)
1089
 
                                     >= REC_MAX_INDEX_COL_LEN
1090
 
                                     + BTR_EXTERN_FIELD_REF_SIZE);
1091
 
                        }
 
1077
                        ut_a(ignore_prefix
 
1078
                             || !col->ord_part
 
1079
                             || dfield_get_len(dfield)
 
1080
                             >= REC_MAX_INDEX_COL_LEN
 
1081
                             + BTR_EXTERN_FIELD_REF_SIZE);
1092
1082
                }
1093
1083
        }
1094
1084
 
1123
1113
trx_undo_parse_erase_page_end(
1124
1114
/*==========================*/
1125
1115
        byte*   ptr,    /*!< in: buffer */
1126
 
        byte*   /*end_ptr*/, /*!< in: buffer end */
 
1116
        byte*   end_ptr __attribute__((unused)), /*!< in: buffer end */
1127
1117
        page_t* page,   /*!< in: page or NULL */
1128
1118
        mtr_t*  mtr)    /*!< in: mtr or NULL */
1129
1119
{
1168
1158
                                        index, otherwise NULL */
1169
1159
        roll_ptr_t*     roll_ptr)       /*!< out: rollback pointer to the
1170
1160
                                        inserted undo log record,
1171
 
                                        0 if BTR_NO_UNDO_LOG
 
1161
                                        ut_dulint_zero if BTR_NO_UNDO_LOG
1172
1162
                                        flag was specified */
1173
1163
{
1174
1164
        trx_t*          trx;
1186
1176
 
1187
1177
        if (flags & BTR_NO_UNDO_LOG_FLAG) {
1188
1178
 
1189
 
                *roll_ptr = 0;
 
1179
                *roll_ptr = ut_dulint_zero;
1190
1180
 
1191
1181
                return(DB_SUCCESS);
1192
1182
        }
1284
1274
                        undo->top_undo_no = trx->undo_no;
1285
1275
                        undo->guess_block = undo_block;
1286
1276
 
1287
 
                        trx->undo_no++;
 
1277
                        UT_DULINT_INC(trx->undo_no);
1288
1278
 
1289
1279
                        mutex_exit(&trx->undo_mutex);
1290
1280
 
1343
1333
        ulint           rseg_id;
1344
1334
        ulint           page_no;
1345
1335
        ulint           offset;
1346
 
        const page_t*   undo_page;
 
1336
        page_t*         undo_page;
1347
1337
        trx_rseg_t*     rseg;
1348
1338
        ibool           is_insert;
1349
1339
        mtr_t           mtr;
1414
1404
/*========================*/
1415
1405
        const rec_t*    index_rec,/*!< in: clustered index record in the
1416
1406
                                index tree */
1417
 
        mtr_t*          /*index_mtr*/,
 
1407
        mtr_t*          index_mtr __attribute__((unused)),
1418
1408
                                /*!< in: mtr which contains the latch to
1419
1409
                                index_rec page and purge_view */
1420
1410
        const rec_t*    rec,    /*!< in: version of a clustered index record */
1433
1423
        trx_id_t        rec_trx_id;
1434
1424
        ulint           type;
1435
1425
        undo_no_t       undo_no;
1436
 
        table_id_t      table_id;
 
1426
        dulint          table_id;
1437
1427
        trx_id_t        trx_id;
1438
1428
        roll_ptr_t      roll_ptr;
1439
1429
        roll_ptr_t      old_roll_ptr;
1523
1513
                                             roll_ptr, info_bits,
1524
1514
                                             NULL, heap, &update);
1525
1515
 
1526
 
        if (UNIV_UNLIKELY(table_id != index->table->id)) {
 
1516
        if (ut_dulint_cmp(table_id, index->table->id) != 0) {
1527
1517
                ptr = NULL;
1528
1518
 
1529
1519
                fprintf(stderr,
1544
1534
                fprintf(stderr,
1545
1535
                        "InnoDB: table %s, index %s, n_uniq %lu\n"
1546
1536
                        "InnoDB: undo rec address %p, type %lu cmpl_info %lu\n"
1547
 
                        "InnoDB: undo rec table id %llu,"
1548
 
                        " index table id %llu\n"
 
1537
                        "InnoDB: undo rec table id %lu %lu,"
 
1538
                        " index table id %lu %lu\n"
1549
1539
                        "InnoDB: dump of 150 bytes in undo rec: ",
1550
1540
                        index->table_name, index->name,
1551
1541
                        (ulong) dict_index_get_n_unique(index),
1552
1542
                        undo_rec, (ulong) type, (ulong) cmpl_info,
1553
 
                        (ullint) table_id,
1554
 
                        (ullint) index->table->id);
 
1543
                        (ulong) ut_dulint_get_high(table_id),
 
1544
                        (ulong) ut_dulint_get_low(table_id),
 
1545
                        (ulong) ut_dulint_get_high(index->table->id),
 
1546
                        (ulong) ut_dulint_get_low(index->table->id));
1555
1547
                ut_print_buf(stderr, undo_rec, 150);
1556
1548
                fputs("\n"
1557
1549
                      "InnoDB: index record ", stderr);
1562
1554
                fprintf(stderr, "\n"
1563
1555
                        "InnoDB: Record trx id " TRX_ID_FMT
1564
1556
                        ", update rec trx id " TRX_ID_FMT "\n"
1565
 
                        "InnoDB: Roll ptr in rec " TRX_ID_FMT
1566
 
                        ", in update rec" TRX_ID_FMT "\n",
1567
 
                        rec_trx_id, trx_id,
1568
 
                        old_roll_ptr, roll_ptr);
 
1557
                        "InnoDB: Roll ptr in rec %lu %lu, in update rec"
 
1558
                        " %lu %lu\n",
 
1559
                        TRX_ID_PREP_PRINTF(rec_trx_id),
 
1560
                        TRX_ID_PREP_PRINTF(trx_id),
 
1561
                        (ulong) ut_dulint_get_high(old_roll_ptr),
 
1562
                        (ulong) ut_dulint_get_low(old_roll_ptr),
 
1563
                        (ulong) ut_dulint_get_high(roll_ptr),
 
1564
                        (ulong) ut_dulint_get_low(roll_ptr));
1569
1565
 
1570
1566
                trx_purge_sys_print();
1571
1567
                return(DB_ERROR);
1588
1584
                following call is safe. */
1589
1585
                row_upd_index_replace_new_col_vals(entry, index, update, heap);
1590
1586
 
1591
 
                buf = static_cast<byte *>(mem_heap_alloc(heap, rec_get_converted_size(index, entry,
1592
 
                                                                  n_ext)));
 
1587
                buf = mem_heap_alloc(heap, rec_get_converted_size(index, entry,
 
1588
                                                                  n_ext));
1593
1589
 
1594
1590
                *old_vers = rec_convert_dtuple_to_rec(buf, index,
1595
1591
                                                      entry, n_ext);
1596
1592
        } else {
1597
 
                buf = static_cast<byte *>(mem_heap_alloc(heap, rec_offs_size(offsets)));
 
1593
                buf = mem_heap_alloc(heap, rec_offs_size(offsets));
1598
1594
                *old_vers = rec_copy(buf, rec, offsets);
1599
1595
                rec_offs_make_valid(*old_vers, index, offsets);
1600
1596
                row_upd_rec_in_place(*old_vers, index, offsets, update, NULL);