~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-12-02 01:39:53 UTC
  • mto: This revision was merged to the branch mainline in revision 1968.
  • Revision ID: brian@tangent.org-20101202013953-9ie7kafjag0e051q
Style cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
#define ROW_INS_PREV    1
52
52
#define ROW_INS_NEXT    2
53
53
 
54
 
/*************************************************************************
55
 
IMPORTANT NOTE: Any operation that generates redo MUST check that there
56
 
is enough space in the redo log before for that operation. This is
57
 
done by calling log_free_check(). The reason for checking the
58
 
availability of the redo log space before the start of the operation is
59
 
that we MUST not hold any synchonization objects when performing the
60
 
check.
61
 
If you make a change in this module make sure that no codepath is
62
 
introduced where a call to log_free_check() is bypassed. */
63
54
 
64
55
/*********************************************************************//**
65
56
Creates an insert node struct.
87
78
 
88
79
        node->select = NULL;
89
80
 
90
 
        node->trx_id = 0;
 
81
        node->trx_id = ut_dulint_zero;
91
82
 
92
83
        node->entry_sys_heap = mem_heap_create(128);
93
84
 
207
198
        /* As we allocated a new trx id buf, the trx id should be written
208
199
        there again: */
209
200
 
210
 
        node->trx_id = 0;
 
201
        node->trx_id = ut_dulint_zero;
211
202
}
212
203
 
213
204
/*******************************************************************//**
515
506
 
516
507
                                if (!dfield_is_null(&ufield->new_val)
517
508
                                    && dtype_get_at_most_n_mbchars(
518
 
                                        col->prtype, col->mbminmaxlen,
 
509
                                        col->prtype,
 
510
                                        col->mbminlen, col->mbmaxlen,
519
511
                                        col->len,
520
512
                                        ufield_len,
521
513
                                        dfield_get_data(&ufield->new_val))
538
530
 
539
531
                                if (min_size > ufield_len) {
540
532
 
541
 
                                        byte*   pad;
542
 
                                        ulint   pad_len;
543
 
                                        byte*   padded_data;
544
 
                                        ulint   mbminlen;
545
 
 
546
 
                                        padded_data = mem_heap_alloc(
547
 
                                                heap, min_size);
548
 
 
549
 
                                        pad = padded_data + ufield_len;
550
 
                                        pad_len = min_size - ufield_len;
 
533
                                        char*           pad_start;
 
534
                                        const char*     pad_end;
 
535
                                        char*           padded_data
 
536
                                                = mem_heap_alloc(
 
537
                                                        heap, min_size);
 
538
                                        pad_start = padded_data + ufield_len;
 
539
                                        pad_end = padded_data + min_size;
551
540
 
552
541
                                        memcpy(padded_data,
553
542
                                               dfield_get_data(&ufield
554
543
                                                               ->new_val),
555
 
                                               ufield_len);
556
 
 
557
 
                                        mbminlen = dict_col_get_mbminlen(col);
558
 
 
559
 
                                        ut_ad(!(ufield_len % mbminlen));
560
 
                                        ut_ad(!(min_size % mbminlen));
561
 
 
562
 
                                        if (mbminlen == 1
563
 
                                            && dtype_get_charset_coll(
564
 
                                                    col->prtype)
565
 
                                            == DATA_MYSQL_BINARY_CHARSET_COLL) {
566
 
                                                /* Do not pad BINARY columns */
 
544
                                               dfield_get_len(&ufield
 
545
                                                              ->new_val));
 
546
 
 
547
                                        switch (UNIV_EXPECT(col->mbminlen,1)) {
 
548
                                        default:
 
549
                                                ut_error;
567
550
                                                return(ULINT_UNDEFINED);
 
551
                                        case 1:
 
552
                                                if (UNIV_UNLIKELY
 
553
                                                    (dtype_get_charset_coll(
 
554
                                                            col->prtype)
 
555
                                                     == DATA_MYSQL_BINARY_CHARSET_COLL)) {
 
556
                                                        /* Do not pad BINARY
 
557
                                                        columns. */
 
558
                                                        return(ULINT_UNDEFINED);
 
559
                                                }
 
560
 
 
561
                                                /* space=0x20 */
 
562
                                                memset(pad_start, 0x20,
 
563
                                                       pad_end - pad_start);
 
564
                                                break;
 
565
                                        case 2:
 
566
                                                /* space=0x0020 */
 
567
                                                ut_a(!(ufield_len % 2));
 
568
                                                ut_a(!(min_size % 2));
 
569
                                                do {
 
570
                                                        *pad_start++ = 0x00;
 
571
                                                        *pad_start++ = 0x20;
 
572
                                                } while (pad_start < pad_end);
 
573
                                                break;
568
574
                                        }
569
575
 
570
 
                                        row_mysql_pad_col(mbminlen,
571
 
                                                          pad, pad_len);
572
576
                                        dfield_set_data(&ufield->new_val,
573
577
                                                        padded_data, min_size);
574
578
                                }
2156
2160
        ibool           foreign,/*!< in: TRUE=check foreign key constraints */
2157
2161
        que_thr_t*      thr)    /*!< in: query thread */
2158
2162
{
2159
 
        enum db_err     err;
 
2163
        ulint   err;
2160
2164
 
2161
2165
        if (foreign && UT_LIST_GET_FIRST(index->table->foreign_list)) {
2162
2166
                err = row_ins_check_foreign_constraints(index->table, index,
2220
2224
                                = dict_field_get_col(ind_field);
2221
2225
 
2222
2226
                        len = dtype_get_at_most_n_mbchars(
2223
 
                                col->prtype, col->mbminmaxlen,
 
2227
                                col->prtype, col->mbminlen, col->mbmaxlen,
2224
2228
                                ind_field->prefix_len,
2225
2229
                                len, dfield_get_data(row_field));
2226
2230
 
2246
2250
        ins_node_t*     node,   /*!< in: row insert node */
2247
2251
        que_thr_t*      thr)    /*!< in: query thread */
2248
2252
{
2249
 
        enum db_err     err;
 
2253
        ulint   err;
2250
2254
 
2251
2255
        ut_ad(dtuple_check_typed(node->row));
2252
2256
 
2267
2271
/*======================*/
2268
2272
        ins_node_t*     node)   /*!< in: row insert node */
2269
2273
{
2270
 
        row_id_t        row_id;
 
2274
        dulint  row_id;
2271
2275
 
2272
2276
        ut_ad(node->state == INS_NODE_ALLOC_ROW_ID);
2273
2277
 
2454
2458
                /* It may be that the current session has not yet started
2455
2459
                its transaction, or it has been committed: */
2456
2460
 
2457
 
                if (trx->id == node->trx_id) {
 
2461
                if (UT_DULINT_EQ(trx->id, node->trx_id)) {
2458
2462
                        /* No need to do IX-locking */
2459
2463
 
2460
2464
                        goto same_trx;