Commit b0a0c542 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Fixed bug in auto-increment handling with InnoDB

Some small speedups
parent 2adf2fad
...@@ -46672,6 +46672,8 @@ not yet 100% confident in this code. ...@@ -46672,6 +46672,8 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.42 @appendixsubsec Changes in release 3.23.42
@itemize @bullet @itemize @bullet
@item @item
Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns.
@item
Applied large patch for OS/2 from Yuri Dario. Applied large patch for OS/2 from Yuri Dario.
@item @item
Fixed problem with InnoDB when one could get the error @code{Can't Fixed problem with InnoDB when one could get the error @code{Can't
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee> ** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee>
**/ **/
#define DUMP_VERSION "8.14" #define DUMP_VERSION "8.15"
#include <global.h> #include <global.h>
#include <my_sys.h> #include <my_sys.h>
...@@ -1224,6 +1224,7 @@ static int dump_all_tables_in_db(char *database) ...@@ -1224,6 +1224,7 @@ static int dump_all_tables_in_db(char *database)
{ {
char *table; char *table;
uint numrows; uint numrows;
char table_buff[NAME_LEN+3];
if (init_dumping(database)) if (init_dumping(database))
return 1; return 1;
...@@ -1233,7 +1234,7 @@ static int dump_all_tables_in_db(char *database) ...@@ -1233,7 +1234,7 @@ static int dump_all_tables_in_db(char *database)
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (numrows=0 ; (table = getTableName(1)) ; numrows++) for (numrows=0 ; (table = getTableName(1)) ; numrows++)
{ {
dynstr_append(&query, table); dynstr_append(&query, quote_name(table,table_buff));
dynstr_append(&query, " READ /*!32311 LOCAL */,"); dynstr_append(&query, " READ /*!32311 LOCAL */,");
} }
if (numrows && mysql_real_query(sock, query.str, query.length-1)) if (numrows && mysql_real_query(sock, query.str, query.length-1))
...@@ -1263,6 +1264,7 @@ static int dump_all_tables_in_db(char *database) ...@@ -1263,6 +1264,7 @@ static int dump_all_tables_in_db(char *database)
static int dump_selected_tables(char *db, char **table_names, int tables) static int dump_selected_tables(char *db, char **table_names, int tables)
{ {
uint numrows; uint numrows;
char table_buff[NAME_LEN+3];
if (init_dumping(db)) if (init_dumping(db))
return 1; return 1;
...@@ -1274,7 +1276,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) ...@@ -1274,7 +1276,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024); init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (i=0 ; i < tables ; i++) for (i=0 ; i < tables ; i++)
{ {
dynstr_append(&query, table_names[i]); dynstr_append(&query, quote_name(table_names[i],table_buff));
dynstr_append(&query, " READ /*!32311 LOCAL */,"); dynstr_append(&query, " READ /*!32311 LOCAL */,");
} }
if (mysql_real_query(sock, query.str, query.length-1)) if (mysql_real_query(sock, query.str, query.length-1))
......
...@@ -31,14 +31,16 @@ ...@@ -31,14 +31,16 @@
void caseup_str(my_string str) void caseup_str(my_string str)
{ {
#ifdef USE_MB #ifdef USE_MB
if (use_mb(default_charset_info))
{
register uint32 l; register uint32 l;
register char *end=str+(uint) strlen(str); register char *end=str+(uint) strlen(str);
if (use_mb(default_charset_info))
while (*str) while (*str)
{ {
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=toupper(*str),++str; else *str=toupper(*str),++str;
} }
}
else else
#endif #endif
while ((*str = toupper(*str)) != 0) while ((*str = toupper(*str)) != 0)
...@@ -50,14 +52,16 @@ void caseup_str(my_string str) ...@@ -50,14 +52,16 @@ void caseup_str(my_string str)
void casedn_str(my_string str) void casedn_str(my_string str)
{ {
#ifdef USE_MB #ifdef USE_MB
if (use_mb(default_charset_info))
{
register uint32 l; register uint32 l;
register char *end=str+(uint) strlen(str); register char *end=str+(uint) strlen(str);
if (use_mb(default_charset_info))
while (*str) while (*str)
{ {
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=tolower(*str),++str; else *str=tolower(*str),++str;
} }
}
else else
#endif #endif
while ((*str= tolower(*str)) != 0) while ((*str= tolower(*str)) != 0)
...@@ -70,14 +74,16 @@ void casedn_str(my_string str) ...@@ -70,14 +74,16 @@ void casedn_str(my_string str)
void caseup(my_string str, uint length) void caseup(my_string str, uint length)
{ {
#ifdef USE_MB #ifdef USE_MB
if (use_mb(default_charset_info))
{
register uint32 l; register uint32 l;
register char *end=str+length; register char *end=str+length;
if (use_mb(default_charset_info))
while (str<end) while (str<end)
{ {
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=toupper(*str),++str; else *str=toupper(*str),++str;
} }
}
else else
#endif #endif
for ( ; length>0 ; length--, str++) for ( ; length>0 ; length--, str++)
...@@ -89,14 +95,16 @@ void caseup(my_string str, uint length) ...@@ -89,14 +95,16 @@ void caseup(my_string str, uint length)
void casedn(my_string str, uint length) void casedn(my_string str, uint length)
{ {
#ifdef USE_MB #ifdef USE_MB
if (use_mb(default_charset_info))
{
register uint32 l; register uint32 l;
register char *end=str+length; register char *end=str+length;
if (use_mb(default_charset_info))
while (str<end) while (str<end)
{ {
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l; if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=tolower(*str),++str; else *str=tolower(*str),++str;
} }
}
else else
#endif #endif
for ( ; length>0 ; length--, str++) for ( ; length>0 ; length--, str++)
...@@ -143,10 +151,10 @@ my_string my_strcasestr(const char *str, const char *search) ...@@ -143,10 +151,10 @@ my_string my_strcasestr(const char *str, const char *search)
int my_strcasecmp(const char *s, const char *t) int my_strcasecmp(const char *s, const char *t)
{ {
#ifdef USE_MB #ifdef USE_MB
register uint32 l;
register const char *end=s+(uint) strlen(s);
if (use_mb(default_charset_info)) if (use_mb(default_charset_info))
{ {
register uint32 l;
register const char *end=s+(uint) strlen(s);
while (s<end) while (s<end)
{ {
if ((l=my_ismbchar(default_charset_info, s,end))) if ((l=my_ismbchar(default_charset_info, s,end)))
...@@ -172,10 +180,10 @@ int my_strcasecmp(const char *s, const char *t) ...@@ -172,10 +180,10 @@ int my_strcasecmp(const char *s, const char *t)
int my_casecmp(const char *s, const char *t, uint len) int my_casecmp(const char *s, const char *t, uint len)
{ {
#ifdef USE_MB #ifdef USE_MB
register uint32 l;
register const char *end=s+len;
if (use_mb(default_charset_info)) if (use_mb(default_charset_info))
{ {
register uint32 l;
register const char *end=s+len;
while (s<end) while (s<end)
{ {
if ((l=my_ismbchar(default_charset_info, s,end))) if ((l=my_ismbchar(default_charset_info, s,end)))
......
...@@ -562,7 +562,7 @@ if ($limits->{'group_functions'}) ...@@ -562,7 +562,7 @@ if ($limits->{'group_functions'})
fetch_all_rows($dbh,"select min(id) from bench1"); fetch_all_rows($dbh,"select min(id) from bench1");
fetch_all_rows($dbh,"select max(id) from bench1"); fetch_all_rows($dbh,"select max(id) from bench1");
fetch_all_rows($dbh,"select sum(id+0.0) from bench1"); fetch_all_rows($dbh,"select sum(id+0.0) from bench1");
fetch_all_rows($dbh,"select min(id3),max(id3),sum(id3 +0.0) from bench1"); fetch_all_rows($dbh,"select min(id3),max(id3),sum(id3-0.0) from bench1");
if ($limits->{'group_func_sql_min_str'}) if ($limits->{'group_func_sql_min_str'})
{ {
fetch_all_rows($dbh,"select min(dummy1),max(dummy1) from bench1"); fetch_all_rows($dbh,"select min(dummy1),max(dummy1) from bench1");
...@@ -579,7 +579,7 @@ if ($limits->{'group_functions'}) ...@@ -579,7 +579,7 @@ if ($limits->{'group_functions'})
$count++; $count++;
$sth=$dbh->prepare($query="select count(*),sum(id+0.0),min(id),max(id),avg(id+0.0) from bench1") or die $DBI::errstr; $sth=$dbh->prepare($query="select count(*),sum(id+0.0),min(id),max(id),avg(id-0.0) from bench1") or die $DBI::errstr;
$sth->execute or die $DBI::errstr; $sth->execute or die $DBI::errstr;
@row=$sth->fetchrow_array; @row=$sth->fetchrow_array;
if ($row[0] != $total_rows || if ($row[0] != $total_rows ||
......
...@@ -136,12 +136,12 @@ if ($limits->{'group_functions'}) ...@@ -136,12 +136,12 @@ if ($limits->{'group_functions'})
print "Test if the database has a query cache\n"; print "Test if the database has a query cache\n";
# First ensure that the table is read into memory # First ensure that the table is read into memory
fetch_all_rows($dbh,"select sum(idn+$tmp),sum(rev_idn+$tmp) from bench1"); fetch_all_rows($dbh,"select sum(idn+$tmp),sum(rev_idn-$tmp) from bench1");
$loop_time=new Benchmark; $loop_time=new Benchmark;
for ($tests=0 ; $tests < $opt_loop_count ; $tests++) for ($tests=0 ; $tests < $opt_loop_count ; $tests++)
{ {
fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn+$tests) from bench1"); fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn-$tests) from bench1");
} }
$end_time=new Benchmark; $end_time=new Benchmark;
print "Time for select_query_cache ($opt_loop_count): " . print "Time for select_query_cache ($opt_loop_count): " .
...@@ -153,7 +153,7 @@ if ($limits->{'group_functions'}) ...@@ -153,7 +153,7 @@ if ($limits->{'group_functions'})
$loop_time=new Benchmark; $loop_time=new Benchmark;
for ($tests=0 ; $tests < $opt_loop_count ; $tests++) for ($tests=0 ; $tests < $opt_loop_count ; $tests++)
{ {
fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn+$tests) from bench1"); fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn-$tests) from bench1");
} }
$end_time=new Benchmark; $end_time=new Benchmark;
print "Time for select_query_cache2 ($opt_loop_count): " . print "Time for select_query_cache2 ($opt_loop_count): " .
......
...@@ -300,6 +300,7 @@ class Field_tiny :public Field_num { ...@@ -300,6 +300,7 @@ class Field_tiny :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -328,6 +329,7 @@ class Field_short :public Field_num { ...@@ -328,6 +329,7 @@ class Field_short :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -356,6 +358,7 @@ class Field_medium :public Field_num { ...@@ -356,6 +358,7 @@ class Field_medium :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -389,6 +392,7 @@ class Field_long :public Field_num { ...@@ -389,6 +392,7 @@ class Field_long :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -423,6 +427,7 @@ class Field_longlong :public Field_num { ...@@ -423,6 +427,7 @@ class Field_longlong :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -449,6 +454,7 @@ class Field_float :public Field_num { ...@@ -449,6 +454,7 @@ class Field_float :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { bzero(ptr,sizeof(float)); }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -480,6 +486,7 @@ class Field_double :public Field_num { ...@@ -480,6 +486,7 @@ class Field_double :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { bzero(ptr,sizeof(double)); }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -505,6 +512,7 @@ class Field_null :public Field_str { ...@@ -505,6 +512,7 @@ class Field_null :public Field_str {
void store(const char *to, uint length) { null[0]=1; } void store(const char *to, uint length) { null[0]=1; }
void store(double nr) { null[0]=1; } void store(double nr) { null[0]=1; }
void store(longlong nr) { null[0]=1; } void store(longlong nr) { null[0]=1; }
void reset(void) {}
double val_real(void) { return 0.0;} double val_real(void) { return 0.0;}
longlong val_int(void) { return 0;} longlong val_int(void) { return 0;}
String *val_str(String *value,String *value2) String *val_str(String *value,String *value2)
...@@ -528,6 +536,7 @@ class Field_timestamp :public Field_num { ...@@ -528,6 +536,7 @@ class Field_timestamp :public Field_num {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -588,6 +597,7 @@ class Field_date :public Field_str { ...@@ -588,6 +597,7 @@ class Field_date :public Field_str {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -615,6 +625,7 @@ class Field_newdate :public Field_str { ...@@ -615,6 +625,7 @@ class Field_newdate :public Field_str {
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void store_time(TIME *ltime,timestamp_type type); void store_time(TIME *ltime,timestamp_type type);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -643,6 +654,7 @@ class Field_time :public Field_str { ...@@ -643,6 +654,7 @@ class Field_time :public Field_str {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -673,6 +685,7 @@ class Field_datetime :public Field_str { ...@@ -673,6 +685,7 @@ class Field_datetime :public Field_str {
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void store_time(TIME *ltime,timestamp_type type); void store_time(TIME *ltime,timestamp_type type);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
...@@ -922,6 +935,7 @@ class Field_enum :public Field_str { ...@@ -922,6 +935,7 @@ class Field_enum :public Field_str {
void store(const char *to,uint length); void store(const char *to,uint length);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset() { bzero(ptr,packlength); }
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); String *val_str(String*,String *);
......
...@@ -472,7 +472,7 @@ int main(int argc,char **argv) ...@@ -472,7 +472,7 @@ int main(int argc,char **argv)
int error; int error;
MY_INIT(argv[0]); MY_INIT(argv[0]);
start_value=487844L; best_t1=4969454L; best_t2=2266538L; best_type=2; /* mode=4567 add=5 type: 0 */ start_value=4597269L; best_t1=6001982L; best_t2=5063828L; best_type=4; /* mode=4513 add=8 type: 0 */
if (get_options(argc,(char **) argv)) if (get_options(argc,(char **) argv))
exit(1); exit(1);
......
...@@ -1334,6 +1334,8 @@ ha_innobase::write_row( ...@@ -1334,6 +1334,8 @@ ha_innobase::write_row(
autoincrement field */ autoincrement field */
auto_inc = table->next_number_field->val_int(); auto_inc = table->next_number_field->val_int();
if (auto_inc == 0)
auto_inc= user_thd->next_insert_id;
if (auto_inc != 0) { if (auto_inc != 0) {
/* This call will calculate the max of the /* This call will calculate the max of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment