~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-12-12 11:52:00 UTC
  • mto: (2023.3.15 innodb-cxx)
  • mto: This revision was merged to the branch mainline in revision 2014.
  • Revision ID: mordred@inaugust.com-20101212115200-uyk1h5crevvt77gh
RevertĀ -Wc++-compatĀ change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 2000, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 2000, 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
486
486
                                        row is used, as row may contain
487
487
                                        pointers to this record! */
488
488
{
489
 
        const mysql_row_templ_t*templ;
 
489
        mysql_row_templ_t*      templ;
490
490
        dfield_t*               dfield;
491
491
        ulint                   i;
492
492
 
659
659
 
660
660
        heap = mem_heap_create(sizeof *prebuilt + 128);
661
661
 
662
 
        prebuilt = static_cast<row_prebuilt_t *>(mem_heap_zalloc(heap, sizeof *prebuilt));
 
662
        prebuilt = mem_heap_zalloc(heap, sizeof *prebuilt);
663
663
 
664
664
        prebuilt->magic_n = ROW_PREBUILT_ALLOCATED;
665
665
        prebuilt->magic_n2 = ROW_PREBUILT_ALLOCATED;
869
869
                prebuilt->ins_node = node;
870
870
 
871
871
                if (prebuilt->ins_upd_rec_buff == NULL) {
872
 
                        prebuilt->ins_upd_rec_buff = static_cast<byte *>(mem_heap_alloc(
873
 
                                prebuilt->heap, prebuilt->mysql_row_len));
 
872
                        prebuilt->ins_upd_rec_buff = mem_heap_alloc(
 
873
                                prebuilt->heap, prebuilt->mysql_row_len);
874
874
                }
875
875
 
876
876
                row = dtuple_create(prebuilt->heap,
880
880
 
881
881
                ins_node_set_new_row(node, row);
882
882
 
883
 
                prebuilt->ins_graph = static_cast<que_fork_t *>(que_node_get_parent(
 
883
                prebuilt->ins_graph = que_node_get_parent(
884
884
                        pars_complete_graph_for_exec(node,
885
885
                                                     prebuilt->trx,
886
 
                                                     prebuilt->heap)));
 
886
                                                     prebuilt->heap));
887
887
                prebuilt->ins_graph->state = QUE_FORK_ACTIVE;
888
888
        }
889
889
 
914
914
        if (counter > 2000000000
915
915
            || ((ib_int64_t)counter > 16 + table->stat_n_rows / 16)) {
916
916
 
917
 
                dict_update_statistics(table, FALSE /* update even if stats
918
 
                                                    are initialized */);
 
917
                dict_update_statistics(table);
919
918
        }
920
919
}
921
920
 
1066
1065
        trx_start_if_not_started(trx);
1067
1066
 
1068
1067
        if (table) {
1069
 
                err = lock_table(0, table, static_cast<lock_mode>(mode), thr);
 
1068
                err = lock_table(0, table, mode, thr);
1070
1069
        } else {
1071
1070
                err = lock_table(0, prebuilt->table,
1072
 
                                 static_cast<lock_mode>(prebuilt->select_lock_type), thr);
 
1071
                                 prebuilt->select_lock_type, thr);
1073
1072
        }
1074
1073
 
1075
1074
        trx->error_state = err;
1244
1243
 
1245
1244
                node = sel_node_create(prebuilt->heap);
1246
1245
 
1247
 
                prebuilt->sel_graph = static_cast<que_fork_t *>(que_node_get_parent(
 
1246
                prebuilt->sel_graph = que_node_get_parent(
1248
1247
                        pars_complete_graph_for_exec(node,
1249
1248
                                                     prebuilt->trx,
1250
 
                                                     prebuilt->heap)));
 
1249
                                                     prebuilt->heap));
1251
1250
 
1252
1251
                prebuilt->sel_graph->state = QUE_FORK_ACTIVE;
1253
1252
        }
1315
1314
 
1316
1315
                prebuilt->upd_node = node;
1317
1316
 
1318
 
                prebuilt->upd_graph = static_cast<que_fork_t *>(que_node_get_parent(
 
1317
                prebuilt->upd_graph = que_node_get_parent(
1319
1318
                        pars_complete_graph_for_exec(node,
1320
1319
                                                     prebuilt->trx,
1321
 
                                                     prebuilt->heap)));
 
1320
                                                     prebuilt->heap));
1322
1321
                prebuilt->upd_graph->state = QUE_FORK_ACTIVE;
1323
1322
        }
1324
1323
 
1605
1604
                        index = btr_pcur_get_btr_cur(pcur)->index;
1606
1605
 
1607
1606
                        lock_rec_unlock(trx, btr_pcur_get_block(pcur),
1608
 
                                        rec, static_cast<lock_mode>(prebuilt->select_lock_type));
 
1607
                                        rec, prebuilt->select_lock_type);
1609
1608
 
1610
1609
                        if (prebuilt->new_rec_locks >= 2) {
1611
1610
                                rec = btr_pcur_get_rec(clust_pcur);
1614
1613
                                lock_rec_unlock(trx,
1615
1614
                                                btr_pcur_get_block(clust_pcur),
1616
1615
                                                rec,
1617
 
                                                static_cast<lock_mode>(prebuilt->select_lock_type));
 
1616
                                                prebuilt->select_lock_type);
1618
1617
                        }
1619
1618
                }
1620
1619
no_unlock:
1912
1911
 
1913
1912
        thr = pars_complete_graph_for_exec(node, trx, heap);
1914
1913
 
1915
 
        ut_a(thr == que_fork_start_command(static_cast<que_fork_t *>(que_node_get_parent(thr))));
 
1914
        ut_a(thr == que_fork_start_command(que_node_get_parent(thr)));
1916
1915
        que_run_threads(thr);
1917
1916
 
1918
1917
        err = trx->error_state;
1919
1918
 
 
1919
        if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
 
1920
                trx->error_state = DB_SUCCESS;
 
1921
                trx_general_rollback_for_mysql(trx, NULL);
 
1922
                /* TO DO: free table?  The code below will dereference
 
1923
                table->name, though. */
 
1924
        }
 
1925
 
1920
1926
        switch (err) {
1921
 
        case DB_SUCCESS:
1922
 
                break;
1923
1927
        case DB_OUT_OF_FILE_SPACE:
1924
 
                trx->error_state = DB_SUCCESS;
1925
 
                trx_general_rollback_for_mysql(trx, NULL);
1926
 
 
1927
1928
                ut_print_timestamp(stderr);
1928
1929
                fputs("  InnoDB: Warning: cannot create table ",
1929
1930
                      stderr);
1938
1939
                break;
1939
1940
 
1940
1941
        case DB_DUPLICATE_KEY:
1941
 
        default:
1942
1942
                /* We may also get err == DB_ERROR if the .ibd file for the
1943
1943
                table already exists */
1944
1944
 
1945
 
                trx->error_state = DB_SUCCESS;
1946
 
                trx_general_rollback_for_mysql(trx, NULL);
1947
 
                dict_mem_table_free(table);
1948
1945
                break;
1949
1946
        }
1950
1947
 
2053
2050
 
2054
2051
        thr = pars_complete_graph_for_exec(node, trx, heap);
2055
2052
 
2056
 
        ut_a(thr == que_fork_start_command(static_cast<que_fork_t *>(que_node_get_parent(thr))));
 
2053
        ut_a(thr == que_fork_start_command(que_node_get_parent(thr)));
2057
2054
        que_run_threads(thr);
2058
2055
 
2059
2056
        err = trx->error_state;
2326
2323
                drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop);
2327
2324
        }
2328
2325
 
2329
 
        drop = static_cast<row_mysql_drop_t *>(mem_alloc(sizeof(row_mysql_drop_t)));
 
2326
        drop = mem_alloc(sizeof(row_mysql_drop_t));
2330
2327
 
2331
2328
        drop->table_name = mem_strdup(name);
2332
2329
 
2820
2817
 
2821
2818
        trx->table_id = table->id;
2822
2819
 
 
2820
        /* Lock all index trees for this table, as we will
 
2821
        truncate the table/index and possibly change their metadata.
 
2822
        All DML/DDL are blocked by table level lock, with
 
2823
        a few exceptions such as queries into information schema
 
2824
        about the table, MySQL could try to access index stats
 
2825
        for this kind of query, we need to use index locks to
 
2826
        sync up */
 
2827
        dict_table_x_lock_indexes(table);
 
2828
 
2823
2829
        if (table->space && !table->dir_path_of_temp_table) {
2824
2830
                /* Discard and create the single-table tablespace. */
2825
2831
                ulint   space   = table->space;
2832
2838
 
2833
2839
                        dict_hdr_get_new_id(NULL, NULL, &space);
2834
2840
 
2835
 
                        /* Lock all index trees for this table. We must
2836
 
                        do so after dict_hdr_get_new_id() to preserve
2837
 
                        the latch order */
2838
 
                        dict_table_x_lock_indexes(table);
2839
 
 
2840
2841
                        if (space == ULINT_UNDEFINED
2841
2842
                            || fil_create_new_single_table_tablespace(
2842
2843
                                    space, table->name, FALSE, flags,
2870
2871
                                        FIL_IBD_FILE_INITIAL_SIZE, &mtr);
2871
2872
                        mtr_commit(&mtr);
2872
2873
                }
2873
 
        } else {
2874
 
                /* Lock all index trees for this table, as we will
2875
 
                truncate the table/index and possibly change their metadata.
2876
 
                All DML/DDL are blocked by table level lock, with
2877
 
                a few exceptions such as queries into information schema
2878
 
                about the table, MySQL could try to access index stats
2879
 
                for this kind of query, we need to use index locks to
2880
 
                sync up */
2881
 
                dict_table_x_lock_indexes(table);
2882
2874
        }
2883
2875
 
2884
2876
        /* scan SYS_INDEXES for all indexes of the table */
2887
2879
        tuple = dtuple_create(heap, 1);
2888
2880
        dfield = dtuple_get_nth_field(tuple, 0);
2889
2881
 
2890
 
        buf = static_cast<byte *>(mem_heap_alloc(heap, 8));
 
2882
        buf = mem_heap_alloc(heap, 8);
2891
2883
        mach_write_to_8(buf, table->id);
2892
2884
 
2893
2885
        dfield_set_data(dfield, buf, 8);
3004
2996
        dict_table_autoinc_lock(table);
3005
2997
        dict_table_autoinc_initialize(table, 1);
3006
2998
        dict_table_autoinc_unlock(table);
3007
 
        dict_update_statistics(table, FALSE /* update even if stats are
3008
 
                                            initialized */);
 
2999
        dict_update_statistics(table);
3009
3000
 
3010
3001
        trx_commit_for_mysql(trx);
3011
3002
 
3213
3204
 
3214
3205
        if (table->n_foreign_key_checks_running > 0) {
3215
3206
 
3216
 
                const char*     i_table_name = table->name;
 
3207
                const char*     table_name = table->name;
3217
3208
                ibool           added;
3218
3209
 
3219
 
                added = row_add_table_to_background_drop_list(i_table_name);
 
3210
                added = row_add_table_to_background_drop_list(table_name);
3220
3211
 
3221
3212
                if (added) {
3222
3213
                        ut_print_timestamp(stderr);
3223
3214
                        fputs("  InnoDB: You are trying to drop table ",
3224
3215
                              stderr);
3225
 
                        ut_print_name(stderr, trx, TRUE, i_table_name);
 
3216
                        ut_print_name(stderr, trx, TRUE, table_name);
3226
3217
                        fputs("\n"
3227
3218
                              "InnoDB: though there is a"
3228
3219
                              " foreign key check running on it.\n"
4095
4086
 
4096
4087
        *n_rows = 0;
4097
4088
 
4098
 
        buf = static_cast<byte *>(mem_alloc(UNIV_PAGE_SIZE));
 
4089
        buf = mem_alloc(UNIV_PAGE_SIZE);
4099
4090
        heap = mem_heap_create(100);
4100
4091
 
4101
4092
        cnt = 1000;
4196
4187
                                * sizeof *offsets;
4197
4188
 
4198
4189
                        tmp_heap = mem_heap_create(size);
4199
 
                        offsets = static_cast<ulint *>(mem_heap_dup(tmp_heap, offsets, size));
 
4190
                        offsets = mem_heap_dup(tmp_heap, offsets, size);
4200
4191
                }
4201
4192
 
4202
4193
                mem_heap_empty(heap);