MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:July 25 2006 11:12pm
Subject:bk commit into 5.0 tree (jimw:1.2218) BUG#21284
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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-25 16:12:48-07:00, jimw@rama.(none) +2 -0
  Bug #21284: Add Field::needs_quote() method and use it in Federated
  
    The fix for bug 17608 removed the behavior of only adding quotes to values
    that needed it when constructing the queries sent by the federated storage
    engine. This restores that behavior, but using a new virtual Field method.
    (The old one had a hardcoded list of field types.)
  
    No test included. The behavior can be verified by inspecting the query log
    on the slave in the federated test.

  sql/field.h@stripped, 2006-07-25 16:12:44-07:00, jimw@rama.(none) +7 -0
    Add str_needs_quotes() method to indicate whether the results of val_str()
    requires quoting when used in constructing an SQL query.

  sql/ha_federated.cc@stripped, 2006-07-25 16:12:44-07:00, jimw@rama.(none) +21 -9
    Restore behavior of only quoting values that need it, using the new
    Field::str_needs_quotes() method.

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-21284

--- 1.185/sql/field.h	2006-07-25 16:12:52 -07:00
+++ 1.186/sql/field.h	2006-07-25 16:12:52 -07:00
@@ -118,6 +118,11 @@ public:
   */
   virtual String *val_str(String*,String *)=0;
   String *val_int_as_str(String *val_buffer, my_bool unsigned_flag);
+  /*
+   str_needs_quotes() returns TRUE if the value returned by val_str() needs
+   to be quoted when used in constructing an SQL query.
+  */
+  virtual bool str_needs_quotes() { return FALSE; }
   virtual Item_result result_type () const=0;
   virtual Item_result cmp_type () const { return result_type(); }
   virtual Item_result cast_to_int_type () const { return result_type(); }
@@ -386,6 +391,7 @@ public:
   uint32 max_length() { return field_length; }
   friend class create_field;
   my_decimal *val_decimal(my_decimal *);
+  virtual bool str_needs_quotes() { return TRUE; }
 };
 
 
@@ -1330,6 +1336,7 @@ public:
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*, String *);
+  virtual bool str_needs_quotes() { return TRUE; }
   my_decimal *val_decimal(my_decimal *);
   int cmp(const char *a, const char *b)
   { return cmp_binary(a, b); }

--- 1.67/sql/ha_federated.cc	2006-07-25 16:12:52 -07:00
+++ 1.68/sql/ha_federated.cc	2006-07-25 16:12:52 -07:00
@@ -1136,7 +1136,7 @@ bool ha_federated::create_where_from_key
       Field *field= key_part->field;
       uint store_length= key_part->store_length;
       uint part_length= min(store_length, length);
-      needs_quotes= 1;
+      needs_quotes= field->str_needs_quotes();
       DBUG_DUMP("key, start of loop", (char *) ptr, length);
 
       if (key_part->null_bit)
@@ -1588,10 +1588,13 @@ int ha_federated::write_row(byte *buf)
       insert_field_value_string.append(FEDERATED_NULL);
     else
     {
+      bool needs_quote= (*field)->str_needs_quotes();
       (*field)->val_str(&insert_field_value_string);
-      values_string.append('\'');
+      if (needs_quote)
+        values_string.append('\'');
       insert_field_value_string.print(&values_string);
-      values_string.append('\'');
+      if (needs_quote)
+        values_string.append('\'');
 
       insert_field_value_string.length(0);
     }
@@ -1804,11 +1807,14 @@ int ha_federated::update_row(const byte 
       update_string.append(FEDERATED_NULL);
     else
     {
+      bool needs_quote= (*field)->str_needs_quotes();
       /* otherwise = */
       (*field)->val_str(&field_value);
-      update_string.append('\'');
+      if (needs_quote)
+        update_string.append('\'');
       field_value.print(&update_string);
-      update_string.append('\'');
+      if (needs_quote)
+        update_string.append('\'');
       field_value.length(0);
     }
 
@@ -1816,12 +1822,15 @@ int ha_federated::update_row(const byte 
       where_string.append(FEDERATED_ISNULL);
     else
     {
+      bool needs_quote= (*field)->str_needs_quotes();
       where_string.append(FEDERATED_EQ);
       (*field)->val_str(&field_value,
                         (char*) (old_data + (*field)->offset()));
-      where_string.append('\'');
+      if (needs_quote)
+        where_string.append('\'');
       field_value.print(&where_string);
-      where_string.append('\'');
+      if (needs_quote)
+        where_string.append('\'');
       field_value.length(0);
     }
 
@@ -1895,11 +1904,14 @@ int ha_federated::delete_row(const byte 
     }
     else
     {
+      bool needs_quote= cur_field->str_needs_quotes();
       delete_string.append(FEDERATED_EQ);
       cur_field->val_str(&data_string);
-      delete_string.append('\'');
+      if (needs_quote)
+        delete_string.append('\'');
       data_string.print(&delete_string);
-      delete_string.append('\'');
+      if (needs_quote)
+        delete_string.append('\'');
     }
 
     delete_string.append(FEDERATED_AND);
Thread
bk commit into 5.0 tree (jimw:1.2218) BUG#21284Jim Winstead26 Jul