Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************************************//**
- This special handling is really to overcome the limitations of MySQL's
- binlogging. We need to eliminate the non-determinism that will arise in
- INSERT ... SELECT type of statements, since MySQL binlog only stores the
- min value of the autoinc interval. Once that is fixed we can get rid of
- the special lock handling.
- @return DB_SUCCESS if all OK else error code */
- UNIV_INTERN
- dberr_t
- ha_innobase::innobase_lock_autoinc(void)
- /*====================================*/
- {
- dberr_t error = DB_SUCCESS;
- ut_ad(!srv_read_only_mode);
- switch (innobase_autoinc_lock_mode) {
- case AUTOINC_NO_LOCKING:
- /* Acquire only the AUTOINC mutex. */
- dict_table_autoinc_lock(prebuilt->table);
- break;
- case AUTOINC_NEW_STYLE_LOCKING:
- /* For simple (single/multi) row INSERTs, we fallback to the
- old style only if another transaction has already acquired
- the AUTOINC lock on behalf of a LOAD FILE or INSERT ... SELECT
- etc. type of statement. */
- /* If this is (single/multi) row INSERTs/REPLACEs, or
- slave thread executing Write_rows_log_event */
- fprintf(stderr, "JANK: thd_sql_command(user_thd) %d\n", thd_sql_command(user_thd));
- if (thd_sql_command(user_thd) == SQLCOM_INSERT
- || thd_sql_command(user_thd) == SQLCOM_REPLACE
- || (thd_slave_thread(user_thd) && thd_sql_command(user_thd) == SQLCOM_END)) {
- dict_table_t* ib_table = prebuilt->table;
- /* Acquire the AUTOINC mutex. */
- dict_table_autoinc_lock(ib_table);
- /* We need to check that another transaction isn't
- already holding the AUTOINC lock on the table. */
- if (ib_table->n_waiting_or_granted_auto_inc_locks) {
- /* Release the mutex to avoid deadlocks. */
- dict_table_autoinc_unlock(ib_table);
- } else {
- /* Do not fall back to old style autoinc
- locking */
- break;
- }
- }
- /* Fall through to old style locking. */
- case AUTOINC_OLD_STYLE_LOCKING:
- error = row_lock_table_autoinc_for_mysql(prebuilt); // THIS WILL TAKE INTERNAL AUTOINC TABLE LOCK
- if (error == DB_SUCCESS) {
- /* Acquire the AUTOINC mutex. */
- dict_table_autoinc_lock(prebuilt->table);
- }
- break;
- default:
- ut_error;
- }
- return(error);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement