Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. /********************************************************************//**
  2. This special handling is really to overcome the limitations of MySQL's
  3. binlogging. We need to eliminate the non-determinism that will arise in
  4. INSERT ... SELECT type of statements, since MySQL binlog only stores the
  5. min value of the autoinc interval. Once that is fixed we can get rid of
  6. the special lock handling.
  7. @return DB_SUCCESS if all OK else error code */
  8. UNIV_INTERN
  9. dberr_t
  10. ha_innobase::innobase_lock_autoinc(void)
  11. /*====================================*/
  12. {
  13. dberr_t error = DB_SUCCESS;
  14.  
  15. ut_ad(!srv_read_only_mode);
  16.  
  17. switch (innobase_autoinc_lock_mode) {
  18. case AUTOINC_NO_LOCKING:
  19. /* Acquire only the AUTOINC mutex. */
  20. dict_table_autoinc_lock(prebuilt->table);
  21. break;
  22.  
  23. case AUTOINC_NEW_STYLE_LOCKING:
  24. /* For simple (single/multi) row INSERTs, we fallback to the
  25. old style only if another transaction has already acquired
  26. the AUTOINC lock on behalf of a LOAD FILE or INSERT ... SELECT
  27. etc. type of statement. */
  28.  
  29. /* If this is (single/multi) row INSERTs/REPLACEs, or
  30. slave thread executing Write_rows_log_event */
  31.  
  32. fprintf(stderr, "JANK: thd_sql_command(user_thd) %d\n", thd_sql_command(user_thd));
  33.  
  34. if (thd_sql_command(user_thd) == SQLCOM_INSERT
  35. || thd_sql_command(user_thd) == SQLCOM_REPLACE
  36. || (thd_slave_thread(user_thd) && thd_sql_command(user_thd) == SQLCOM_END)) {
  37. dict_table_t* ib_table = prebuilt->table;
  38.  
  39. /* Acquire the AUTOINC mutex. */
  40. dict_table_autoinc_lock(ib_table);
  41.  
  42. /* We need to check that another transaction isn't
  43. already holding the AUTOINC lock on the table. */
  44. if (ib_table->n_waiting_or_granted_auto_inc_locks) {
  45. /* Release the mutex to avoid deadlocks. */
  46. dict_table_autoinc_unlock(ib_table);
  47. } else {
  48. /* Do not fall back to old style autoinc
  49. locking */
  50. break;
  51. }
  52. }
  53. /* Fall through to old style locking. */
  54.  
  55. case AUTOINC_OLD_STYLE_LOCKING:
  56. error = row_lock_table_autoinc_for_mysql(prebuilt); // THIS WILL TAKE INTERNAL AUTOINC TABLE LOCK
  57.  
  58. if (error == DB_SUCCESS) {
  59.  
  60. /* Acquire the AUTOINC mutex. */
  61. dict_table_autoinc_lock(prebuilt->table);
  62. }
  63. break;
  64.  
  65. default:
  66. ut_error;
  67. }
  68.  
  69. return(error);
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement