~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-12-06 21:17:06 UTC
  • mto: (1977.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1980.
  • Revision ID: mordred@inaugust.com-20101206211706-iiuzzkxhh3fm10zf
Add ability to add a validation function to any sys_var. duh.

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, 2010, 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
313
313
{
314
314
        upd_node_t*     node;
315
315
 
316
 
        node = static_cast<upd_node_t *>(mem_heap_alloc(heap, sizeof(upd_node_t)));
 
316
        node = mem_heap_alloc(heap, sizeof(upd_node_t));
317
317
        node->common.type = QUE_NODE_UPDATE;
318
318
 
319
319
        node->state = UPD_NODE_UPDATE_CLUSTERED;
381
381
void
382
382
row_upd_index_entry_sys_field(
383
383
/*==========================*/
384
 
        dtuple_t*       entry,  /*!< in/out: index entry, where the memory
385
 
                                buffers for sys fields are already allocated:
 
384
        const dtuple_t* entry,  /*!< in: index entry, where the memory buffers
 
385
                                for sys fields are already allocated:
386
386
                                the function just copies the new values to
387
387
                                them */
388
388
        dict_index_t*   index,  /*!< in: clustered index */
398
398
        pos = dict_index_get_sys_col_pos(index, type);
399
399
 
400
400
        dfield = dtuple_get_nth_field(entry, pos);
401
 
        field = static_cast<byte *>(dfield_get_data(dfield));
 
401
        field = dfield_get_data(dfield);
402
402
 
403
403
        if (type == DATA_TRX_ID) {
404
404
                trx_write_trx_id(field, val);
476
476
#endif /* !UNIV_HOTBACKUP */
477
477
 
478
478
/***********************************************************//**
479
 
Replaces the new column values stored in the update vector to the
480
 
record given. No field size changes are allowed. This function is
481
 
usually invoked on a clustered index. The only use case for a
482
 
secondary index is row_ins_sec_index_entry_by_modify() or its
483
 
counterpart in ibuf_insert_to_index_page(). */
 
479
Replaces the new column values stored in the update vector to the record
 
480
given. No field size changes are allowed. */
484
481
UNIV_INTERN
485
482
void
486
483
row_upd_rec_in_place(
537
534
        roll_ptr_t      roll_ptr,/*!< in: roll ptr of the undo log record */
538
535
        byte*           log_ptr,/*!< pointer to a buffer of size > 20 opened
539
536
                                in mlog */
540
 
        mtr_t*          /*mtr __attribute__((unused))*/) /*!< in: mtr */
 
537
        mtr_t*          mtr __attribute__((unused))) /*!< in: mtr */
541
538
{
542
539
        ut_ad(dict_index_is_clust(index));
543
540
        ut_ad(mtr);
648
645
                                mlog_close(mtr, log_ptr);
649
646
 
650
647
                                mlog_catenate_string(mtr,
651
 
                                                     static_cast<byte *>(dfield_get_data(new_val)),
 
648
                                                     dfield_get_data(new_val),
652
649
                                                     len);
653
650
 
654
651
                                log_ptr = mlog_open(mtr, MLOG_BUF_MARGIN);
907
904
                                        out: fetched length of the prefix */
908
905
        mem_heap_t*     heap)           /*!< in: heap where to allocate */
909
906
{
910
 
        byte* buf = static_cast<byte *>(mem_heap_alloc(heap, *len));
 
907
        byte*   buf = mem_heap_alloc(heap, *len);
911
908
 
912
909
        *len = btr_copy_externally_stored_field_prefix(buf, *len,
913
910
                                                       zip_size,
945
942
        }
946
943
 
947
944
        len = dfield_get_len(dfield);
948
 
        data = static_cast<const byte *>(dfield_get_data(dfield));
 
945
        data = dfield_get_data(dfield);
949
946
 
950
947
        if (field->prefix_len > 0) {
951
948
                ibool           fetch_ext = dfield_is_ext(dfield)
996
993
                stored part of the column.  The data
997
994
                will have to be copied. */
998
995
                ut_a(uf->orig_len > BTR_EXTERN_FIELD_REF_SIZE);
999
 
                buf = static_cast<byte *>(mem_heap_alloc(heap, uf->orig_len));
 
996
                buf = mem_heap_alloc(heap, uf->orig_len);
1000
997
                /* Copy the locally stored prefix. */
1001
998
                memcpy(buf, data,
1002
999
                       uf->orig_len - BTR_EXTERN_FIELD_REF_SIZE);
1146
1143
        table = index->table;
1147
1144
        ut_ad(n_cols == dict_table_get_n_cols(table));
1148
1145
 
1149
 
        ext_cols = static_cast<ulint *>(mem_heap_alloc(heap, n_cols * sizeof *ext_cols));
 
1146
        ext_cols = mem_heap_alloc(heap, n_cols * sizeof *ext_cols);
1150
1147
        n_ext_cols = 0;
1151
1148
 
1152
1149
        dtuple_set_info_bits(row, update->info_bits);
1625
1622
ulint
1626
1623
row_upd_clust_rec_by_insert(
1627
1624
/*========================*/
1628
 
        upd_node_t*     node,   /*!< in/out: row update node */
 
1625
        upd_node_t*     node,   /*!< in: row update node */
1629
1626
        dict_index_t*   index,  /*!< in: clustered index of the record */
1630
1627
        que_thr_t*      thr,    /*!< in: query thread */
1631
1628
        ibool           referenced,/*!< in: TRUE if index may be referenced in
1632
1629
                                a foreign key constraint */
1633
 
        mtr_t*          mtr)    /*!< in/out: mtr; gets committed here */
 
1630
        mtr_t*          mtr)    /*!< in: mtr; gets committed here */
1634
1631
{
1635
1632
        mem_heap_t*     heap    = NULL;
1636
1633
        btr_pcur_t*     pcur;
1639
1636
        dict_table_t*   table;
1640
1637
        dtuple_t*       entry;
1641
1638
        ulint           err;
1642
 
        ibool           change_ownership = FALSE;
1643
1639
 
1644
1640
        ut_ad(node);
1645
1641
        ut_ad(dict_index_is_clust(index));
1651
1647
 
1652
1648
        if (node->state != UPD_NODE_INSERT_CLUSTERED) {
1653
1649
                rec_t*          rec;
1654
 
                dict_index_t*   node_index;
 
1650
                dict_index_t*   index;
1655
1651
                ulint           offsets_[REC_OFFS_NORMAL_SIZE];
1656
1652
                ulint*          offsets;
1657
1653
                rec_offs_init(offsets_);
1669
1665
                record is removed from the index tree, or updated. */
1670
1666
 
1671
1667
                rec = btr_cur_get_rec(btr_cur);
1672
 
                node_index = dict_table_get_first_index(table);
1673
 
                offsets = rec_get_offsets(rec, node_index, offsets_,
 
1668
                index = dict_table_get_first_index(table);
 
1669
                offsets = rec_get_offsets(rec, index, offsets_,
1674
1670
                                          ULINT_UNDEFINED, &heap);
1675
 
                change_ownership = btr_cur_mark_extern_inherited_fields(
1676
 
                        btr_cur_get_page_zip(btr_cur), rec, node_index, offsets,
1677
 
                        node->update, mtr);
 
1671
                btr_cur_mark_extern_inherited_fields(
 
1672
                        btr_cur_get_page_zip(btr_cur),
 
1673
                        rec, index, offsets, node->update, mtr);
1678
1674
                if (referenced) {
1679
1675
                        /* NOTE that the following call loses
1680
1676
                        the position of pcur ! */
1681
1677
 
1682
1678
                        err = row_upd_check_references_constraints(
1683
 
                                node, pcur, table, node_index, offsets, thr, mtr);
 
1679
                                node, pcur, table, index, offsets, thr, mtr);
1684
1680
 
1685
1681
                        if (err != DB_SUCCESS) {
1686
1682
 
1708
1704
 
1709
1705
        row_upd_index_entry_sys_field(entry, index, DATA_TRX_ID, trx->id);
1710
1706
 
1711
 
        if (change_ownership) {
 
1707
        if (node->upd_ext) {
1712
1708
                /* If we return from a lock wait, for example, we may have
1713
1709
                extern fields marked as not-owned in entry (marked in the
1714
 
                if-branch above). We must unmark them, take the ownership
1715
 
                back. */
 
1710
                if-branch above). We must unmark them. */
1716
1711
 
1717
1712
                btr_cur_unmark_dtuple_extern_fields(entry);
1718
1713
 
2154
2149
 
2155
2150
        trx_start_if_not_started(trx);
2156
2151
 
2157
 
        node = static_cast<upd_node_t *>(thr->run_node);
 
2152
        node = thr->run_node;
2158
2153
 
2159
2154
        sel_node = node->select;
2160
2155