List:Commits« Previous MessageNext Message »
From:ingo Date:March 1 2006 3:52pm
Subject:bk commit into 4.1 tree (ingo:1.2475) BUG#14980
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of mydev. When mydev 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.2475 06/03/01 16:52:47 ingo@stripped +5 -0
  Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
  
  For "count(*) while index_column = value" an index read
  is done. It consists of an index scan and retrieval of
  each key.
  
  For efficiency reasons the index scan stores the key in
  the special buffer 'lastkey2' once only. At the first 
  iteration it notes this fact with the flag 
  HA_STATE_RNEXT_SAME in 'info->update'.
  
  For efficiency reasons, the key retrieval for blobs
  does not allocate a new buffer, but uses 'lastkey2'...
  
  Now I clear the HA_STATE_RNEXT_SAME flag whenever the 
  buffer has been polluted. In this case, the index scan
  copies the key value again (and sets the flag again).

  mysql-test/t/myisam.test
    1.45 06/03/01 16:52:42 ingo@stripped +19 -0
    Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
    Added test.

  mysql-test/r/myisam.result
    1.59 06/03/01 16:52:42 ingo@stripped +18 -0
    Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
    Added test result.

  myisam/mi_rnext_same.c
    1.18 06/03/01 16:52:42 ingo@stripped +2 -2
    Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
    Removed trailing space and fixed a comment.

  myisam/mi_key.c
    1.37 06/03/01 16:52:42 ingo@stripped +2 -0
    Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
    Removing the flag HA_STATE_RNEXT_SAME from info->update
    if info->lastkey2 was reused for another purpose than
    index scanning.

  include/my_base.h
    1.66 06/03/01 16:52:42 ingo@stripped +1 -1
    Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
    Changed the comment for HA_STATE_RNEXT_SAME as a warning
    for future uses.

# 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:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-4.1-bug14980

--- 1.65/include/my_base.h	2005-11-21 12:27:55 +01:00
+++ 1.66/include/my_base.h	2006-03-01 16:52:42 +01:00
@@ -340,7 +340,7 @@
 #define HA_STATE_BUFF_SAVED	512	/* If current keybuff is info->buff */
 #define HA_STATE_ROW_CHANGED	1024	/* To invalide ROW cache */
 #define HA_STATE_EXTEND_BLOCK	2048
-#define HA_STATE_RNEXT_SAME	4096	/* rnext_same was called */
+#define HA_STATE_RNEXT_SAME	4096	/* rnext_same occupied lastkey2 */
 
 enum en_fieldtype {
   FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE,

--- 1.36/myisam/mi_key.c	2005-10-28 21:31:25 +02:00
+++ 1.37/myisam/mi_key.c	2006-03-01 16:52:42 +01:00
@@ -393,6 +393,8 @@
 	     (char*) &blob_ptr,sizeof(char*));
       memcpy(blob_ptr,key,length);
       blob_ptr+=length;
+      /* The above changed info->lastkey2. Inform mi_rnext_same(). */
+      info->update&= ~HA_STATE_RNEXT_SAME;
       _my_store_blob_length(record+keyseg->start,
 			    (uint) keyseg->bit_start,length);
       key+=length;

--- 1.17/myisam/mi_rnext_same.c	2005-10-25 01:27:29 +02:00
+++ 1.18/myisam/mi_rnext_same.c	2006-03-01 16:52:42 +01:00
@@ -40,7 +40,7 @@
 
   if (info->s->concurrent_insert)
     rw_rdlock(&info->s->key_root_lock[inx]);
-    
+
   switch (keyinfo->key_alg)
   {
 #ifdef HAVE_RTREE_KEYS
@@ -102,4 +102,4 @@
     DBUG_RETURN(0);
   }
   DBUG_RETURN(my_errno);
-} /* mi_rnext */
+} /* mi_rnext_same */

--- 1.58/mysql-test/r/myisam.result	2005-11-22 18:58:52 +01:00
+++ 1.59/mysql-test/r/myisam.result	2006-03-01 16:52:42 +01:00
@@ -730,3 +730,21 @@
 cip	time	score	bob
 1	00:01:00	0	NULL
 drop table t1;
+create table t1 (
+id1 int not null auto_increment,
+id2 int not null default '0',
+t text not null,
+primary key  (id1),
+key x (id2, t(32))
+) engine=myisam;
+insert into t1 (id2, t) values
+(10, 'abc'), (10, 'abc'), (10, 'abc'),
+(20, 'abc'), (20, 'abc'), (20, 'def'),
+(10, 'abc'), (10, 'abc');
+select count(*)   from t1 where id2 = 10;
+count(*)
+5
+select count(id1) from t1 where id2 = 10;
+count(id1)
+5
+drop table t1;

--- 1.44/mysql-test/t/myisam.test	2005-11-15 16:07:02 +01:00
+++ 1.45/mysql-test/t/myisam.test	2006-03-01 16:52:42 +01:00
@@ -686,4 +686,23 @@
 create index bug on t1 (bob(22), cip, time);
 select * from t1 where bob is null and cip=1;
 drop table t1;
+
+#
+# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
+#
+create table t1 (
+  id1 int not null auto_increment,
+  id2 int not null default '0',
+  t text not null,
+  primary key  (id1),
+  key x (id2, t(32))
+) engine=myisam;
+insert into t1 (id2, t) values
+(10, 'abc'), (10, 'abc'), (10, 'abc'),
+(20, 'abc'), (20, 'abc'), (20, 'def'),
+(10, 'abc'), (10, 'abc');
+select count(*)   from t1 where id2 = 10;
+select count(id1) from t1 where id2 = 10;
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (ingo:1.2475) BUG#14980ingo1 Mar