MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:ramil Date:September 28 2006 6:43am
Subject:bk commit into 4.1 tree (ramil:1.2539) BUG#20732
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@stripped, 2006-09-28 11:43:40+05:00, ramil@stripped +3 -0
  Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
  
  We miss some records sometimes using RANGE method if we have 
  partial key segments.
  Example:
    create table t1(a char(2), key(a(1)));                                          
    insert into t1 values ('a'), ('xx');                                            
    select a from t1 where a > 'x';                                                 
  We call index_read() passing 'x' key and HA_READ_AFTER_KEY flag
  in the handler::read_range_first() wich is wrong because we have 
  a partial key segment for the field and might miss records like 'xx'.
  
  Fix: don't use open segments in such a case.

  mysql-test/r/range.result@stripped, 2006-09-28 11:43:34+05:00, ramil@stripped +10 -0
    Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
      - test result

  mysql-test/t/range.test@stripped, 2006-09-28 11:43:34+05:00, ramil@stripped +11 -1
    Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
      - test case

  sql/opt_range.cc@stripped, 2006-09-28 11:43:34+05:00, ramil@stripped +10 -8
    Fix for bug #20732: Partial index and long sjis search with '>' fails sometimes
      - check if we have a partial key segment for a Item_func::GT_FUNC; 
        if so, don't set NEAR_MIN flag in order to use HA_READ_KEY_OR_NEXT 
        instead of HA_READ_AFTER_KEY.
    
        Note: we cannot use HA_PART_KEY_SEG here as it's also set for fields            
        that can be NULL (see sql/table.cc).

# 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:	myoffice.izhnet.ru
# Root:	/usr/home/ram/work/bug20732/my41-bug20732

--- 1.147/sql/opt_range.cc	2006-09-28 11:43:49 +05:00
+++ 1.148/sql/opt_range.cc	2006-09-28 11:43:49 +05:00
@@ -396,9 +396,9 @@ typedef struct st_qsel_param {
 static SEL_TREE * get_mm_parts(PARAM *param,COND *cond_func,Field *field,
 			       Item_func::Functype type,Item *value,
 			       Item_result cmp_type);
-static SEL_ARG *get_mm_leaf(PARAM *param,COND *cond_func,Field *field,
-			    KEY_PART *key_part,
-			    Item_func::Functype type,Item *value);
+static SEL_ARG *get_mm_leaf(PARAM *param, COND *cond_func, Field *orig_field,
+                            Field *field, KEY_PART *key_part,
+			    Item_func::Functype type, Item *value);
 static SEL_TREE *get_mm_tree(PARAM *param,COND *cond);
 static ha_rows check_quick_select(PARAM *param,uint index,SEL_ARG *key_tree);
 static ha_rows check_quick_keys(PARAM *param,uint index,SEL_ARG *key_tree,
@@ -1146,8 +1146,8 @@ get_mm_parts(PARAM *param, COND *cond_fu
 	DBUG_RETURN(0);				// OOM
       if (!value || !(value->used_tables() & ~param->read_tables))
       {
-	sel_arg=get_mm_leaf(param,cond_func,
-			    key_part->field,key_part,type,value);
+	sel_arg= get_mm_leaf(param, cond_func, field, key_part->field,
+                             key_part, type, value);
 	if (!sel_arg)
 	  continue;
 	if (sel_arg->type == SEL_ARG::IMPOSSIBLE)
@@ -1182,8 +1182,8 @@ get_mm_parts(PARAM *param, COND *cond_fu
 
 
 static SEL_ARG *
-get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
-	    Item_func::Functype type,Item *value)
+get_mm_leaf(PARAM *param, COND *conf_func, Field *orig_field, Field *field, 
+            KEY_PART *key_part, Item_func::Functype type, Item *value)
 {
   uint maybe_null=(uint) field->real_maybe_null(), copies;
   uint field_length=field->pack_length()+maybe_null;
@@ -1398,7 +1398,9 @@ get_mm_leaf(PARAM *param, COND *conf_fun
     }
     break;
   case Item_func::GT_FUNC:
-    if (field_is_equal_to_item(field,value))
+    /* Don't use open ranges for partial key segments */
+    if (field_is_equal_to_item(field,value) && 
+        (orig_field->key_length() == key_part->length))
       tree->min_flag=NEAR_MIN;
     /* fall through */
   case Item_func::GE_FUNC:

--- 1.35/mysql-test/r/range.result	2006-09-28 11:43:49 +05:00
+++ 1.36/mysql-test/r/range.result	2006-09-28 11:43:49 +05:00
@@ -649,3 +649,13 @@ OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 )))
 pk1	pk2	pk3	pk4	filler
 2621	2635	1000015	0	filler
 drop table t1, t2;
+create table t1(a char(2), key(a(1)));
+insert into t1 values ('x'), ('xx');
+explain select a from t1 where a > 'x';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	a	a	2	NULL	2	Using where
+select a from t1 where a > 'x';
+a
+xx
+drop table t1;
+End of 4.1 tests

--- 1.31/mysql-test/t/range.test	2006-09-28 11:43:49 +05:00
+++ 1.32/mysql-test/t/range.test	2006-09-28 11:43:49 +05:00
@@ -510,4 +510,14 @@ OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 )))
 ) AND (pk3 >=1000000);
 drop table t1, t2;
 
-# End of 4.1 tests
+#
+# Bug #20732: Partial index and long sjis search with '>' fails sometimes
+#
+
+create table t1(a char(2), key(a(1)));
+insert into t1 values ('x'), ('xx');
+explain select a from t1 where a > 'x';
+select a from t1 where a > 'x';
+drop table t1;
+
+--echo End of 4.1 tests
Thread
bk commit into 4.1 tree (ramil:1.2539) BUG#20732ramil28 Sep