List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:January 14 2011 1:41pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:4112)
View as plain text  
#At file:///home/msvensson/mysql/7.0-cond-push-bitmasks/ based on revid:ole.john.aske@strippedlnj879s5ru437t

 4112 Magnus Blåudd	2011-01-14
      ndb
       -  remove need for MAX_XXX values in mysql server enums,
         ll the values that can be expected to be handled
         by condition pushdown are hardcoded. Only when asking
         for "is this type supported/expected?" can we expect "any"
         value for the type. This means the 'expecting' functions should return
         false for any type values it does not know about.
       - Since we know the max values for bitmask at compile time, use
          fixed size buffers to remove the need for extra mallocs when creating
         Ndb_expect_stack
       - revert the additiotn of MAX_XXX values on the three enums

    modified:
      include/mysql.h.pp
      include/mysql_com.h
      sql/ha_ndbcluster_cond.h
      sql/item.h
      sql/rpl_utility.cc
=== modified file 'include/mysql.h.pp'
--- a/include/mysql.h.pp	2010-11-09 09:29:29 +0000
+++ b/include/mysql.h.pp	2011-01-14 13:41:20 +0000
@@ -58,8 +58,7 @@ enum enum_field_types { MYSQL_TYPE_DECIM
                         MYSQL_TYPE_BLOB=252,
                         MYSQL_TYPE_VAR_STRING=253,
                         MYSQL_TYPE_STRING=254,
-                        MYSQL_TYPE_GEOMETRY=255,
-                        MYSQL_NUM_FIELD_TYPES
+                        MYSQL_TYPE_GEOMETRY=255
 };
 enum mysql_enum_shutdown_level {
   SHUTDOWN_DEFAULT = 0,
@@ -103,8 +102,7 @@ struct rand_struct {
   double max_value_dbl;
 };
 enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
-                  DECIMAL_RESULT,
-                  MYSQL_NUM_ITEM_RESULTS };
+                  DECIMAL_RESULT};
 typedef struct st_udf_args
 {
   unsigned int arg_count;

=== modified file 'include/mysql_com.h'
--- a/include/mysql_com.h	2010-11-09 09:29:29 +0000
+++ b/include/mysql_com.h	2011-01-14 13:41:20 +0000
@@ -315,12 +315,7 @@ enum enum_field_types { MYSQL_TYPE_DECIM
                         MYSQL_TYPE_BLOB=252,
                         MYSQL_TYPE_VAR_STRING=253,
                         MYSQL_TYPE_STRING=254,
-#ifndef MCP_BUG58075
-                        MYSQL_TYPE_GEOMETRY=255,
-                        MYSQL_NUM_FIELD_TYPES /* Always last */
-#else
                         MYSQL_TYPE_GEOMETRY=255
-#endif
 };
 
 /* For backward compatibility */
@@ -448,12 +443,7 @@ struct rand_struct {
   /* The following is for user defined functions */
 
 enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
-#ifndef MCP_BUG58075
-                  DECIMAL_RESULT,
-                  MYSQL_NUM_ITEM_RESULTS /* Always last */ };
-#else
                   DECIMAL_RESULT};
-#endif
 
 typedef struct st_udf_args
 {

=== modified file 'sql/ha_ndbcluster_cond.h'
--- a/sql/ha_ndbcluster_cond.h	2010-11-15 09:23:10 +0000
+++ b/sql/ha_ndbcluster_cond.h	2011-01-14 13:41:20 +0000
@@ -25,8 +25,6 @@
 #pragma interface                       /* gcc class implementation */
 #endif
 
-#define round_up_byte(size) ((size + 7) >> 3) << 3
-
 typedef enum ndb_item_type {
   NDB_VALUE = 0,   // Qualified more with Item::Type
   NDB_FIELD = 1,   // Qualified from table definition
@@ -333,22 +331,23 @@ class Ndb_cond_stack : public Sql_alloc
  */
 class Ndb_expect_stack : public Sql_alloc
 {
+  static const uint MAX_EXPECT_ITEMS = Item::VIEW_FIXER_ITEM + 1;
+  static const uint MAX_EXPECT_FIELD_TYPES = MYSQL_TYPE_GEOMETRY + 1;
+  static const uint MAX_EXPECT_FIELD_RESULTS = DECIMAL_RESULT + 1;
  public:
 Ndb_expect_stack(): collation(NULL), length(0), max_length(0), next(NULL) 
   {
-    // Allocate type checking bitmaps   
-    bitmap_init(&expect_mask,
-                0, round_up_byte(Item::MAX_NUM_ITEMS), FALSE);
-    bitmap_init(&expect_field_type_mask,
-                0, round_up_byte(MYSQL_NUM_FIELD_TYPES), FALSE);
-    bitmap_init(&expect_field_result_mask,
-                0, round_up_byte(MYSQL_NUM_ITEM_RESULTS), FALSE);
+    // Allocate type checking bitmaps using fixed size buffers
+    // since max size is known at compile time
+    bitmap_init(&expect_mask, m_expect_buf,
+                MAX_EXPECT_ITEMS, FALSE);
+    bitmap_init(&expect_field_type_mask, m_expect_field_type_buf,
+                MAX_EXPECT_FIELD_TYPES, FALSE);
+    bitmap_init(&expect_field_result_mask, m_expect_field_result_buf,
+                MAX_EXPECT_FIELD_RESULTS, FALSE);
   };
   ~Ndb_expect_stack()
   {
-    bitmap_free(&expect_mask);
-    bitmap_free(&expect_field_type_mask);
-    bitmap_free(&expect_field_result_mask);
     if (next)
       delete next;
     next= NULL;
@@ -385,6 +384,11 @@ Ndb_expect_stack(): collation(NULL), len
   }
   bool expecting(Item::Type type)
   {
+    if (unlikely((uint)type > MAX_EXPECT_ITEMS))
+    {
+      // Unknown type, can't be expected
+      return false;
+    }
     return bitmap_is_set(&expect_mask, (uint) type);
   }
   void expect_nothing()
@@ -411,6 +415,11 @@ Ndb_expect_stack(): collation(NULL), len
   }
   bool expecting_field_type(enum_field_types type)
   {
+    if (unlikely((uint)type > MAX_EXPECT_FIELD_TYPES))
+    {
+      // Unknown type, can't be expected
+      return false;
+    }
     return bitmap_is_set(&expect_field_type_mask, (uint) type);
   }
   void expect_no_field_type()
@@ -433,6 +442,11 @@ Ndb_expect_stack(): collation(NULL), len
   }
   bool expecting_field_result(Item_result result)
   {
+    if (unlikely((uint)result > MAX_EXPECT_FIELD_RESULTS))
+    {
+      // Unknown result, can't be expected
+      return false;
+    }
     return bitmap_is_set(&expect_field_result_mask,
                          (uint) result);
   }
@@ -484,6 +498,12 @@ Ndb_expect_stack(): collation(NULL), len
   }
 
 private:
+  my_bitmap_map
+    m_expect_buf[bitmap_buffer_size(MAX_EXPECT_ITEMS)];
+  my_bitmap_map
+    m_expect_field_type_buf[bitmap_buffer_size(MAX_EXPECT_FIELD_TYPES)];
+  my_bitmap_map
+    m_expect_field_result_buf[bitmap_buffer_size(MAX_EXPECT_FIELD_RESULTS)];
   MY_BITMAP expect_mask;
   MY_BITMAP expect_field_type_mask;
   MY_BITMAP expect_field_result_mask;

=== modified file 'sql/item.h'
--- a/sql/item.h	2010-11-09 09:29:29 +0000
+++ b/sql/item.h	2011-01-14 13:41:20 +0000
@@ -490,12 +490,7 @@ public:
              SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
              PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM,
              XPATH_NODESET, XPATH_NODESET_CMP,
-#ifndef MCP_BUG58075
-             VIEW_FIXER_ITEM,
-             MAX_NUM_ITEMS /* Always last */
-#else
              VIEW_FIXER_ITEM
-#endif
   };
 
   enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };

=== modified file 'sql/rpl_utility.cc'
--- a/sql/rpl_utility.cc	2010-11-23 14:45:43 +0000
+++ b/sql/rpl_utility.cc	2011-01-14 13:41:20 +0000
@@ -736,8 +736,6 @@ can_convert_field_to(Field *field,
   case MYSQL_TYPE_NULL:
   case MYSQL_TYPE_ENUM:
   case MYSQL_TYPE_SET:
-
-  case MYSQL_NUM_FIELD_TYPES:
     DBUG_RETURN(false);
   }
   DBUG_RETURN(false);                                 // To keep GCC happy

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@oracle.com-20110114134120-d2373ks9wrak9ww6.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:4112) Magnus Blåudd14 Jan