MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:msvensson Date:July 20 2006 5:25pm
Subject:bk commit into 5.1 tree (msvensson:1.2225) BUG#20942
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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@stripped, 2006-07-20 19:25:20+02:00, msvensson@neptunus.(none) +2 -0
  Bug#20942 ha_federated uses String::append(const char *s), strlen() on every call
   - Use precompiled lengths of constant strings

  sql/ha_federated.cc@stripped, 2006-07-20 19:25:12+02:00, msvensson@neptunus.(none) +83 -84
    Use the procomputed length of the fixed strings to avoid using strlen every time.

  sql/ha_federated.h@stripped, 2006-07-20 19:25:13+02:00, msvensson@neptunus.(none) +2 -2
    Use the procomputed length of the fixed strings to avoid using strlen every time.
    Add define for FEDERATED_TRUE (1=1) as FEDERATED_FALSE (1=0) already exist
    Remove FEDERATED_IS and use FEDERATE_ISNULL instead 

# 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/my51-m-bug20942

--- 1.66/sql/ha_federated.cc	2006-07-20 19:25:27 +02:00
+++ 1.67/sql/ha_federated.cc	2006-07-20 19:25:27 +02:00
@@ -526,19 +526,19 @@
 
       the query will be: SELECT * FROM `tablename` WHERE 1=0
     */
-    query.append(FEDERATED_SELECT);
-    query.append(FEDERATED_STAR);
-    query.append(FEDERATED_FROM);
-    query.append(FEDERATED_BTICK);
+    query.append(FEDERATED_SELECT, FEDERATED_SELECT_LEN);
+    query.append(FEDERATED_STAR, FEDERATED_STAR_LEN);
+    query.append(FEDERATED_FROM, FEDERATED_FROM_LEN);
+    query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
     escaped_table_name_length=
       escape_string_for_mysql(&my_charset_bin, (char*)escaped_table_name,
                             sizeof(escaped_table_name),
                             share->table_name,
                             share->table_name_length);
     query.append(escaped_table_name, escaped_table_name_length);
-    query.append(FEDERATED_BTICK);
-    query.append(FEDERATED_WHERE);
-    query.append(FEDERATED_FALSE);
+    query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
+    query.append(FEDERATED_WHERE, FEDERATED_WHERE_LEN);
+    query.append(FEDERATED_FALSE, FEDERATED_FALSE_LEN);
 
     if (mysql_real_query(mysql, query.ptr(), query.length()))
     {
@@ -801,9 +801,9 @@
 static bool emit_key_part_name(String *to, KEY_PART_INFO *part)
 {
   DBUG_ENTER("emit_key_part_name");
-  if (to->append(FEDERATED_BTICK) ||
+  if (to->append(FEDERATED_BTICK, FEDERATED_BTICK_LEN) ||
       to->append(part->field->field_name) ||
-      to->append(FEDERATED_BTICK))
+      to->append(FEDERATED_BTICK, FEDERATED_BTICK_LEN))
     DBUG_RETURN(1);                           // Out of memory
   DBUG_RETURN(0);
 }
@@ -815,7 +815,7 @@
   Field *field= part->field;
   DBUG_ENTER("emit_key_part_element");
 
-  if (needs_quotes && to->append(FEDERATED_SQUOTE))
+  if (needs_quotes && to->append(FEDERATED_SQUOTE, FEDERATED_SQUOTE_LEN))
     DBUG_RETURN(1);
 
   if (part->type == HA_KEYTYPE_BIT)
@@ -862,10 +862,10 @@
       DBUG_RETURN(1);
   }
 
-  if (is_like && to->append(FEDERATED_PERCENT))
+  if (is_like && to->append(FEDERATED_PERCENT, FEDERATED_PERCENT_LEN))
     DBUG_RETURN(1);
 
-  if (needs_quotes && to->append(FEDERATED_SQUOTE))
+  if (needs_quotes && to->append(FEDERATED_SQUOTE, FEDERATED_SQUOTE_LEN))
     DBUG_RETURN(1);
 
   DBUG_RETURN(0);
@@ -1141,9 +1141,9 @@
     if (both_not_null)
     {
       if (i > 0)
-        tmp.append(FEDERATED_CONJUNCTION);
+        tmp.append(FEDERATED_CONJUNCTION, FEDERATED_CONJUNCTION_LEN);
       else
-        tmp.append(FEDERATED_OPENPAREN);
+        tmp.append(FEDERATED_OPENPAREN, FEDERATED_OPENPAREN_LEN);
     }
 
     for (key_part= key_info->key_part,
@@ -1164,13 +1164,13 @@
         if (*ptr++)
         {
           if (emit_key_part_name(&tmp, key_part) ||
-              tmp.append(FEDERATED_ISNULL))
+              tmp.append(FEDERATED_ISNULL, FEDERATED_ISNULL_LEN))
             goto err;
           continue;
         }
       }
 
-      if (tmp.append(FEDERATED_OPENPAREN))
+      if (tmp.append(FEDERATED_OPENPAREN, FEDERATED_OPENPAREN_LEN))
         goto err;
 
       switch (ranges[i]->flag) {
@@ -1186,12 +1186,12 @@
 
           if (records_in_range)
           {
-            if (tmp.append(FEDERATED_GE))
+            if (tmp.append(FEDERATED_GE, FEDERATED_GE_LEN))
               goto err;
           }
           else
           {
-            if (tmp.append(FEDERATED_EQ))
+            if (tmp.append(FEDERATED_EQ, FEDERATED_EQ_LEN))
               goto err;
           }
 
@@ -1203,7 +1203,7 @@
         {
           /* LIKE */
           if (emit_key_part_name(&tmp, key_part) ||
-              tmp.append(FEDERATED_LIKE) ||
+              tmp.append(FEDERATED_LIKE, FEDERATED_LIKE_LEN) ||
               emit_key_part_element(&tmp, key_part, needs_quotes, 1, ptr,
                                     part_length))
             goto err;
@@ -1212,7 +1212,7 @@
       case HA_READ_AFTER_KEY:
         if (eq_range)
         {
-          if (tmp.append("1=1"))                // Dummy
+          if (tmp.append(FEDERATED_TRUE, FEDERATED_TRUE_LEN)) // Dummy
             goto err;
           break;
         }
@@ -1224,12 +1224,12 @@
 
           if (i > 0) /* end key */
           {
-            if (tmp.append(FEDERATED_LE))
+            if (tmp.append(FEDERATED_LE, FEDERATED_LE_LEN))
               goto err;
           }
           else /* start key */
           {
-            if (tmp.append(FEDERATED_GT))
+            if (tmp.append(FEDERATED_GT, FEDERATED_GT_LEN))
               goto err;
           }
 
@@ -1243,7 +1243,7 @@
       case HA_READ_KEY_OR_NEXT:
         DBUG_PRINT("info", ("federated HA_READ_KEY_OR_NEXT %d", i));
         if (emit_key_part_name(&tmp, key_part) ||
-            tmp.append(FEDERATED_GE) ||
+            tmp.append(FEDERATED_GE, FEDERATED_GE_LEN) ||
             emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
               part_length))
           goto err;
@@ -1253,7 +1253,7 @@
         if (store_length >= length)
         {
           if (emit_key_part_name(&tmp, key_part) ||
-              tmp.append(FEDERATED_LT) ||
+              tmp.append(FEDERATED_LT, FEDERATED_LT_LEN) ||
               emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
                                     part_length))
             goto err;
@@ -1262,7 +1262,7 @@
       case HA_READ_KEY_OR_PREV:
         DBUG_PRINT("info", ("federated HA_READ_KEY_OR_PREV %d", i));
         if (emit_key_part_name(&tmp, key_part) ||
-            tmp.append(FEDERATED_LE) ||
+            tmp.append(FEDERATED_LE, FEDERATED_LE_LEN) ||
             emit_key_part_element(&tmp, key_part, needs_quotes, 0, ptr,
                                   part_length))
           goto err;
@@ -1271,7 +1271,7 @@
         DBUG_PRINT("info",("cannot handle flag %d", ranges[i]->flag));
         goto err;
       }
-      if (tmp.append(FEDERATED_CLOSEPAREN))
+      if (tmp.append(FEDERATED_CLOSEPAREN, FEDERATED_CLOSEPAREN_LEN))
         goto err;
 
 next_loop:
@@ -1281,7 +1281,7 @@
       DBUG_ASSERT(remainder > 1);
       length-= store_length;
       ptr+= store_length;
-      if (tmp.append(FEDERATED_AND))
+      if (tmp.append(FEDERATED_AND, FEDERATED_AND_LEN))
         goto err;
 
       DBUG_PRINT("info",
@@ -1292,10 +1292,10 @@
   dbug_tmp_restore_column_map(table->write_set, old_map);
 
   if (both_not_null)
-    if (tmp.append(FEDERATED_CLOSEPAREN))
+    if (tmp.append(FEDERATED_CLOSEPAREN, FEDERATED_CLOSEPAREN_LEN))
       DBUG_RETURN(1);
 
-  if (to->append(FEDERATED_WHERE))
+  if (to->append(FEDERATED_WHERE, FEDERATED_WHERE_LEN))
     DBUG_RETURN(1);
 
   if (to->append(tmp))
@@ -1339,17 +1339,17 @@
                                                connect_string_length)))
   {
     query.set_charset(system_charset_info);
-    query.append(FEDERATED_SELECT);
+    query.append(FEDERATED_SELECT, FEDERATED_SELECT_LEN);
     for (field= table->field; *field; field++)
     {
-      query.append(FEDERATED_BTICK);
+      query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
       query.append((*field)->field_name);
-      query.append(FEDERATED_BTICK);
-      query.append(FEDERATED_COMMA);
+      query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
+      query.append(FEDERATED_COMMA, FEDERATED_COMMA_LEN);
     }
     query.length(query.length()- FEDERATED_COMMA_LEN);
-    query.append(FEDERATED_FROM);
-    query.append(FEDERATED_BTICK);
+    query.append(FEDERATED_FROM, FEDERATED_FROM_LEN);
+    query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
 
     if (!(share= (FEDERATED_SHARE *)
           my_multi_malloc(MYF(MY_WME),
@@ -1364,7 +1364,7 @@
     share->table_name_length= strlen(share->table_name);
     /* TODO: share->table_name to LEX_STRING object */
     query.append(share->table_name, share->table_name_length);
-    query.append(FEDERATED_BTICK);
+    query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
     share->select_query= select_query;
     strmov(share->select_query, query.ptr());
     share->use_count= 0;
@@ -1608,14 +1608,14 @@
   /*
     start both our field and field values strings
   */
-  insert_string.append(FEDERATED_INSERT);
-  insert_string.append(FEDERATED_BTICK);
+  insert_string.append(FEDERATED_INSERT, FEDERATED_INSERT_LEN);
+  insert_string.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
   insert_string.append(share->table_name, share->table_name_length);
-  insert_string.append(FEDERATED_BTICK);
-  insert_string.append(FEDERATED_OPENPAREN);
+  insert_string.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
+  insert_string.append(FEDERATED_OPENPAREN, FEDERATED_OPENPAREN_LEN);
 
-  values_string.append(FEDERATED_VALUES);
-  values_string.append(FEDERATED_OPENPAREN);
+  values_string.append(FEDERATED_VALUES, FEDERATED_VALUES_LEN);
+  values_string.append(FEDERATED_OPENPAREN, FEDERATED_OPENPAREN_LEN);
 
   /*
     loop through the field pointer array, add any fields to both the values
@@ -1636,7 +1636,7 @@
       has_fields= TRUE;
 
       if ((*field)->is_null())
-        insert_field_value_string.append(FEDERATED_NULL);
+        insert_field_value_string.append(FEDERATED_NULL, FEDERATED_NULL_LEN);
       else
       {
         (*field)->val_str(&insert_field_value_string);
@@ -1656,8 +1656,8 @@
         make the following appends conditional as we don't know if the
         next field is in the write set
       */
-      insert_string.append(FEDERATED_COMMA);
-      values_string.append(FEDERATED_COMMA);
+      insert_string.append(FEDERATED_COMMA, FEDERATED_COMMA_LEN);
+      values_string.append(FEDERATED_COMMA, FEDERATED_COMMA_LEN);
     }
   }
   dbug_tmp_restore_column_map(table->read_set, old_map);
@@ -1672,13 +1672,13 @@
     /* chops off leading commas */
     insert_string.length(insert_string.length() - FEDERATED_COMMA_LEN);
     values_string.length(values_string.length() - FEDERATED_COMMA_LEN);
-    insert_string.append(FEDERATED_CLOSEPAREN);
+    insert_string.append(FEDERATED_CLOSEPAREN, FEDERATED_CLOSEPAREN_LEN);
   }
   else
     insert_string.length(insert_string.length() - FEDERATED_CLOSEPAREN_LEN);
 
   /* we always want to append this, even if there aren't any fields */
-  values_string.append(FEDERATED_CLOSEPAREN);
+  values_string.append(FEDERATED_CLOSEPAREN, FEDERATED_CLOSEPAREN_LEN);
 
   /* add the values */
   insert_string.append(values_string);
@@ -1726,10 +1726,10 @@
   query.length(0);
 
   query.set_charset(system_charset_info);
-  query.append(FEDERATED_OPTIMIZE);
-  query.append(FEDERATED_BTICK);
+  query.append(FEDERATED_OPTIMIZE, FEDERATED_OPTIMIZE_LEN);
+  query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
   query.append(share->table_name, share->table_name_length);
-  query.append(FEDERATED_BTICK);
+  query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
 
   if (mysql_real_query(mysql, query.ptr(), query.length()))
   {
@@ -1749,16 +1749,16 @@
   query.length(0);
 
   query.set_charset(system_charset_info);
-  query.append(FEDERATED_REPAIR);
-  query.append(FEDERATED_BTICK);
+  query.append(FEDERATED_REPAIR, FEDERATED_REPAIR_LEN);
+  query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
   query.append(share->table_name, share->table_name_length);
-  query.append(FEDERATED_BTICK);
+  query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
   if (check_opt->flags & T_QUICK)
-    query.append(FEDERATED_QUICK);
+    query.append(FEDERATED_QUICK, FEDERATED_QUICK_LEN);
   if (check_opt->flags & T_EXTEND)
-    query.append(FEDERATED_EXTENDED);
+    query.append(FEDERATED_EXTENDED, FEDERATED_EXTENDED_LEN);
   if (check_opt->sql_flags & TT_USEFRM)
-    query.append(FEDERATED_USE_FRM);
+    query.append(FEDERATED_USE_FRM, FEDERATED_USE_FRM_LEN);
 
   if (mysql_real_query(mysql, query.ptr(), query.length()))
   {
@@ -1834,11 +1834,11 @@
   update_string.length(0);
   where_string.length(0);
 
-  update_string.append(FEDERATED_UPDATE);
-  update_string.append(FEDERATED_BTICK);
+  update_string.append(FEDERATED_UPDATE, FEDERATED_UPDATE_LEN);
+  update_string.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
   update_string.append(share->table_name);
-  update_string.append(FEDERATED_BTICK);
-  update_string.append(FEDERATED_SET);
+  update_string.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
+  update_string.append(FEDERATED_SET, FEDERATED_SET_LEN);
 
   /*
     In this loop, we want to match column names to values being inserted
@@ -1855,7 +1855,7 @@
     if (bitmap_is_set(table->write_set, (*field)->field_index))
     {
       if ((*field)->is_null())
-        new_field_value.append(FEDERATED_NULL);
+        new_field_value.append(FEDERATED_NULL, FEDERATED_NULL_LEN);
       else
       {
         my_bitmap_map *old_map= tmp_use_all_columns(table, table->read_set);
@@ -1865,9 +1865,9 @@
         tmp_restore_column_map(table->read_set, old_map);
       }
       update_string.append((*field)->field_name);
-      update_string.append(FEDERATED_EQ);
+      update_string.append(FEDERATED_EQ, FEDERATED_EQ_LEN);
       update_string.append(new_field_value);
-      update_string.append(FEDERATED_COMMA);
+      update_string.append(FEDERATED_COMMA, FEDERATED_COMMA_LEN);
       new_field_value.length(0);
     }
 
@@ -1875,17 +1875,17 @@
     {
       where_string.append((*field)->field_name);
       if (field_in_record_is_null(table, *field, (char*) old_data))
-        where_string.append(FEDERATED_ISNULL);
+        where_string.append(FEDERATED_ISNULL, FEDERATED_ISNULL_LEN);
       else
       {
-        where_string.append(FEDERATED_EQ);
+        where_string.append(FEDERATED_EQ, FEDERATED_EQ_LEN);
         (*field)->val_str(&old_field_value,
                           (char*) (old_data + (*field)->offset()));
         (*field)->quote_data(&old_field_value);
         where_string.append(old_field_value);
         old_field_value.length(0);
       }
-      where_string.append(FEDERATED_AND);
+      where_string.append(FEDERATED_AND, FEDERATED_AND_LEN);
     }
   }
 
@@ -1894,7 +1894,7 @@
   if (where_string.length())
   {
     where_string.length(where_string.length() - FEDERATED_AND_LEN);
-    update_string.append(FEDERATED_WHERE);
+    update_string.append(FEDERATED_WHERE, FEDERATED_WHERE_LEN);
     update_string.append(where_string);
   }
 
@@ -1903,7 +1903,7 @@
     update multiple rows. We want to make sure to only update one!
   */
   if (!has_a_primary_key)
-    update_string.append(FEDERATED_LIMIT1);
+    update_string.append(FEDERATED_LIMIT1, FEDERATED_LIMIT1_LEN);
 
   if (mysql_real_query(mysql, update_string.ptr(), update_string.length()))
   {
@@ -1937,12 +1937,12 @@
   DBUG_ENTER("ha_federated::delete_row");
 
   delete_string.length(0);
-  delete_string.append(FEDERATED_DELETE);
-  delete_string.append(FEDERATED_FROM);
-  delete_string.append(FEDERATED_BTICK);
+  delete_string.append(FEDERATED_DELETE, FEDERATED_DELETE_LEN);
+  delete_string.append(FEDERATED_FROM, FEDERATED_FROM_LEN);
+  delete_string.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
   delete_string.append(share->table_name);
-  delete_string.append(FEDERATED_BTICK);
-  delete_string.append(FEDERATED_WHERE);
+  delete_string.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
+  delete_string.append(FEDERATED_WHERE, FEDERATED_WHERE_LEN);
 
   for (Field **field= table->field; *field; field++)
   {
@@ -1954,17 +1954,16 @@
       delete_string.append(cur_field->field_name);
       if (cur_field->is_null())
       {
-        delete_string.append(FEDERATED_IS);
-        delete_string.append(FEDERATED_NULL);
+        delete_string.append(FEDERATED_ISNULL, FEDERATED_ISNULL_LEN);
       }
       else
       {
-        delete_string.append(FEDERATED_EQ);
+        delete_string.append(FEDERATED_EQ, FEDERATED_EQ_LEN);
         cur_field->val_str(&data_string);
         cur_field->quote_data(&data_string);
         delete_string.append(data_string);
       }
-      delete_string.append(FEDERATED_AND);
+      delete_string.append(FEDERATED_AND, FEDERATED_AND_LEN);
     }
   }
 
@@ -1973,7 +1972,7 @@
   if (!found)
     delete_string.length(delete_string.length() - FEDERATED_WHERE_LEN);
 
-  delete_string.append(FEDERATED_LIMIT1);
+  delete_string.append(FEDERATED_LIMIT1, FEDERATED_LIMIT1_LEN);
   DBUG_PRINT("info",
              ("Delete sql: %s", delete_string.c_ptr_quick()));
   if (mysql_real_query(mysql, delete_string.ptr(), delete_string.length()))
@@ -2469,15 +2468,15 @@
   if (flag & (HA_STATUS_VARIABLE | HA_STATUS_CONST))
   {
     status_query_string.length(0);
-    status_query_string.append(FEDERATED_INFO);
-    status_query_string.append(FEDERATED_SQUOTE);
+    status_query_string.append(FEDERATED_INFO, FEDERATED_INFO_LEN);
+    status_query_string.append(FEDERATED_SQUOTE, FEDERATED_SQUOTE_LEN);
 
     escape_string_for_mysql(&my_charset_bin, (char *)escaped_table_name,
                             sizeof(escaped_table_name),
                             share->table_name,
                             share->table_name_length);
     status_query_string.append(escaped_table_name);
-    status_query_string.append(FEDERATED_SQUOTE);
+    status_query_string.append(FEDERATED_SQUOTE, FEDERATED_SQUOTE_LEN);
 
     if (mysql_real_query(mysql, status_query_string.ptr(),
                          status_query_string.length()))
@@ -2569,10 +2568,10 @@
   query.length(0);
 
   query.set_charset(system_charset_info);
-  query.append(FEDERATED_TRUNCATE);
-  query.append(FEDERATED_BTICK);
+  query.append(FEDERATED_TRUNCATE, FEDERATED_TRUNCATE_LEN);
+  query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
   query.append(share->table_name);
-  query.append(FEDERATED_BTICK);
+  query.append(FEDERATED_BTICK, FEDERATED_BTICK_LEN);
 
   /*
     TRUNCATE won't return anything in mysql_affected_rows

--- 1.33/sql/ha_federated.h	2006-07-20 19:25:27 +02:00
+++ 1.34/sql/ha_federated.h	2006-07-20 19:25:27 +02:00
@@ -48,8 +48,6 @@
 #define FEDERATED_FROM_LEN (sizeof(FEDERATED_FROM) -1)
 #define FEDERATED_PERCENT "%"
 #define FEDERATED_PERCENT_LEN (sizeof(FEDERATED_PERCENT) -1)
-#define FEDERATED_IS " IS "
-#define FEDERATED_IS_LEN (sizeof(FEDERATED_IS) -1)
 #define FEDERATED_NULL " NULL "
 #define FEDERATED_NULL_LEN (sizeof(FEDERATED_NULL) -1)
 #define FEDERATED_ISNULL " IS NULL "
@@ -116,6 +114,8 @@
 #define FEDERATED_EQ_LEN (sizeof(FEDERATED_EQ) -1)
 #define FEDERATED_FALSE " 1=0"
 #define FEDERATED_FALSE_LEN (sizeof(FEDERATED_FALSE) -1)
+#define FEDERATED_TRUE " 1=1"
+#define FEDERATED_TRUE_LEN (sizeof(FEDERATED_TRUE) -1)
 
 /*
   FEDERATED_SHARE is a structure that will be shared amoung all open handlers
Thread
bk commit into 5.1 tree (msvensson:1.2225) BUG#20942msvensson20 Jul