List:Commits« Previous MessageNext Message »
From:msvensson Date:January 30 2006 3:07pm
Subject:bk commit into 5.0 tree (msvensson:1.2014)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson 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.2014 06/01/30 16:07:26 msvensson@neptunus.(none) +5 -0
  Merge neptunus.(none):/home/msvensson/mysql/tmp/.10720
  into  neptunus.(none):/home/msvensson/mysql/mysql-5.0

  sql/ha_heap.h
    1.39 06/01/30 16:07:22 msvensson@neptunus.(none) +1 -0
    Merge

  sql/ha_heap.cc
    1.75 06/01/30 16:07:22 msvensson@neptunus.(none) +0 -4
    Merge

  mysql-test/r/heap.result
    1.43 06/01/30 16:07:22 msvensson@neptunus.(none) +1 -1
    Merge

  mysql-test/t/heap.test
    1.31 06/01/30 15:58:27 msvensson@neptunus.(none) +0 -0
    Auto merged

  heap/hp_create.c
    1.22 06/01/30 15:58:27 msvensson@neptunus.(none) +0 -0
    Auto merged

# 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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/mysql-5.0/RESYNC

--- 1.21/heap/hp_create.c	2005-10-27 19:04:31 +02:00
+++ 1.22/heap/hp_create.c	2006-01-30 15:58:27 +01:00
@@ -135,6 +135,7 @@
       DBUG_RETURN(1);
     }
     share->keydef= (HP_KEYDEF*) (share + 1);
+    share->key_stat_version= 1;
     keyseg= (HA_KEYSEG*) (share->keydef + keys);
     init_block(&share->block, reclength + 1, min_records, max_records);
 	/* Fix keys */

--- 1.74/sql/ha_heap.cc	2005-10-03 05:03:41 +02:00
+++ 1.75/sql/ha_heap.cc	2006-01-30 16:07:22 +01:00
@@ -104,7 +104,7 @@
       ha_heap::info(), which is always called before key statistics are
       used.
     */
-    key_stats_ok= FALSE;
+    key_stat_version= file->s->key_stat_version-1;
   }
   return (file ? 0 : 1);
 }
@@ -151,14 +151,21 @@
       continue;
     if (key->algorithm != HA_KEY_ALG_BTREE)
     {
-      ha_rows hash_buckets= file->s->keydef[i].hash_buckets;
-      key->rec_per_key[key->key_parts-1]= 
-        hash_buckets ? file->s->records/hash_buckets : 0;
+      if (key->flags & HA_NOSAME)
+        key->rec_per_key[key->key_parts-1]= 1;
+      else
+      {
+        ha_rows hash_buckets= file->s->keydef[i].hash_buckets;
+        uint no_records= hash_buckets ? file->s->records/hash_buckets : 2;
+        if (no_records < 2)
+          no_records= 2;
+        key->rec_per_key[key->key_parts-1]= no_records;
+      }
     }
   }
   records_changed= 0;
   /* At the end of update_key_stats() we can proudly claim they are OK. */
-  key_stats_ok= TRUE;
+  key_stat_version= file->s->key_stat_version;
 }
 
 
@@ -173,7 +180,7 @@
   res= heap_write(file,buf);
   if (!res && (++records_changed*HEAP_STATS_UPDATE_THRESHOLD > 
                file->s->records))
-    key_stats_ok= FALSE;
+    file->s->key_stat_version++;
   return res;
 }
 
@@ -186,7 +193,7 @@
   res= heap_update(file,old_data,new_data);
   if (!res && ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > 
               file->s->records)
-    key_stats_ok= FALSE;
+    file->s->key_stat_version++;
   return res;
 }
 
@@ -197,7 +204,7 @@
   res= heap_delete(file,buf);
   if (!res && table->s->tmp_table == NO_TMP_TABLE && 
       ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records)
-    key_stats_ok= FALSE;
+    file->s->key_stat_version++;
   return res;
 }
 
@@ -324,7 +331,7 @@
     have to update the key statistics. Hoping that a table lock is now
     in place.
   */
-  if (! key_stats_ok)
+  if (key_stat_version != file->s->key_stat_version)
     update_key_stats();
 }
 
@@ -337,7 +344,7 @@
 {
   heap_clear(file);
   if (table->s->tmp_table == NO_TMP_TABLE)
-    key_stats_ok= FALSE;
+    file->s->key_stat_version++;
   return 0;
 }
 
@@ -496,10 +503,14 @@
       min_key->flag != HA_READ_KEY_EXACT ||
       max_key->flag != HA_READ_AFTER_KEY)
     return HA_POS_ERROR;			// Can only use exact keys
-
-  /* Assert that info() did run. We need current statistics here. */
-  DBUG_ASSERT(key_stats_ok);
-  return key->rec_per_key[key->key_parts-1];
+    if (records <= 1)
+      return records;
+    else
+    {
+      /* Assert that info() did run. We need current statistics here. */
+      DBUG_ASSERT(key_stat_version == file->s->key_stat_version);
+      return key->rec_per_key[key->key_parts-1];
+    }
 }
 
 

--- 1.38/sql/ha_heap.h	2005-08-05 22:19:44 +02:00
+++ 1.39/sql/ha_heap.h	2006-01-30 16:07:22 +01:00
@@ -29,8 +29,10 @@
   key_map btree_keys;
   /* number of records changed since last statistics update */
   uint    records_changed;
-  bool    key_stats_ok;
+  uint    key_stat_version;
 public:
+  ha_heap(TABLE *table): handler(table), file(0), records_changed(0),
+      key_stat_version(0) {}
   ha_heap(TABLE *table);
   ~ha_heap() {}
   const char *table_type() const

--- 1.42/mysql-test/r/heap.result	2005-09-29 23:34:15 +02:00
+++ 1.43/mysql-test/r/heap.result	2006-01-30 16:07:22 +01:00
@@ -182,7 +182,7 @@
 a	b
 explain SELECT * FROM t1 WHERE a IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	5	const	1	Using where
+1	SIMPLE	t1	ref	a	a	5	const	2	Using where
 SELECT * FROM t1 WHERE a<=>NULL;
 a	b
 NULL	99
@@ -700,6 +700,16 @@
 insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
 insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
 ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 1
+drop table t1;
+CREATE TABLE t1 (a int, key(a)) engine=heap;
+insert delayed into t1 values (0);
+delete from t1;
+select * from t1;
+a
+insert delayed into t1 values (0), (1);
+select * from t1 where a = 0;
+a
+0
 drop table t1;
 create table t1 (c char(10)) engine=memory;
 create table t2 (c varchar(10)) engine=memory;

--- 1.30/mysql-test/t/heap.test	2005-08-09 10:21:41 +02:00
+++ 1.31/mysql-test/t/heap.test	2006-01-30 15:58:27 +01:00
@@ -436,6 +436,17 @@
 insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
 drop table t1;
 
+#
+# Bug 12796: Record doesn't show when selecting through index
+#
+CREATE TABLE t1 (a int, key(a)) engine=heap;
+insert delayed into t1 values (0);
+delete from t1;
+select * from t1;
+insert delayed into t1 values (0), (1);
+select * from t1 where a = 0;
+drop table t1;
+
 # End of 4.1 tests
 
 #
Thread
bk commit into 5.0 tree (msvensson:1.2014)msvensson30 Jan