=== modified file 'sql/handler.cc' --- sql/handler.cc 2009-03-27 09:34:24 +0000 +++ sql/handler.cc 2009-05-18 08:17:38 +0000 @@ -2149,6 +2149,9 @@ set_next_insert_id(compute_next_insert_id(nr, &table->in_use->variables)); } +bool handler::is_auto_inc_singleton(){ + return true; +} /** @brief Computes the largest number X: @@ -2359,7 +2362,7 @@ nr= compute_next_insert_id(nr-1, variables); } - if (table->s->next_number_keypart == 0) + if (!is_auto_inc_singleton() || table->s->next_number_keypart == 0) { /* We must defer the appending until "nr" has been possibly truncated */ append= TRUE; === modified file 'sql/handler.h' --- sql/handler.h 2008-12-10 20:14:50 +0000 +++ sql/handler.h 2009-05-18 08:25:58 +0000 @@ -1261,6 +1261,12 @@ int ha_rename_partitions(const char *path); void adjust_next_insert_id_after_explicit_value(ulonglong nr); + /** + Some storage engines can perform auto increment properly even if the autoincrement column + is not the first column of any key. Such storage engines should return false. + By default this method returns true. + */ + virtual bool is_auto_inc_singleton(); int update_auto_increment(); void print_keydup_error(uint key_nr, const char *msg); virtual void print_error(int error, myf errflag);