List:Internals« Previous MessageNext Message »
From:ramil Date:March 15 2005 10:32am
Subject:bk commit into 4.1 tree (ramil:1.2112) BUG#8489
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2112 05/03/15 13:32:12 ramil@stripped +5 -0
  A fix (bug #8489: Strange auto_increment behaviour with HEAP table).

  sql/ha_heap.cc
    1.50 05/03/15 13:32:08 ramil@stripped +8 -4
    A fix (bug #8489: Strange auto_increment behaviour with HEAP table).
    Handle autoincrement keys MyISAM-way.

  mysql-test/t/heap.test
    1.20 05/03/15 13:32:08 ramil@stripped +29 -0
    A fix (bug #8489: Strange auto_increment behaviour with HEAP table).

  mysql-test/r/heap.result
    1.28 05/03/15 13:32:08 ramil@stripped +42 -0
    A fix (bug #8489: Strange auto_increment behaviour with HEAP table).

  include/heap.h
    1.23 05/03/15 13:32:08 ramil@stripped +1 -1
    A fix (bug #8489: Strange auto_increment behaviour with HEAP table).
    Handle autoincrement keys MyISAM-way.

  heap/hp_create.c
    1.16 05/03/15 13:32:08 ramil@stripped +2 -1
    A fix (bug #8489: Strange auto_increment behaviour with HEAP table).
    Handle autoincrement keys MyISAM-way.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ramil
# Host:	gw.mysql.r18.ru
# Root:	/usr/home/ram/work/4.1

--- 1.15/heap/hp_create.c	2005-01-14 22:49:38 +04:00
+++ 1.16/heap/hp_create.c	2005-03-15 13:32:08 +04:00
@@ -137,6 +137,8 @@
 	keyinfo->write_key= hp_write_key;
         keyinfo->hash_buckets= 0;
       }
+      if ((keyinfo->flag & HA_AUTO_KEY) &&
create_info->with_auto_increment)
+        share->auto_key= i + 1;
     }
     share->min_records= min_records;
     share->max_records= max_records;
@@ -147,7 +149,6 @@
     share->keys= keys;
     share->max_key_length= max_length;
     share->changed= 0;
-    share->auto_key= create_info->auto_key;
     share->auto_key_type= create_info->auto_key_type;
     share->auto_increment= create_info->auto_increment;
     /* Must be allocated separately for rename to work */

--- 1.22/include/heap.h	2005-01-14 22:49:38 +04:00
+++ 1.23/include/heap.h	2005-03-15 13:32:08 +04:00
@@ -183,10 +183,10 @@
 
 typedef struct st_heap_create_info
 {
-  uint auto_key;
   uint auto_key_type;
   ulong max_table_size;
   ulonglong auto_increment;
+  my_bool with_auto_increment;
 } HP_CREATE_INFO;
 
 	/* Prototypes for heap-functions */

--- 1.49/sql/ha_heap.cc	2005-02-09 00:44:49 +04:00
+++ 1.50/sql/ha_heap.cc	2005-03-15 13:32:08 +04:00
@@ -446,6 +446,7 @@
   HA_KEYSEG *seg;
   char buff[FN_REFLEN];
   int error;
+  bool found_real_auto_increment= 0;
 
   for (key= parts= 0; key < table_arg->keys; key++)
     parts+= table_arg->key_info[key].key_parts;
@@ -506,17 +507,20 @@
 	seg->null_bit= 0;
 	seg->null_pos= 0;
       }
+      // We have to store field->key_type() as seg->type can differ from it
       if (field->flags & AUTO_INCREMENT_FLAG)
-      {
-	auto_key= key + 1;
 	auto_key_type= field->key_type();
-      }
     }
   }
+  if (table_arg->found_next_number_field)
+  {
+    keydef[table_arg->next_number_index].flag|= HA_AUTO_KEY;
+    found_real_auto_increment= table_arg->next_number_key_offset == 0;
+  }
   mem_per_row+= MY_ALIGN(table_arg->reclength + 1, sizeof(char*));
   HP_CREATE_INFO hp_create_info;
-  hp_create_info.auto_key= auto_key;
   hp_create_info.auto_key_type= auto_key_type;
+  hp_create_info.with_auto_increment= found_real_auto_increment;
   hp_create_info.auto_increment= (create_info->auto_increment_value ?
 				  create_info->auto_increment_value - 1 : 0);
   hp_create_info.max_table_size=current_thd->variables.max_heap_table_size;

--- 1.27/mysql-test/r/heap.result	2004-12-02 15:06:11 +04:00
+++ 1.28/mysql-test/r/heap.result	2005-03-15 13:32:08 +04:00
@@ -249,3 +249,45 @@
 3
 2
 drop table t1;
+create table t1 (a bigint unsigned auto_increment primary key, b int,
+key (b, a)) engine=heap;
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+select * from t1;
+a	b
+1	1
+2	1
+3	1
+4	1
+5	1
+6	1
+7	1
+8	1
+drop table t1;
+create table t1 (a int not null, b int not null auto_increment,
+primary key(a, b), key(b)) engine=heap;
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+select * from t1;
+a	b
+1	1
+1	2
+1	3
+1	4
+1	5
+1	6
+1	7
+1	8
+drop table t1;

--- 1.19/mysql-test/t/heap.test	2004-12-02 15:06:11 +04:00
+++ 1.20/mysql-test/t/heap.test	2005-03-15 13:32:08 +04:00
@@ -195,3 +195,32 @@
 insert into t1 values ('2'), ('3');
 select * from t1;
 drop table t1;
+
+#
+# Bug #8489: Strange auto_increment behaviour
+#
+
+create table t1 (a bigint unsigned auto_increment primary key, b int,
+  key (b, a)) engine=heap;
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+select * from t1;                                                               
+drop table t1;
+create table t1 (a int not null, b int not null auto_increment,
+  primary key(a, b), key(b)) engine=heap;
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+select * from t1;                                                               
+drop table t1;
Thread
bk commit into 4.1 tree (ramil:1.2112) BUG#8489ramil15 Mar