~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Tags: innodb-plugin-1.0.2
InnoDB Plugin 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
625
625
 
626
626
        prebuilt->clust_ref = ref;
627
627
 
 
628
        prebuilt->autoinc_error = 0;
 
629
        prebuilt->autoinc_offset = 0;
 
630
 
 
631
        /* Default to 1, we will set the actual value later in 
 
632
        ha_innobase::get_auto_increment(). */
 
633
        prebuilt->autoinc_increment = 1;
 
634
 
 
635
        prebuilt->autoinc_last_value = 0;
 
636
 
628
637
        return(prebuilt);
629
638
}
630
639
 
843
852
}
844
853
 
845
854
/*************************************************************************
846
 
Unlocks an AUTO_INC type lock possibly reserved by trx. */
 
855
Unlocks AUTO_INC type locks that were possibly reserved by a trx. */
847
856
UNIV_INTERN
848
857
void
849
858
row_unlock_table_autoinc_for_mysql(
850
859
/*===============================*/
851
 
        trx_t*  trx)    /* in: transaction */
 
860
        trx_t*  trx)    /* in/out: transaction */
852
861
{
853
 
        if (!trx->auto_inc_lock) {
854
 
 
855
 
                return;
856
 
        }
857
 
 
858
 
        lock_table_unlock_auto_inc(trx);
 
862
        mutex_enter(&kernel_mutex);
 
863
 
 
864
        lock_release_autoinc_locks(trx);
 
865
 
 
866
        mutex_exit(&kernel_mutex);
859
867
}
860
868
 
861
869
/*************************************************************************
872
880
        row_prebuilt_t* prebuilt)       /* in: prebuilt struct in the MySQL
873
881
                                        table handle */
874
882
{
875
 
        trx_t*          trx             = prebuilt->trx;
876
 
        ins_node_t*     node            = prebuilt->ins_node;
877
 
        que_thr_t*      thr;
878
 
        ulint           err;
879
 
        ibool           was_lock_wait;
 
883
        trx_t*                  trx     = prebuilt->trx;
 
884
        ins_node_t*             node    = prebuilt->ins_node;
 
885
        const dict_table_t*     table   = prebuilt->table;
 
886
        que_thr_t*              thr;
 
887
        ulint                   err;
 
888
        ibool                   was_lock_wait;
880
889
 
881
890
        ut_ad(trx);
882
891
        ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
883
892
 
884
 
        if (trx->auto_inc_lock) {
 
893
        /* If we already hold an AUTOINC lock on the table then do nothing.
 
894
        Note: We peek at the value of the current owner without acquiring
 
895
        the kernel mutex. **/
 
896
        if (trx == table->autoinc_trx) {
885
897
 
886
898
                return(DB_SUCCESS);
887
899
        }
1701
1713
row_create_table_for_mysql(
1702
1714
/*=======================*/
1703
1715
                                /* out: error code or DB_SUCCESS */
1704
 
        dict_table_t*   table,  /* in: table definition */
 
1716
        dict_table_t*   table,  /* in, own: table definition
 
1717
                                (will be freed) */
1705
1718
        trx_t*          trx)    /* in: transaction handle */
1706
1719
{
1707
1720
        tab_node_t*     node;
1842
1855
                if (dict_table_get_low(table->name)) {
1843
1856
 
1844
1857
                        row_drop_table_for_mysql(table->name, trx, FALSE);
 
1858
                        trx_commit_for_mysql(trx);
1845
1859
                }
1846
1860
                break;
1847
1861
 
1894
1908
row_create_index_for_mysql(
1895
1909
/*=======================*/
1896
1910
                                        /* out: error number or DB_SUCCESS */
1897
 
        dict_index_t*   index,          /* in: index definition */
 
1911
        dict_index_t*   index,          /* in, own: index definition
 
1912
                                        (will be freed) */
1898
1913
        trx_t*          trx,            /* in: transaction handle */
1899
1914
        const ulint*    field_lengths)  /* in: if not NULL, must contain
1900
1915
                                        dict_index_get_n_fields(index)
1999
2014
 
2000
2015
                row_drop_table_for_mysql(table_name, trx, FALSE);
2001
2016
 
 
2017
                trx_commit_for_mysql(trx);
 
2018
 
2002
2019
                trx->error_state = DB_SUCCESS;
2003
2020
        }
2004
2021
 
2066
2083
 
2067
2084
                row_drop_table_for_mysql(name, trx, FALSE);
2068
2085
 
 
2086
                trx_commit_for_mysql(trx);
 
2087
 
2069
2088
                trx->error_state = DB_SUCCESS;
2070
2089
        }
2071
2090
 
2397
2416
 
2398
2417
        new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
2399
2418
 
2400
 
        /* Remove any locks there are on the table or its records */
2401
 
        lock_reset_all_on_table(table);
 
2419
        /* Remove all locks except the table-level S and X locks. */
 
2420
        lock_remove_all_on_table(table, FALSE);
2402
2421
 
2403
2422
        info = pars_info_create();
2404
2423
 
2742
2761
                goto funct_exit;
2743
2762
        }
2744
2763
 
2745
 
        /* Remove any locks there are on the table or its records */
2746
 
 
2747
 
        lock_reset_all_on_table(table);
 
2764
        /* Remove all locks except the table-level S and X locks. */
 
2765
        lock_remove_all_on_table(table, FALSE);
2748
2766
 
2749
2767
        trx->table_id = table->id;
2750
2768
 
2908
2926
        /* MySQL calls ha_innobase::reset_auto_increment() which does
2909
2927
        the same thing. */
2910
2928
        dict_table_autoinc_lock(table);
2911
 
        dict_table_autoinc_initialize(table, 0);
 
2929
        dict_table_autoinc_initialize(table, 1);
2912
2930
        dict_table_autoinc_unlock(table);
2913
2931
        dict_update_statistics(table);
2914
2932
 
2926
2944
}
2927
2945
 
2928
2946
/*************************************************************************
2929
 
Drops a table for MySQL. If the name of the dropped table ends in
 
2947
Drops a table for MySQL.  If the name of the dropped table ends in
2930
2948
one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor",
2931
2949
"innodb_table_monitor", then this will also stop the printing of monitor
2932
 
output by the master thread. */
 
2950
output by the master thread.  If the data dictionary was not already locked
 
2951
by the transaction, the transaction will be committed.  Otherwise, the
 
2952
data dictionary will remain locked. */
2933
2953
UNIV_INTERN
2934
2954
int
2935
2955
row_drop_table_for_mysql(
2939
2959
        trx_t*          trx,    /* in: transaction handle */
2940
2960
        ibool           drop_db)/* in: TRUE=dropping whole database */
2941
2961
{
2942
 
        ulint           err;
2943
 
 
2944
 
        err = row_drop_table_for_mysql_no_commit(name, trx, drop_db);
2945
 
        trx_commit_for_mysql(trx);
2946
 
 
2947
 
        return(err);
2948
 
}
2949
 
 
2950
 
/*************************************************************************
2951
 
Drops a table for MySQL but does not commit the transaction.  If the
2952
 
name of the dropped table ends in one of "innodb_monitor",
2953
 
"innodb_lock_monitor", "innodb_tablespace_monitor",
2954
 
"innodb_table_monitor", then this will also stop the printing of
2955
 
monitor output by the master thread. */
2956
 
UNIV_INTERN
2957
 
int
2958
 
row_drop_table_for_mysql_no_commit(
2959
 
/*===============================*/
2960
 
                                /* out: error code or DB_SUCCESS */
2961
 
        const char*     name,   /* in: table name */
2962
 
        trx_t*          trx,    /* in: transaction handle */
2963
 
        ibool           drop_db)/* in: TRUE=dropping whole database */
2964
 
{
2965
2962
        dict_foreign_t* foreign;
2966
2963
        dict_table_t*   table;
2967
2964
        ulint           space_id;
3165
3162
                goto funct_exit;
3166
3163
        }
3167
3164
 
3168
 
        /* Remove any locks there are on the table or its records */
3169
 
 
3170
 
        lock_reset_all_on_table(table);
 
3165
        /* Remove all locks there are on the table or its records */
 
3166
        lock_remove_all_on_table(table, TRUE);
3171
3167
 
3172
3168
        trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
3173
3169
        trx->table_id = table->id;
3330
3326
funct_exit:
3331
3327
 
3332
3328
        if (locked_dictionary) {
 
3329
                trx_commit_for_mysql(trx);
 
3330
 
3333
3331
                row_mysql_unlock_data_dictionary(trx);
3334
3332
        }
3335
3333
 
3458
3456
                }
3459
3457
 
3460
3458
                err = row_drop_table_for_mysql(table_name, trx, TRUE);
3461
 
 
3462
 
                mem_free(table_name);
 
3459
                trx_commit_for_mysql(trx);
3463
3460
 
3464
3461
                if (err != DB_SUCCESS) {
3465
3462
                        fputs("InnoDB: DROP DATABASE ", stderr);
3468
3465
                                (ulint) err);
3469
3466
                        ut_print_name(stderr, trx, TRUE, table_name);
3470
3467
                        putc('\n', stderr);
 
3468
                        mem_free(table_name);
3471
3469
                        break;
3472
3470
                }
 
3471
 
 
3472
                mem_free(table_name);
3473
3473
        }
3474
3474
 
3475
3475
        if (err == DB_SUCCESS) {