List:Commits« Previous MessageNext Message »
From:jonas oreland Date:November 4 2011 4:44pm
Subject:bzr push into mysql-5.1-telco-7.1 branch (jonas.oreland:4325 to 4326)
View as plain text  
 4326 jonas oreland	2011-11-04 [merge]
      ndb - merge 70 to 71

    modified:
      mysql-test/suite/ndb/r/ndb_condition_pushdown.result
      mysql-test/suite/ndb/t/ndb_condition_pushdown.test
      sql/ha_ndbcluster_cond.cc
      sql/ha_ndbcluster_cond.h
 4325 jonas oreland	2011-11-03 [merge]
      ndb - merge 70 to 71

    modified:
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
      storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp
      storage/ndb/src/kernel/vm/Rope.cpp
      storage/ndb/src/kernel/vm/Rope.hpp
=== modified file 'mysql-test/suite/ndb/r/ndb_condition_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2011-06-23 12:19:32 +0000
+++ b/mysql-test/suite/ndb/r/ndb_condition_pushdown.result	2011-11-04 08:33:56 +0000
@@ -2292,5 +2292,59 @@ pk1	pk1	pk2	pk2
 3	3	0	0
 4	3	0	0
 drop table t;
+create table mytable(i int, s varchar(255) ) engine = ndb;
+insert into mytable values(0,"Text Hej"),(1, "xText aaja");
+set engine_condition_pushdown=1;
+select * from mytable where s like concat("%Text","%") or s like concat("%Text","%") order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s like concat("%Text","%") or s like "%Text%" order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s like concat("%Text","%") or s like concat("%Text1","%") order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s like concat("%Text","%") or s like "%Text1%" order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s not like concat("%Text","%") or s not like concat("%Text","%") order by i;
+i	s
+select * from mytable where s not like concat("%Text1","%") or s not like concat("%Text","%") order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s like concat("%Text","%") or s not like "%Text%" order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s like concat("%Text1","%") or s not like "%Text%" order by i;
+i	s
+select * from mytable where s like concat("%Text","%") and s like concat("%Text","%") order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s like concat("%Text","%") and s like "%Text%" order by i;
+i	s
+0	Text Hej
+1	xText aaja
+select * from mytable where s like concat("%Text","%") and s like concat("%Text1","%") order by i;
+i	s
+select * from mytable where s like concat("%Text","%") and s like "%Text1%" order by i;
+i	s
+select * from mytable where s not like concat("%Text","%") and s not like concat("%Text","%") order by i;
+i	s
+select * from mytable where s not like concat("%Text","%") and s not like concat("%Text1","%") order by i;
+i	s
+select * from mytable where s like concat("%Text","%") and s not like "%Text%" order by i;
+i	s
+select * from mytable where s like concat("%Text","%") and s not like "%Text1%" order by i;
+i	s
+0	Text Hej
+1	xText aaja
+drop table mytable;
 set engine_condition_pushdown = @old_ecpd;
 DROP TABLE t1,t2,t3,t4,t5;

=== modified file 'mysql-test/suite/ndb/t/ndb_condition_pushdown.test'
--- a/mysql-test/suite/ndb/t/ndb_condition_pushdown.test	2011-01-17 13:29:52 +0000
+++ b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test	2011-11-04 08:33:56 +0000
@@ -2368,6 +2368,32 @@ select table1.pk1, table2.pk1, table1.pk
 
 drop table t;
 
+# Bug#11765142 58073: CONCAT AND OR GIVE INCORRECT QUERY RESULTS
+create table mytable(i int, s varchar(255) ) engine = ndb;
+insert into mytable values(0,"Text Hej"),(1, "xText aaja");
+set engine_condition_pushdown=1;
+
+ select * from mytable where s like concat("%Text","%") or s like concat("%Text","%") order by i;
+ select * from mytable where s like concat("%Text","%") or s like "%Text%" order by i;
+ select * from mytable where s like concat("%Text","%") or s like concat("%Text1","%") order by i;
+ select * from mytable where s like concat("%Text","%") or s like "%Text1%" order by i;
+ select * from mytable where s not like concat("%Text","%") or s not like concat("%Text","%") order by i;
+ select * from mytable where s not like concat("%Text1","%") or s not like concat("%Text","%") order by i;
+ select * from mytable where s like concat("%Text","%") or s not like "%Text%" order by i;
+ select * from mytable where s like concat("%Text1","%") or s not like "%Text%" order by i;
+
+
+ select * from mytable where s like concat("%Text","%") and s like concat("%Text","%") order by i;
+ select * from mytable where s like concat("%Text","%") and s like "%Text%" order by i;
+ select * from mytable where s like concat("%Text","%") and s like concat("%Text1","%") order by i;
+ select * from mytable where s like concat("%Text","%") and s like "%Text1%" order by i;
+ select * from mytable where s not like concat("%Text","%") and s not like concat("%Text","%") order by i;
+ select * from mytable where s not like concat("%Text","%") and s not like concat("%Text1","%") order by i;
+ select * from mytable where s like concat("%Text","%") and s not like "%Text%" order by i;
+ select * from mytable where s like concat("%Text","%") and s not like "%Text1%" order by i;
+
+drop table mytable;
+
 set engine_condition_pushdown = @old_ecpd;
 DROP TABLE t1,t2,t3,t4,t5;
 

=== modified file 'sql/ha_ndbcluster_cond.cc'
--- a/sql/ha_ndbcluster_cond.cc	2011-06-30 15:59:25 +0000
+++ b/sql/ha_ndbcluster_cond.cc	2011-11-04 08:33:56 +0000
@@ -1209,18 +1209,27 @@ ha_ndbcluster_cond::build_scan_filter_pr
     case NDB_LIKE_FUNC:
     {
       if (!value || !field) break;
-      if ((value->qualification.value_type != Item::STRING_ITEM) &&
-          (value->qualification.value_type != Item::VARBIN_ITEM))
-          break;
+      bool is_string= (value->qualification.value_type == Item::STRING_ITEM);
+      bool is_varbin= (value->qualification.value_type == Item::VARBIN_ITEM);
+      if (!is_string && !is_varbin)
+        break;
       // Save value in right format for the field type
-      value->save_in_field(field);
+      uint32 len= value->save_in_field(field);
+      char buff[MAX_FIELD_WIDTH];
+      String str(buff,sizeof(buff),field->get_field_charset());
+      field->get_field_val_str(&str);
+      const char *val=
+        (value->is_const_func() & is_string)?
+        str.ptr()
+        : value->get_val();
       DBUG_PRINT("info", ("Generating LIKE filter: like(%d,%s,%d)", 
-                          field->get_field_no(), value->get_val(), 
-                          value->pack_length()));
+                          field->get_field_no(),
+                          val,
+                          len));
       if (filter->cmp(NdbScanFilter::COND_LIKE, 
                       field->get_field_no(),
-                      value->get_val(),
-                      value->pack_length()) == -1)
+                      val,
+                      len) == -1)
         DBUG_RETURN(1);
       cond= cond->next->next->next;
       DBUG_RETURN(0);
@@ -1228,18 +1237,27 @@ ha_ndbcluster_cond::build_scan_filter_pr
     case NDB_NOTLIKE_FUNC:
     {
       if (!value || !field) break;
-      if ((value->qualification.value_type != Item::STRING_ITEM) &&
-          (value->qualification.value_type != Item::VARBIN_ITEM))
-          break;
+      bool is_string= (value->qualification.value_type == Item::STRING_ITEM);
+      bool is_varbin= (value->qualification.value_type == Item::VARBIN_ITEM);
+      if (!is_string && !is_varbin)
+        break;
       // Save value in right format for the field type
-      value->save_in_field(field);
+      uint32 len= value->save_in_field(field);
+      char buff[MAX_FIELD_WIDTH];
+      String str(buff,sizeof(buff),field->get_field_charset());
+      field->get_field_val_str(&str);
+      const char *val=
+        (value->is_const_func() & is_string)?
+        str.ptr()
+        : value->get_val();
       DBUG_PRINT("info", ("Generating NOTLIKE filter: notlike(%d,%s,%d)", 
-                          field->get_field_no(), value->get_val(), 
-                          value->pack_length()));
+                          field->get_field_no(),
+                          (value->pack_length() > len)?value->get_val():val,
+                          (value->pack_length() > len)?value->pack_length():len));
       if (filter->cmp(NdbScanFilter::COND_NOT_LIKE, 
                       field->get_field_no(),
-                      value->get_val(),
-                      value->pack_length()) == -1)
+                      (value->pack_length() > len)?value->get_val():val,
+                      (value->pack_length() > len)?value->pack_length():len) == -1)
         DBUG_RETURN(1);
       cond= cond->next->next->next;
       DBUG_RETURN(0);

=== modified file 'sql/ha_ndbcluster_cond.h'
--- a/sql/ha_ndbcluster_cond.h	2011-06-30 15:59:25 +0000
+++ b/sql/ha_ndbcluster_cond.h	2011-11-04 08:33:56 +0000
@@ -201,6 +201,9 @@ public:
       break;
     case(NDB_FIELD):
       return (char*) value.field_value->field->ptr; 
+    case(NDB_FUNCTION):
+      if(qualification.value_type == Item::STRING_ITEM)
+        return value.item->str_value.ptr();
     default:
       break;
     }
@@ -208,8 +211,40 @@ public:
     return NULL;
   };
 
-  void save_in_field(Ndb_item *field_item)
+  CHARSET_INFO *get_field_charset()
   {
+    Field *field= get_field();
+    if (field)
+      return field->charset();
+
+    return NULL;
+  }
+
+  String *get_field_val_str(String *str)
+  {
+    Field *field= get_field();
+    if (field)
+      return field->val_str(str);
+
+    return NULL;
+  }
+
+  bool is_const_func()
+  {
+    const Item *item= value.item;
+
+    if (item->type() == Item::FUNC_ITEM)
+    {
+      Item_func *func_item= (Item_func *) item;
+      if (func_item->const_item())
+        return true;
+    }
+    return false;
+  };
+
+  uint32 save_in_field(Ndb_item *field_item)
+  {
+    uint32 length= 0;
     DBUG_ENTER("save_in_field");
     Field *field = field_item->value.field_value->field;
     const Item *item= value.item;
@@ -221,13 +256,16 @@ public:
       {
         DBUG_PRINT("info", ("Comparing field with longer value"));
         DBUG_PRINT("info", ("Field can store %u", field->field_length));
+        length= field->field_length;
       }
+      else
+        length= item->max_length;
       my_bitmap_map *old_map=
         dbug_tmp_use_all_columns(field->table, field->table->write_set);
       ((Item *)item)->save_in_field(field, FALSE);
       dbug_tmp_restore_column_map(field->table->write_set, old_map);
     }
-    DBUG_VOID_RETURN;
+    DBUG_RETURN(length);
   };
 
   static NDB_FUNC_TYPE item_func_to_ndb_func(Item_func::Functype fun)

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.1 branch (jonas.oreland:4325 to 4326) jonas oreland7 Nov