List:Internals« Previous MessageNext Message »
From:sanja Date:November 15 2005 2:34pm
Subject:bk commit into 5.0 tree (bell:1.1967) BUG#14090
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell 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
  1.1967 05/11/15 15:34:42 bell@stripped +41 -0
  Inefficient using of String::append() fixed
  Bad examples of using a string with its length fixed
  The incorrect length in the trigger file configuration descriptor fixed (BUG#14090)
  A hook for uncknown keys added to parser to support old .TRG files

  sql/tztime.cc
    1.27 05/11/15 15:34:38 bell@stripped +1 -1
    A bad example of using a string with its length fixed

  sql/table.cc
    1.209 05/11/15 15:34:38 bell@stripped +1 -1
    A bad example of using a string with its length fixed

  sql/sql_view.cc
    1.77 05/11/15 15:34:38 bell@stripped +5 -3
    A dummy  hook used for parsing views

  sql/sql_trigger.cc
    1.33 05/11/15 15:34:38 bell@stripped +76 -11
    Bad examples of using a string with its length fixed
    The incorrect length in the trigger file configuration descriptor fixed (BUG#14090)
    the hook for processing sql_modes from previous messages added.

  sql/sql_table.cc
    1.285 05/11/15 15:34:38 bell@stripped +29 -23
    Bad examples of using a string with its length fixed

  sql/sql_string.cc
    1.90 05/11/15 15:34:38 bell@stripped +8 -6
    Bad examples of using a string with its length fixed

  sql/sql_show.cc
    1.296 05/11/15 15:34:37 bell@stripped +87 -81
    Bad examples of using a string with its length fixed

  sql/sql_select.cc
    1.375 05/11/15 15:34:37 bell@stripped +39 -34
    Bad examples of using a string with its length fixed

  sql/sql_prepare.cc
    1.164 05/11/15 15:34:37 bell@stripped +1 -1
    A bad example of using a string with its length fixed

  sql/sql_parse.cc
    1.512 05/11/15 15:34:37 bell@stripped +2 -2
    Bad examples of using a string with its length fixed

  sql/sql_load.cc
    1.89 05/11/15 15:34:36 bell@stripped +2 -1
    A bad example of using a string with its length fixed

  sql/sql_lex.cc
    1.174 05/11/15 15:34:36 bell@stripped +5 -5
    Bad examples of using a string with its length fixed

  sql/sql_analyse.cc
    1.66 05/11/15 15:34:36 bell@stripped +29 -29
    Bad examples of using a string with its length fixed
    Inefficient using of String::append() fixed

  sql/sql_acl.cc
    1.181 05/11/15 15:34:36 bell@stripped +54 -50
    Bad examples of using a string with its length fixed

  sql/spatial.cc
    1.25 05/11/15 15:34:36 bell@stripped +1 -1
    A bad example of using a string with its length fixed

  sql/sp_head.cc
    1.195 05/11/15 15:34:36 bell@stripped +23 -23
    Bad examples of using a string with its length fixed

  sql/sp.cc
    1.99 05/11/15 15:34:36 bell@stripped +10 -10
    Bad examples of using a string with its length fixed

  sql/slave.cc
    1.262 05/11/15 15:34:36 bell@stripped +6 -4
    Bad examples of using a string with its length fixed

  sql/share/errmsg.txt
    1.57 05/11/15 15:34:36 bell@stripped +2 -0
    warning for old format config file

  sql/repl_failsafe.cc
    1.59 05/11/15 15:34:36 bell@stripped +7 -6
    Bad examples of using a string with its length fixed

  sql/protocol.cc
    1.110 05/11/15 15:34:36 bell@stripped +1 -1
    A bad example of using a string with its length fixed

  sql/parse_file.h
    1.10 05/11/15 15:34:36 bell@stripped +13 -1
    A hook for uncknown keys added to the parser

  sql/parse_file.cc
    1.17 05/11/15 15:34:36 bell@stripped +120 -58
    Bad examples of using a string with its length fixed
    A hook for uncknown keys added to the parser

  sql/opt_range.cc
    1.198 05/11/15 15:34:36 bell@stripped +5 -5
    Inefficient using of String::append() fixed

  sql/log_event.cc
    1.197 05/11/15 15:34:36 bell@stripped +9 -9
    Bad examples of using a string with its length fixed

  sql/log.cc
    1.184 05/11/15 15:34:36 bell@stripped +3 -3
    Bad examples of using a string with its length fixed

  sql/key.cc
    1.35 05/11/15 15:34:35 bell@stripped +2 -2
    Bad examples of using a string with its length fixed

  sql/item_uniq.h
    1.27 05/11/15 15:34:35 bell@stripped +2 -2
    Bad examples of using a string with its length fixed

  sql/item_timefunc.cc
    1.99 05/11/15 15:34:35 bell@stripped +28 -28
    Inefficient using of String::append() fixed
    Bad examples of using a string with its length fixed

  sql/item_sum.cc
    1.168 05/11/15 15:34:35 bell@stripped +7 -7
    Bad examples of using a string with its length fixed
    Inefficient using of String::append() fixed

  sql/item_subselect.cc
    1.121 05/11/15 15:34:35 bell@stripped +13 -13
    Bad examples of using a string with its length fixed

  sql/item_strfunc.cc
    1.259 05/11/15 15:34:35 bell@stripped +10 -9
    Bad examples of using a string with its length fixed

  sql/item_func.cc
    1.268 05/11/15 15:34:35 bell@stripped +18 -18
    Bad examples of using a string with its length fixed

  sql/item_cmpfunc.cc
    1.185 05/11/15 15:34:35 bell@stripped +12 -12
    Bad examples of using a string with its length fixed

  sql/item.h
    1.180 05/11/15 15:34:35 bell@stripped +1 -1
    A bad example of using a string with its length fixed

  sql/item.cc
    1.197 05/11/15 15:34:35 bell@stripped +8 -8
    Bad examples of using a string with its length fixed

  sql/handler.cc
    1.203 05/11/15 15:34:35 bell@stripped +1 -1
    Inefficient using of String::append() fixed

  sql/ha_myisammrg.cc
    1.75 05/11/15 15:34:35 bell@stripped +2 -2
    Bad examples of using a string with its length fixed

  sql/ha_federated.cc
    1.53 05/11/15 15:34:35 bell@stripped +2 -2
    Inefficient using of String::append() fixed

  sql/ha_berkeley.cc
    1.160 05/11/15 15:34:35 bell@stripped +1 -1
    A bad example of using a string with its length fixed

  sql/field.cc
    1.291 05/11/15 15:34:35 bell@stripped +26 -26
    Inefficient using of String::append() fixed
    Bad examples of using a string with its length fixed

# 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:	bell
# Host:	sanja.is.com.ua
# Root:	/home/bell/mysql/bk/work-bug1-5.0

--- 1.290/sql/field.cc	2005-11-08 21:18:05 +02:00
+++ 1.291/sql/field.cc	2005-11-15 15:34:35 +02:00
@@ -1272,9 +1272,9 @@
 void Field_num::add_zerofill_and_unsigned(String &res) const
 {
   if (unsigned_flag)
-    res.append(" unsigned");
+    res.append(STRING_WITH_LEN(" unsigned"));
   if (zerofill)
-    res.append(" zerofill");
+    res.append(STRING_WITH_LEN(" zerofill"));
 }
 
 
@@ -1655,7 +1655,7 @@
 
 void Field_null::sql_type(String &res) const
 {
-  res.set_ascii("null", 4);
+  res.set_ascii(STRING_WITH_LEN("null"));
 }
 
 
@@ -1667,7 +1667,7 @@
 void
 Field_decimal::reset(void)
 {
-  Field_decimal::store("0",1,&my_charset_bin);
+  Field_decimal::store(STRING_WITH_LEN("0"),&my_charset_bin);
 }
 
 void Field_decimal::overflow(bool negative)
@@ -4113,7 +4113,7 @@
 {
   if (dec == NOT_FIXED_DEC)
   {
-    res.set_ascii("float", 5);
+    res.set_ascii(STRING_WITH_LEN("float"));
   }
   else
   {
@@ -4384,7 +4384,7 @@
   CHARSET_INFO *cs=res.charset();
   if (dec == NOT_FIXED_DEC)
   {
-    res.set_ascii("double",6);
+    res.set_ascii(STRING_WITH_LEN("double"));
   }
   else
   {
@@ -4673,7 +4673,7 @@
 
   if (temp == 0L)
   {				      /* Zero time is "000000" */
-    val_ptr->set("0000-00-00 00:00:00", 19, &my_charset_bin);
+    val_ptr->set(STRING_WITH_LEN("0000-00-00 00:00:00"), &my_charset_bin);
     return val_ptr;
   }
   val_buffer->set_charset(&my_charset_bin);	// Safety
@@ -4805,7 +4805,7 @@
 
 void Field_timestamp::sql_type(String &res) const
 {
-  res.set_ascii("timestamp", 9);
+  res.set_ascii(STRING_WITH_LEN("timestamp"));
 }
 
 
@@ -5074,7 +5074,7 @@
 
 void Field_time::sql_type(String &res) const
 {
-  res.set_ascii("time", 4);
+  res.set_ascii(STRING_WITH_LEN("time"));
 }
 
 /****************************************************************************
@@ -5381,7 +5381,7 @@
 
 void Field_date::sql_type(String &res) const
 {
-  res.set_ascii("date", 4);
+  res.set_ascii(STRING_WITH_LEN("date"));
 }
 
 
@@ -5564,7 +5564,7 @@
 
 void Field_newdate::sql_type(String &res) const
 {
-  res.set_ascii("date", 4);
+  res.set_ascii(STRING_WITH_LEN("date"));
 }
 
 
@@ -5838,7 +5838,7 @@
 
 void Field_datetime::sql_type(String &res) const
 {
-  res.set_ascii("datetime", 8);
+  res.set_ascii(STRING_WITH_LEN("datetime"));
 }
 
 /****************************************************************************
@@ -6061,7 +6061,7 @@
   res.length(length);
   if ((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) &&
       has_charset() && (charset()->state & MY_CS_BINSORT))
-    res.append(" binary");
+    res.append(STRING_WITH_LEN(" binary"));
 }
 
 
@@ -6454,7 +6454,7 @@
   res.length(length);
   if ((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) &&
       has_charset() && (charset()->state & MY_CS_BINSORT))
-    res.append(" binary");
+    res.append(STRING_WITH_LEN(" binary"));
 }
 
 
@@ -7174,10 +7174,10 @@
   }
   res.set_ascii(str,length);
   if (charset() == &my_charset_bin)
-    res.append("blob");
+    res.append(STRING_WITH_LEN("blob"));
   else
   {
-    res.append("text");
+    res.append(STRING_WITH_LEN("text"));
   }
 }
 
@@ -7397,28 +7397,28 @@
   switch (geom_type)
   {
     case GEOM_POINT:
-     res.set("point", 5, cs);
+     res.set(STRING_WITH_LEN("point"), cs);
      break;
     case GEOM_LINESTRING:
-     res.set("linestring", 10, cs);
+     res.set(STRING_WITH_LEN("linestring"), cs);
      break;
     case GEOM_POLYGON:
-     res.set("polygon", 7, cs);
+     res.set(STRING_WITH_LEN("polygon"), cs);
      break;
     case GEOM_MULTIPOINT:
-     res.set("multipoint", 10, cs);
+     res.set(STRING_WITH_LEN("multipoint"), cs);
      break;
     case GEOM_MULTILINESTRING:
-     res.set("multilinestring", 15, cs);
+     res.set(STRING_WITH_LEN("multilinestring"), cs);
      break;
     case GEOM_MULTIPOLYGON:
-     res.set("multipolygon", 12, cs);
+     res.set(STRING_WITH_LEN("multipolygon"), cs);
      break;
     case GEOM_GEOMETRYCOLLECTION:
-     res.set("geometrycollection", 18, cs);
+     res.set(STRING_WITH_LEN("geometrycollection"), cs);
      break;
     default:
-     res.set("geometry", 8, cs);
+     res.set(STRING_WITH_LEN("geometry"), cs);
   }
 }
 
@@ -7695,7 +7695,7 @@
   String enum_item(buffer, sizeof(buffer), res.charset());
 
   res.length(0);
-  res.append("enum(");
+  res.append(STRING_WITH_LEN("enum("));
 
   bool flag=0;
   uint *len= typelib->type_lengths;
@@ -7809,7 +7809,7 @@
   String set_item(buffer, sizeof(buffer), res.charset());
 
   res.length(0);
-  res.append("set(");
+  res.append(STRING_WITH_LEN("set("));
 
   bool flag=0;
   uint *len= typelib->type_lengths;

--- 1.159/sql/ha_berkeley.cc	2005-10-25 09:20:26 +03:00
+++ 1.160/sql/ha_berkeley.cc	2005-11-15 15:34:35 +02:00
@@ -308,7 +308,7 @@
     {
       protocol->prepare_for_resend();
       protocol->store(*a, system_charset_info);
-      protocol->store("BDB", 3, system_charset_info);
+      protocol->store(STRING_WITH_LEN("BDB"), system_charset_info);
       if (f && *f && strcmp(*a, *f) == 0)
       {
 	f++;

--- 1.74/sql/ha_myisammrg.cc	2005-10-03 06:03:42 +03:00
+++ 1.75/sql/ha_myisammrg.cc	2005-11-15 15:34:35 +02:00
@@ -490,10 +490,10 @@
 
   if (file->merge_insert_method != MERGE_INSERT_DISABLED)
   {
-    packet->append(" INSERT_METHOD=",15);
+    packet->append(STRING_WITH_LEN(" INSERT_METHOD="));
     packet->append(get_type(&merge_insert_method,file->merge_insert_method-1));
   }
-  packet->append(" UNION=(",8);
+  packet->append(STRING_WITH_LEN(" UNION=("));
   MYRG_TABLE *open_table,*first;
 
   current_db= table->s->db;

--- 1.202/sql/handler.cc	2005-11-03 14:24:47 +02:00
+++ 1.203/sql/handler.cc	2005-11-15 15:34:35 +02:00
@@ -1684,7 +1684,7 @@
       if (str.length() >= max_length)
       {
 	str.length(max_length-4);
-	str.append("...");
+	str.append(STRING_WITH_LEN("..."));
       }
       my_error(ER_DUP_ENTRY, MYF(0), str.c_ptr(), key_nr+1);
       DBUG_VOID_RETURN;

--- 1.196/sql/item.cc	2005-11-01 15:54:16 +02:00
+++ 1.197/sql/item.cc	2005-11-15 15:34:35 +02:00
@@ -383,7 +383,7 @@
   if (name)
   {
     THD *thd= current_thd;
-    str->append(" AS ", 4);
+    str->append(STRING_WITH_LEN(" AS "));
     append_identifier(thd, str, name, (uint) strlen(name));
   }
 }
@@ -1031,7 +1031,7 @@
 
 void Item_name_const::print(String *str)
 {
-  str->append("NAME_CONST(");
+  str->append(STRING_WITH_LEN("NAME_CONST("));
   name_item->print(str);
   str->append(',');
   value_item->print(str);
@@ -4852,7 +4852,7 @@
 
 void Item_ref_null_helper::print(String *str)
 {
-  str->append("<ref_null_helper>(", 18);
+  str->append(STRING_WITH_LEN("<ref_null_helper>("));
   if (ref)
     (*ref)->print(str);
   else
@@ -4969,7 +4969,7 @@
 
 void Item_null_helper::print(String *str)
 {
-  str->append("<null_helper>(", 14);
+  str->append(STRING_WITH_LEN("<null_helper>("));
   store->print(str);
   str->append(')');
 }
@@ -5029,10 +5029,10 @@
 {
   if (!arg)
   {
-    str->append("default", 7);
+    str->append(STRING_WITH_LEN("default"));
     return;
   }
-  str->append("default(", 8);
+  str->append(STRING_WITH_LEN("default("));
   arg->print(str);
   str->append(')');
 }
@@ -5126,7 +5126,7 @@
 
 void Item_insert_value::print(String *str)
 {
-  str->append("values(", 7);
+  str->append(STRING_WITH_LEN("values("));
   arg->print(str);
   str->append(')');
 }
@@ -5387,7 +5387,7 @@
 
 void Item_cache::print(String *str)
 {
-  str->append("<cache>(", 8);
+  str->append(STRING_WITH_LEN("<cache>("));
   if (example)
     example->print(str);
   else

--- 1.179/sql/item.h	2005-11-03 12:55:07 +02:00
+++ 1.180/sql/item.h	2005-11-15 15:34:35 +02:00
@@ -1055,7 +1055,7 @@
   bool basic_const_item() const { return 1; }
   Item *new_item() { return new Item_null(name); }
   bool is_null() { return 1; }
-  void print(String *str) { str->append("NULL", 4); }
+  void print(String *str) { str->append(STRING_WITH_LEN("NULL")); }
   Item *safe_charset_converter(CHARSET_INFO *tocs);
 };
 

--- 1.184/sql/item_cmpfunc.cc	2005-11-03 12:51:41 +02:00
+++ 1.185/sql/item_cmpfunc.cc	2005-11-15 15:34:35 +02:00
@@ -1175,10 +1175,10 @@
   str->append('(');
   args[0]->print(str);
   if (negated)
-    str->append(" not", 4);
-  str->append(" between ", 9);
+    str->append(STRING_WITH_LEN(" not"));
+  str->append(STRING_WITH_LEN(" between "));
   args[1]->print(str);
-  str->append(" and ", 5);
+  str->append(STRING_WITH_LEN(" and "));
   args[2]->print(str);
   str->append(')');
 }
@@ -1793,7 +1793,7 @@
 
 void Item_func_case::print(String *str)
 {
-  str->append("(case ", 6);
+  str->append(STRING_WITH_LEN("(case "));
   if (first_expr_num != -1)
   {
     args[first_expr_num]->print(str);
@@ -1801,19 +1801,19 @@
   }
   for (uint i=0 ; i < ncases ; i+=2)
   {
-    str->append("when ", 5);
+    str->append(STRING_WITH_LEN("when "));
     args[i]->print(str);
-    str->append(" then ", 6);
+    str->append(STRING_WITH_LEN(" then "));
     args[i+1]->print(str);
     str->append(' ');
   }
   if (else_expr_num != -1)
   {
-    str->append("else ", 5);
+    str->append(STRING_WITH_LEN("else "));
     args[else_expr_num]->print(str);
     str->append(' ');
   }
-  str->append("end)", 4);
+  str->append(STRING_WITH_LEN("end)"));
 }
 
 /*
@@ -2419,10 +2419,10 @@
   str->append('(');
   args[0]->print(str);
   if (negated)
-    str->append(" not", 4);
-  str->append(" in (", 5);
+    str->append(STRING_WITH_LEN(" not"));
+  str->append(STRING_WITH_LEN(" in ("));
   print_args(str, 1);
-  str->append("))", 2);
+  str->append(STRING_WITH_LEN("))"));
 }
 
 
@@ -2894,7 +2894,7 @@
 {
   str->append('(');
   args[0]->print(str);
-  str->append(" is not null)", 13);
+  str->append(STRING_WITH_LEN(" is not null)"));
 }
 
 

--- 1.267/sql/item_func.cc	2005-11-10 21:32:38 +02:00
+++ 1.268/sql/item_func.cc	2005-11-15 15:34:35 +02:00
@@ -794,9 +794,9 @@
 
 void Item_func_signed::print(String *str)
 {
-  str->append("cast(", 5);
+  str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str);
-  str->append(" as signed)", 11);
+  str->append(STRING_WITH_LEN(" as signed)"));
 
 }
 
@@ -855,9 +855,9 @@
 
 void Item_func_unsigned::print(String *str)
 {
-  str->append("cast(", 5);
+  str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str);
-  str->append(" as unsigned)", 13);
+  str->append(STRING_WITH_LEN(" as unsigned)"));
 
 }
 
@@ -927,9 +927,9 @@
 
 void Item_decimal_typecast::print(String *str)
 {
-  str->append("cast(", 5);
+  str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str);
-  str->append(" as decimal)", 12);
+  str->append(STRING_WITH_LEN(" as decimal)"));
 }
 
 
@@ -2234,7 +2234,7 @@
 
 void Item_func_locate::print(String *str)
 {
-  str->append("locate(", 7);
+  str->append(STRING_WITH_LEN("locate("));
   args[1]->print(str);
   str->append(',');
   args[0]->print(str);
@@ -3297,7 +3297,7 @@
 
 void Item_func_benchmark::print(String *str)
 {
-  str->append("benchmark(", 10);
+  str->append(STRING_WITH_LEN("benchmark("));
   char buffer[20];
   // my_charset_bin is good enough for numbers
   String st(buffer, sizeof(buffer), &my_charset_bin);
@@ -3811,9 +3811,9 @@
 
 void Item_func_set_user_var::print(String *str)
 {
-  str->append("(@", 2);
+  str->append(STRING_WITH_LEN("(@"));
   str->append(name.str, name.length);
-  str->append(":=", 2);
+  str->append(STRING_WITH_LEN(":="));
   args[0]->print(str);
   str->append(')');
 }
@@ -3821,9 +3821,9 @@
 
 void Item_func_set_user_var::print_as_stmt(String *str)
 {
-  str->append("set @", 5);
+  str->append(STRING_WITH_LEN("set @"));
   str->append(name.str, name.length);
-  str->append(":=", 2);
+  str->append(STRING_WITH_LEN(":="));
   args[0]->print(str);
   str->append(')');
 }
@@ -4054,7 +4054,7 @@
 
 void Item_func_get_user_var::print(String *str)
 {
-  str->append("(@", 2);
+  str->append(STRING_WITH_LEN("(@"));
   str->append(name.str,name.length);
   str->append(')');
 }
@@ -4479,15 +4479,15 @@
 
 void Item_func_match::print(String *str)
 {
-  str->append("(match ", 7);
+  str->append(STRING_WITH_LEN("(match "));
   print_args(str, 1);
-  str->append(" against (", 10);
+  str->append(STRING_WITH_LEN(" against ("));
   args[0]->print(str);
   if (flags & FT_BOOL)
-    str->append(" in boolean mode", 16);
+    str->append(STRING_WITH_LEN(" in boolean mode"));
   else if (flags & FT_EXPAND)
-    str->append(" with query expansion", 21);
-  str->append("))", 2);
+    str->append(STRING_WITH_LEN(" with query expansion"));
+  str->append(STRING_WITH_LEN("))"));
 }
 
 longlong Item_func_bit_xor::val_int()

--- 1.258/sql/item_strfunc.cc	2005-10-13 13:09:35 +03:00
+++ 1.259/sql/item_strfunc.cc	2005-11-15 15:34:35 +02:00
@@ -1790,7 +1790,7 @@
 
 void Item_func_format::print(String *str)
 {
-  str->append("format(", 7);
+  str->append(STRING_WITH_LEN("format("));
   args[0]->print(str);
   str->append(',');  
   // my_charset_bin is good enough for numbers
@@ -1950,7 +1950,7 @@
 
 void Item_func_make_set::print(String *str)
 {
-  str->append("make_set(", 9);
+  str->append(STRING_WITH_LEN("make_set("));
   item->print(str);
   if (arg_count)
   {
@@ -2331,9 +2331,9 @@
 
 void Item_func_conv_charset::print(String *str)
 {
-  str->append("convert(", 8);
+  str->append(STRING_WITH_LEN("convert("));
   args[0]->print(str);
-  str->append(" using ", 7);
+  str->append(STRING_WITH_LEN(" using "));
   str->append(conv_charset->csname);
   str->append(')');
 }
@@ -2403,7 +2403,7 @@
 {
   str->append('(');
   args[0]->print(str);
-  str->append(" collate ", 9);
+  str->append(STRING_WITH_LEN(" collate "));
   DBUG_ASSERT(args[1]->basic_const_item() &&
               args[1]->type() == Item::STRING_ITEM);
   args[1]->str_value.print(str);
@@ -2523,9 +2523,9 @@
 
 void Item_func_binary::print(String *str)
 {
-  str->append("cast(", 5);
+  str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str);
-  str->append(" as binary)", 11);
+  str->append(STRING_WITH_LEN(" as binary)"));
 }
 
 
@@ -2630,7 +2630,7 @@
     }
     break;
   case 3:
-    sep_buf.set(",", 1, default_charset());
+    sep_buf.set(STRING_WITH_LEN(","), default_charset());
     sep = &sep_buf;
     break;
   default:
@@ -2745,7 +2745,8 @@
   uint arg_length, new_length;
   if (!arg)					// Null argument
   {
-    str->copy("NULL", 4, collation.collation);	// Return the string 'NULL'
+    /* Return the string 'NULL' */
+    str->copy(STRING_WITH_LEN("NULL"), collation.collation);
     null_value= 0;
     return str;
   }

--- 1.167/sql/item_sum.cc	2005-11-01 16:21:43 +02:00
+++ 1.168/sql/item_sum.cc	2005-11-15 15:34:35 +02:00
@@ -3156,9 +3156,9 @@
 
 void Item_func_group_concat::print(String *str)
 {
-  str->append("group_concat(", 13);
+  str->append(STRING_WITH_LEN("group_concat("));
   if (distinct)
-    str->append("distinct ", 9);
+    str->append(STRING_WITH_LEN("distinct "));
   for (uint i= 0; i < arg_count_field; i++)
   {
     if (i)
@@ -3167,19 +3167,19 @@
   }
   if (arg_count_order)
   {
-    str->append(" order by ", 10);
+    str->append(STRING_WITH_LEN(" order by "));
     for (uint i= 0 ; i < arg_count_order ; i++)
     {
       if (i)
         str->append(',');
       (*order[i]->item)->print(str);
       if (order[i]->asc)
-        str->append(" ASC");
+        str->append(STRING_WITH_LEN(" ASC"));
       else
-        str->append(" DESC");
+        str->append(STRING_WITH_LEN(" DESC"));
     }
   }
-  str->append(" separator \'", 12);
+  str->append(STRING_WITH_LEN(" separator \'"));
   str->append(*separator);
-  str->append("\')", 2);
+  str->append(STRING_WITH_LEN("\')"));
 }

--- 1.98/sql/item_timefunc.cc	2005-11-01 18:47:51 +02:00
+++ 1.99/sql/item_timefunc.cc	2005-11-15 15:34:35 +02:00
@@ -506,7 +506,7 @@
   str->set_charset(&my_charset_bin);
 
   if (l_time->neg)
-    str->append("-", 1);
+    str->append('-');
   
   end= (ptr= format->format.str) + format->format.length;
   for (; ptr != end ; ptr++)
@@ -546,21 +546,21 @@
 	length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
 	str->append_with_prefill(intbuff, length, 1, '0');
 	if (l_time->day >= 10 &&  l_time->day <= 19)
-	  str->append("th", 2);
+	  str->append(STRING_WITH_LEN("th"));
 	else
 	{
 	  switch (l_time->day %10) {
 	  case 1:
-	    str->append("st",2);
+	    str->append(STRING_WITH_LEN("st"));
 	    break;
 	  case 2:
-	    str->append("nd",2);
+	    str->append(STRING_WITH_LEN("nd"));
 	    break;
 	  case 3:
-	    str->append("rd",2);
+	    str->append(STRING_WITH_LEN("rd"));
 	    break;
 	  default:
-	    str->append("th",2);
+	    str->append(STRING_WITH_LEN("th"));
 	    break;
 	  }
 	}
@@ -2142,9 +2142,9 @@
 
 void Item_extract::print(String *str)
 {
-  str->append("extract(", 8);
+  str->append(STRING_WITH_LEN("extract("));
   str->append(interval_names[int_type]);
-  str->append(" from ", 6);
+  str->append(STRING_WITH_LEN(" from "));
   args[0]->print(str);
   str->append(')');
 }
@@ -2286,9 +2286,9 @@
 
 void Item_typecast::print(String *str)
 {
-  str->append("cast(", 5);
+  str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str);
-  str->append(" as ", 4);
+  str->append(STRING_WITH_LEN(" as "));
   str->append(cast_type());
   str->append(')');
 }
@@ -2296,9 +2296,9 @@
 
 void Item_char_typecast::print(String *str)
 {
-  str->append("cast(", 5);
+  str->append(STRING_WITH_LEN("cast("));
   args[0]->print(str);
-  str->append(" as char", 8);
+  str->append(STRING_WITH_LEN(" as char"));
   if (cast_length >= 0)
   {
     str->append('(');
@@ -2311,7 +2311,7 @@
   }
   if (cast_cs)
   {
-    str->append(" charset ", 9);
+    str->append(STRING_WITH_LEN(" charset "));
     str->append(cast_cs->csname);
   }
   str->append(')');
@@ -2609,14 +2609,14 @@
   if (is_date)
   {
     DBUG_ASSERT(sign > 0);
-    str->append("timestamp(", 10);
+    str->append(STRING_WITH_LEN("timestamp("));
   }
   else
   {
     if (sign > 0)
-      str->append("addtime(", 8);
+      str->append(STRING_WITH_LEN("addtime("));
     else
-      str->append("subtime(", 8);
+      str->append(STRING_WITH_LEN("subtime("));
   }
   args[0]->print(str);
   str->append(',');
@@ -2825,31 +2825,31 @@
 
   switch (int_type) {
   case INTERVAL_YEAR:
-    str->append("YEAR");
+    str->append(STRING_WITH_LEN("YEAR"));
     break;
   case INTERVAL_QUARTER:
-    str->append("QUARTER");
+    str->append(STRING_WITH_LEN("QUARTER"));
     break;
   case INTERVAL_MONTH:
-    str->append("MONTH");
+    str->append(STRING_WITH_LEN("MONTH"));
     break;
   case INTERVAL_WEEK:          
-    str->append("WEEK");
+    str->append(STRING_WITH_LEN("WEEK"));
     break;
   case INTERVAL_DAY:		
-    str->append("DAY");
+    str->append(STRING_WITH_LEN("DAY"));
     break;
   case INTERVAL_HOUR:
-    str->append("HOUR");
+    str->append(STRING_WITH_LEN("HOUR"));
     break;
   case INTERVAL_MINUTE:		
-    str->append("MINUTE");
+    str->append(STRING_WITH_LEN("MINUTE"));
     break;
   case INTERVAL_SECOND:
-    str->append("SECOND");
+    str->append(STRING_WITH_LEN("SECOND"));
     break;		
   case INTERVAL_MICROSECOND:
-    str->append("SECOND_FRAC");
+    str->append(STRING_WITH_LEN("SECOND_FRAC"));
     break;
   default:
     break;
@@ -2905,13 +2905,13 @@
 
   switch (type) {
   case MYSQL_TIMESTAMP_DATE:
-    str->append("DATE, ");
+    str->append(STRING_WITH_LEN("DATE, "));
     break;
   case MYSQL_TIMESTAMP_DATETIME:
-    str->append("DATETIME, ");
+    str->append(STRING_WITH_LEN("DATETIME, "));
     break;
   case MYSQL_TIMESTAMP_TIME:
-    str->append("TIME, ");
+    str->append(STRING_WITH_LEN("TIME, "));
     break;
   default:
     DBUG_ASSERT(0);

--- 1.26/sql/item_uniq.h	2005-07-01 07:05:35 +03:00
+++ 1.27/sql/item_uniq.h	2005-11-15 15:34:35 +02:00
@@ -29,7 +29,7 @@
     :Item_real_func(list) {}
   double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; }
   void fix_length_and_dec() { decimals=0; max_length=6; }
-  void print(String *str) { str->append("0.0", 3); }
+  void print(String *str) { str->append(STRING_WITH_LEN("0.0")); }
   const char *func_name() const { return "unique_users"; }
 };
 
@@ -57,7 +57,7 @@
   {
     return new Item_sum_unique_users(thd, this);
   }
-  void print(String *str) { str->append("0.0", 3); }
+  void print(String *str) { str->append(STRING_WITH_LEN("0.0")); }
   Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length);
   const char *func_name() const { return "sum_unique_users"; }
 };

--- 1.34/sql/key.cc	2005-05-06 13:46:02 +03:00
+++ 1.35/sql/key.cc	2005-11-15 15:34:35 +02:00
@@ -322,7 +322,7 @@
     {
       if (table->record[0][key_part->null_offset] & key_part->null_bit)
       {
-	to->append("NULL", 4);
+	to->append(STRING_WITH_LEN("NULL"));
 	continue;
       }
     }
@@ -334,7 +334,7 @@
       to->append(tmp);
     }
     else
-      to->append("???", 3);
+      to->append(STRING_WITH_LEN("???"));
   }
   DBUG_VOID_RETURN;
 }

--- 1.183/sql/log.cc	2005-11-10 18:21:41 +02:00
+++ 1.184/sql/log.cc	2005-11-15 15:34:36 +02:00
@@ -131,7 +131,7 @@
     // we're here because trans_log was flushed in MYSQL_LOG::log()
     DBUG_RETURN(0);
   }
-  Query_log_event qev(thd, "COMMIT", 6, TRUE, FALSE);
+  Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
   DBUG_RETURN(binlog_end_trans(thd, trans_log, &qev));
 }
 
@@ -155,7 +155,7 @@
   */
   if (unlikely(thd->options & OPTION_STATUS_NO_TRANS_UPDATE))
   {
-    Query_log_event qev(thd, "ROLLBACK", 8, TRUE, FALSE);
+    Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE);
     error= binlog_end_trans(thd, trans_log, &qev);
   }
   else
@@ -1848,7 +1848,7 @@
     */
     if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
     {
-      Query_log_event qinfo(thd, "BEGIN", 5, TRUE, FALSE);
+      Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), TRUE, FALSE);
       /*
         Imagine this is rollback due to net timeout, after all statements of
         the transaction succeeded. Then we want a zero-error code in BEGIN.

--- 1.196/sql/log_event.cc	2005-10-19 20:42:06 +03:00
+++ 1.197/sql/log_event.cc	2005-11-15 15:34:36 +02:00
@@ -160,7 +160,7 @@
      we cannot meet Start_log event in the middle of events from one 
      LOAD DATA.
   */
-  p= strmake(prefbuf,"SQL_LOAD-",9);
+  p= strmake(prefbuf, STRING_WITH_LEN("SQL_LOAD-"));
   p= int10_to_str(::server_id, p, 10);
   *(p++)= '-';
   *p= 0;
@@ -2991,7 +2991,7 @@
   String tmp(buf1, sizeof(buf1), log_cs);
   tmp.length(0);
   tmp.append(new_log_ident, ident_len);
-  tmp.append(";pos=");
+  tmp.append(STRING_WITH_LEN(";pos="));
   tmp.append(llstr(pos,buf));
   protocol->store(tmp.ptr(), tmp.length(), &my_charset_bin);
 }
@@ -4163,7 +4163,7 @@
   bzero((char*)&file, sizeof(file));
   p = slave_load_file_stem(fname_buf, file_id, server_id);
   strmov(p, ".info");			// strmov takes less code than memcpy
-  strnmov(proc_info, "Making temp file ", 17); // no end 0
+  strnmov(proc_info, STRING_WITH_LEN("Making temp file ")); // no end 0
   thd->proc_info= proc_info;
   my_delete(fname_buf, MYF(0)); // old copy may exist already
   if ((fd= my_create(fname_buf, CREATE_MODE,
@@ -4332,7 +4332,7 @@
   DBUG_ENTER("Append_block_log_event::exec_event");
 
   memcpy(p, ".data", 6);
-  strnmov(proc_info, "Making temp file ", 17); // no end 0
+  strnmov(proc_info, STRING_WITH_LEN("Making temp file ")); // no end 0
   thd->proc_info= proc_info;
   if (get_create_or_append())
   {
@@ -4816,23 +4816,23 @@
   p= buf;
   memcpy(p, query, fn_pos_start);
   p+= fn_pos_start;
-  fname= (p= strmake(p, " INFILE \'", 9));
+  fname= (p= strmake(p, STRING_WITH_LEN(" INFILE \'")));
   p= slave_load_file_stem(p, file_id, server_id);
-  fname_end= (p= strmake(p, ".data", 5));
+  fname_end= (p= strmake(p, STRING_WITH_LEN(".data")));
   *(p++)='\'';
   switch (dup_handling)
   {
   case LOAD_DUP_IGNORE:
-    p= strmake(p, " IGNORE", 7);
+    p= strmake(p, STRING_WITH_LEN(" IGNORE"));
     break;
   case LOAD_DUP_REPLACE:
-    p= strmake(p, " REPLACE", 8);
+    p= strmake(p, STRING_WITH_LEN(" REPLACE"));
     break;
   default:
     /* Ordinary load data */
     break;
   }
-  p= strmake(p, " INTO", 5);
+  p= strmake(p, STRING_WITH_LEN(" INTO"));
   p= strmake(p, query+fn_pos_end, q_len-fn_pos_end);
 
   error= Query_log_event::exec_event(rli, buf, p-buf);

--- 1.109/sql/protocol.cc	2005-10-17 16:07:23 +03:00
+++ 1.110/sql/protocol.cc	2005-11-15 15:34:36 +02:00
@@ -572,7 +572,7 @@
 
     if (thd->client_capabilities & CLIENT_PROTOCOL_41)
     {
-      if (prot.store("def", 3, cs, thd_charset) ||
+      if (prot.store(STRING_WITH_LEN("def"), cs, thd_charset) ||
 	  prot.store(field.db_name, (uint) strlen(field.db_name),
 		     cs, thd_charset) ||
 	  prot.store(field.table_name, (uint) strlen(field.table_name),

--- 1.197/sql/opt_range.cc	2005-11-04 13:16:41 +02:00
+++ 1.198/sql/opt_range.cc	2005-11-15 15:34:36 +02:00
@@ -6691,7 +6691,7 @@
   QUICK_RANGE_SELECT *quick;
   bool first= TRUE;
   List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
-  str->append("sort_union(");
+  str->append(STRING_WITH_LEN("sort_union("));
   while ((quick= it++))
   {
     if (!first)
@@ -6713,7 +6713,7 @@
   bool first= TRUE;
   QUICK_RANGE_SELECT *quick;
   List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects);
-  str->append("intersect(");
+  str->append(STRING_WITH_LEN("intersect("));
   while ((quick= it++))
   {
     KEY *key_info= head->key_info + quick->index;
@@ -6737,7 +6737,7 @@
   bool first= TRUE;
   QUICK_SELECT_I *quick;
   List_iterator_fast<QUICK_SELECT_I> it(quick_selects);
-  str->append("union(");
+  str->append(STRING_WITH_LEN("union("));
   while ((quick= it++))
   {
     if (!first)
@@ -8868,7 +8868,7 @@
     }
   }
   if (!tmp.length())
-    tmp.append("(empty)");
+    tmp.append(STRING_WITH_LEN("(empty)"));
 
   DBUG_PRINT("info", ("SEL_TREE %p (%s) scans:%s", tree, msg, tmp.ptr()));
 
@@ -8894,7 +8894,7 @@
     tmp.append(table->key_info[(*start)->keynr].name);
   }
   if (!tmp.length())
-    tmp.append("(empty)");
+    tmp.append(STRING_WITH_LEN("(empty)"));
   DBUG_PRINT("info", ("ROR key scans (%s): %s", msg, tmp.ptr()));
   DBUG_VOID_RETURN;
 }

--- 1.261/sql/slave.cc	2005-10-27 16:03:48 +03:00
+++ 1.262/sql/slave.cc	2005-11-15 15:34:36 +02:00
@@ -1397,7 +1397,7 @@
   MYSQL_RES *master_res= 0;
   MYSQL_ROW master_row;
   
-  if (!mysql_real_query(mysql, "SELECT UNIX_TIMESTAMP()", 23) &&
+  if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT UNIX_TIMESTAMP()")) &&
       (master_res= mysql_store_result(mysql)) &&
       (master_row= mysql_fetch_row(master_res)))
   {
@@ -1423,7 +1423,8 @@
     Note: we could have put a @@SERVER_ID in the previous SELECT
     UNIX_TIMESTAMP() instead, but this would not have worked on 3.23 masters.
   */
-  if (!mysql_real_query(mysql, "SHOW VARIABLES LIKE 'SERVER_ID'", 31) &&
+  if (!mysql_real_query(mysql,
+                        STRING_WITH_LEN("SHOW VARIABLES LIKE 'SERVER_ID'")) &&
       (master_res= mysql_store_result(mysql)))
   {
     if ((master_row= mysql_fetch_row(master_res)) &&
@@ -1458,7 +1459,8 @@
     goto err;
 
   if ((*mysql->server_version == '4') &&
-      !mysql_real_query(mysql, "SELECT @@GLOBAL.COLLATION_SERVER", 32) &&
+      !mysql_real_query(mysql,
+                        STRING_WITH_LEN("SELECT @@GLOBAL.COLLATION_SERVER")) &&
       (master_res= mysql_store_result(mysql)))
   {
     if ((master_row= mysql_fetch_row(master_res)) &&
@@ -1485,7 +1487,7 @@
     those were alpha).
   */
   if ((*mysql->server_version == '4') &&
-      !mysql_real_query(mysql, "SELECT @@GLOBAL.TIME_ZONE", 25) &&
+      !mysql_real_query(mysql, STRING_WITH_LEN("SELECT @@GLOBAL.TIME_ZONE")) &&
       (master_res= mysql_store_result(mysql)))
   {
     if ((master_row= mysql_fetch_row(master_res)) &&

--- 1.180/sql/sql_acl.cc	2005-11-10 21:24:52 +02:00
+++ 1.181/sql/sql_acl.cc	2005-11-15 15:34:36 +02:00
@@ -1811,19 +1811,22 @@
     /* We write down SSL related ACL stuff */
     switch (lex->ssl_type) {
     case SSL_TYPE_ANY:
-      table->field[next_field]->store("ANY", 3, &my_charset_latin1);
+      table->field[next_field]->store(STRING_WITH_LEN("ANY"),
+                                      &my_charset_latin1);
       table->field[next_field+1]->store("", 0, &my_charset_latin1);
       table->field[next_field+2]->store("", 0, &my_charset_latin1);
       table->field[next_field+3]->store("", 0, &my_charset_latin1);
       break;
     case SSL_TYPE_X509:
-      table->field[next_field]->store("X509", 4, &my_charset_latin1);
+      table->field[next_field]->store(STRING_WITH_LEN("X509"),
+                                      &my_charset_latin1);
       table->field[next_field+1]->store("", 0, &my_charset_latin1);
       table->field[next_field+2]->store("", 0, &my_charset_latin1);
       table->field[next_field+3]->store("", 0, &my_charset_latin1);
       break;
     case SSL_TYPE_SPECIFIED:
-      table->field[next_field]->store("SPECIFIED", 9, &my_charset_latin1);
+      table->field[next_field]->store(STRING_WITH_LEN("SPECIFIED"),
+                                      &my_charset_latin1);
       table->field[next_field+1]->store("", 0, &my_charset_latin1);
       table->field[next_field+2]->store("", 0, &my_charset_latin1);
       table->field[next_field+3]->store("", 0, &my_charset_latin1);
@@ -4056,13 +4059,13 @@
   {
     String global(buff,sizeof(buff),system_charset_info);
     global.length(0);
-    global.append("GRANT ",6);
+    global.append(STRING_WITH_LEN("GRANT "));
 
     want_access= acl_user->access;
     if (test_all_bits(want_access, (GLOBAL_ACLS & ~ GRANT_ACL)))
-      global.append("ALL PRIVILEGES",14);
+      global.append(STRING_WITH_LEN("ALL PRIVILEGES"));
     else if (!(want_access & ~GRANT_ACL))
-      global.append("USAGE",5);
+      global.append(STRING_WITH_LEN("USAGE"));
     else
     {
       bool found=0;
@@ -4072,16 +4075,16 @@
 	if (test_access & j)
 	{
 	  if (found)
-	    global.append(", ",2);
+	    global.append(STRING_WITH_LEN(", "));
 	  found=1;
 	  global.append(command_array[counter],command_lengths[counter]);
 	}
       }
     }
-    global.append (" ON *.* TO '",12);
+    global.append (STRING_WITH_LEN(" ON *.* TO '"));
     global.append(lex_user->user.str, lex_user->user.length,
 		  system_charset_info);
-    global.append ("'@'",3);
+    global.append (STRING_WITH_LEN("'@'"));
     global.append(lex_user->host.str,lex_user->host.length,
 		  system_charset_info);
     global.append ('\'');
@@ -4092,23 +4095,23 @@
         make_password_from_salt(passwd_buff, acl_user->salt);
       else
         make_password_from_salt_323(passwd_buff, (ulong *) acl_user->salt);
-      global.append(" IDENTIFIED BY PASSWORD '",25);
+      global.append(STRING_WITH_LEN(" IDENTIFIED BY PASSWORD '"));
       global.append(passwd_buff);
       global.append('\'');
     }
     /* "show grants" SSL related stuff */
     if (acl_user->ssl_type == SSL_TYPE_ANY)
-      global.append(" REQUIRE SSL",12);
+      global.append(STRING_WITH_LEN(" REQUIRE SSL"));
     else if (acl_user->ssl_type == SSL_TYPE_X509)
-      global.append(" REQUIRE X509",13);
+      global.append(STRING_WITH_LEN(" REQUIRE X509"));
     else if (acl_user->ssl_type == SSL_TYPE_SPECIFIED)
     {
       int ssl_options = 0;
-      global.append(" REQUIRE ",9);
+      global.append(STRING_WITH_LEN(" REQUIRE "));
       if (acl_user->x509_issuer)
       {
 	ssl_options++;
-	global.append("ISSUER \'",8);
+	global.append(STRING_WITH_LEN("ISSUER \'"));
 	global.append(acl_user->x509_issuer,strlen(acl_user->x509_issuer));
 	global.append('\'');
       }
@@ -4116,7 +4119,7 @@
       {
 	if (ssl_options++)
 	  global.append(' ');
-	global.append("SUBJECT \'",9);
+	global.append(STRING_WITH_LEN("SUBJECT \'"));
 	global.append(acl_user->x509_subject,strlen(acl_user->x509_subject),
                       system_charset_info);
 	global.append('\'');
@@ -4125,7 +4128,7 @@
       {
 	if (ssl_options++)
 	  global.append(' ');
-	global.append("CIPHER '",8);
+	global.append(STRING_WITH_LEN("CIPHER '"));
 	global.append(acl_user->ssl_cipher,strlen(acl_user->ssl_cipher),
                       system_charset_info);
 	global.append('\'');
@@ -4137,9 +4140,9 @@
          acl_user->user_resource.conn_per_hour ||
          acl_user->user_resource.user_conn))
     {
-      global.append(" WITH",5);
+      global.append(STRING_WITH_LEN(" WITH"));
       if (want_access & GRANT_ACL)
-	global.append(" GRANT OPTION",13);
+	global.append(STRING_WITH_LEN(" GRANT OPTION"));
       add_user_option(&global, acl_user->user_resource.questions,
 		      "MAX_QUERIES_PER_HOUR");
       add_user_option(&global, acl_user->user_resource.updates,
@@ -4177,12 +4180,12 @@
       {
 	String db(buff,sizeof(buff),system_charset_info);
 	db.length(0);
-	db.append("GRANT ",6);
+	db.append(STRING_WITH_LEN("GRANT "));
 
 	if (test_all_bits(want_access,(DB_ACLS & ~GRANT_ACL)))
-	  db.append("ALL PRIVILEGES",14);
+	  db.append(STRING_WITH_LEN("ALL PRIVILEGES"));
 	else if (!(want_access & ~GRANT_ACL))
-	  db.append("USAGE",5);
+	  db.append(STRING_WITH_LEN("USAGE"));
 	else
 	{
 	  int found=0, cnt;
@@ -4192,23 +4195,23 @@
 	    if (test_access & j)
 	    {
 	      if (found)
-		db.append(", ",2);
+		db.append(STRING_WITH_LEN(", "));
 	      found = 1;
 	      db.append(command_array[cnt],command_lengths[cnt]);
 	    }
 	  }
 	}
-	db.append (" ON ",4);
+	db.append (STRING_WITH_LEN(" ON "));
 	append_identifier(thd, &db, acl_db->db, strlen(acl_db->db));
-	db.append (".* TO '",7);
+	db.append (STRING_WITH_LEN(".* TO '"));
 	db.append(lex_user->user.str, lex_user->user.length,
 		  system_charset_info);
-	db.append ("'@'",3);
+	db.append (STRING_WITH_LEN("'@'"));
 	db.append(lex_user->host.str, lex_user->host.length,
                   system_charset_info);
 	db.append ('\'');
 	if (want_access & GRANT_ACL)
-	  db.append(" WITH GRANT OPTION",18);
+	  db.append(STRING_WITH_LEN(" WITH GRANT OPTION"));
 	protocol->prepare_for_resend();
 	protocol->store(db.ptr(),db.length(),db.charset());
 	if (protocol->write())
@@ -4241,12 +4244,12 @@
 	ulong test_access= (table_access | grant_table->cols) & ~GRANT_ACL;
 
 	global.length(0);
-	global.append("GRANT ",6);
+	global.append(STRING_WITH_LEN("GRANT "));
 
 	if (test_all_bits(table_access, (TABLE_ACLS & ~GRANT_ACL)))
-	  global.append("ALL PRIVILEGES",14);
+	  global.append(STRING_WITH_LEN("ALL PRIVILEGES"));
 	else if (!test_access)
- 	  global.append("USAGE",5);
+	  global.append(STRING_WITH_LEN("USAGE"));
 	else
 	{
           /* Add specific column access */
@@ -4258,7 +4261,7 @@
 	    if (test_access & j)
 	    {
 	      if (found)
-		global.append(", ",2);
+		global.append(STRING_WITH_LEN(", "));
 	      found= 1;
 	      global.append(command_array[counter],command_lengths[counter]);
 
@@ -4282,14 +4285,14 @@
 		      */
 		      if (table_access & j)
 		      {
-			global.append(", ", 2);
+			global.append(STRING_WITH_LEN(", "));
 			global.append(command_array[counter],
 				      command_lengths[counter]);
 		      }
-		      global.append(" (",2);
+		      global.append(STRING_WITH_LEN(" ("));
 		    }
 		    else
-		      global.append(", ",2);
+		      global.append(STRING_WITH_LEN(", "));
 		    global.append(grant_column->column,
 				  grant_column->key_length,
 				  system_charset_info);
@@ -4301,21 +4304,21 @@
 	    }
 	  }
 	}
-	global.append(" ON ",4);
+	global.append(STRING_WITH_LEN(" ON "));
 	append_identifier(thd, &global, grant_table->db,
 			  strlen(grant_table->db));
 	global.append('.');
 	append_identifier(thd, &global, grant_table->tname,
 			  strlen(grant_table->tname));
-	global.append(" TO '",5);
+	global.append(STRING_WITH_LEN(" TO '"));
 	global.append(lex_user->user.str, lex_user->user.length,
 		      system_charset_info);
-	global.append("'@'",3);
+	global.append(STRING_WITH_LEN("'@'"));
 	global.append(lex_user->host.str,lex_user->host.length,
 		      system_charset_info);
 	global.append('\'');
 	if (table_access & GRANT_ACL)
-	  global.append(" WITH GRANT OPTION",18);
+	  global.append(STRING_WITH_LEN(" WITH GRANT OPTION"));
 	protocol->prepare_for_resend();
 	protocol->store(global.ptr(),global.length(),global.charset());
 	if (protocol->write())
@@ -4328,14 +4331,14 @@
   }
 
   if (show_routine_grants(thd, lex_user, &proc_priv_hash, 
-                          "PROCEDURE", 9, buff, sizeof(buff)))
+                          STRING_WITH_LEN("PROCEDURE"), buff, sizeof(buff)))
   {
     error= -1;
     goto end;
   }
 
   if (show_routine_grants(thd, lex_user, &func_priv_hash,
-                          "FUNCTION", 8, buff, sizeof(buff)))
+                          STRING_WITH_LEN("FUNCTION"), buff, sizeof(buff)))
   {
     error= -1;
     goto end;
@@ -4376,10 +4379,10 @@
 	ulong test_access= proc_access & ~GRANT_ACL;
 
 	global.length(0);
-	global.append("GRANT ",6);
+	global.append(STRING_WITH_LEN("GRANT "));
 
 	if (!test_access)
- 	  global.append("USAGE",5);
+ 	  global.append(STRING_WITH_LEN("USAGE"));
 	else
 	{
           /* Add specific procedure access */
@@ -4391,13 +4394,13 @@
 	    if (test_access & j)
 	    {
 	      if (found)
-		global.append(", ",2);
+		global.append(STRING_WITH_LEN(", "));
 	      found= 1;
 	      global.append(command_array[counter],command_lengths[counter]);
 	    }
 	  }
 	}
-	global.append(" ON ",4);
+	global.append(STRING_WITH_LEN(" ON "));
         global.append(type,typelen);
         global.append(' ');
 	append_identifier(thd, &global, grant_proc->db,
@@ -4405,15 +4408,15 @@
 	global.append('.');
 	append_identifier(thd, &global, grant_proc->tname,
 			  strlen(grant_proc->tname));
-	global.append(" TO '",5);
+	global.append(STRING_WITH_LEN(" TO '"));
 	global.append(lex_user->user.str, lex_user->user.length,
 		      system_charset_info);
-	global.append("'@'",3);
+	global.append(STRING_WITH_LEN("'@'"));
 	global.append(lex_user->host.str,lex_user->host.length,
 		      system_charset_info);
 	global.append('\'');
 	if (proc_access & GRANT_ACL)
-	  global.append(" WITH GRANT OPTION",18);
+	  global.append(STRING_WITH_LEN(" WITH GRANT OPTION"));
 	protocol->prepare_for_resend();
 	protocol->store(global.ptr(),global.length(),global.charset());
 	if (protocol->write())
@@ -5068,7 +5071,7 @@
     str->append(',');
   str->append('\'');
   str->append(user->user.str);
-  str->append("'@'");
+  str->append(STRING_WITH_LEN("'@'"));
   str->append(user->host.str);
   str->append('\'');
 }
@@ -5650,7 +5653,8 @@
 
     strxmov(buff,"'",user,"'@'",host,"'",NullS);
     if (!(want_access & ~GRANT_ACL))
-      update_schema_privilege(table, buff, 0, 0, 0, 0, "USAGE", 5, is_grantable);
+      update_schema_privilege(table, buff, 0, 0, 0, 0,
+                              STRING_WITH_LEN("USAGE"), is_grantable);
     else
     {
       uint priv_id;
@@ -5708,7 +5712,7 @@
       strxmov(buff,"'",user,"'@'",host,"'",NullS);
       if (!(want_access & ~GRANT_ACL))
         update_schema_privilege(table, buff, acl_db->db, 0, 0,
-                                0, "USAGE", 5, is_grantable);
+                                0, STRING_WITH_LEN("USAGE"), is_grantable);
       else
       {
         int cnt;
@@ -5768,7 +5772,7 @@
       strxmov(buff,"'",user,"'@'",grant_table->host.hostname,"'",NullS);
       if (!test_access)
         update_schema_privilege(table, buff, grant_table->db, grant_table->tname,
-                                0, 0, "USAGE", 5, is_grantable);
+                                0, 0, STRING_WITH_LEN("USAGE"), is_grantable);
       else
       {
         ulong j;

--- 1.65/sql/sql_analyse.cc	2005-11-01 14:14:13 +02:00
+++ 1.66/sql/sql_analyse.cc	2005-11-15 15:34:36 +02:00
@@ -733,13 +733,13 @@
       tree_info.found = 0;
       tree_info.item = (*f)->item;
 
-      tmp_str.set("ENUM(", 5,&my_charset_bin);
+      tmp_str.set(STRING_WITH_LEN("ENUM("),&my_charset_bin);
       tree_walk(&(*f)->tree, (*f)->collect_enum(), (char*) &tree_info,
 		left_root_right);
       tmp_str.append(')');
 
       if (!(*f)->nulls)
-	tmp_str.append(" NOT NULL");
+	tmp_str.append(STRING_WITH_LEN(" NOT NULL"));
       output_str_length = tmp_str.length();
       func_items[9]->set(tmp_str.ptr(), tmp_str.length(), tmp_str.charset());
       if (result->send_data(result_fields))
@@ -749,35 +749,35 @@
 
     ans.length(0);
     if (!(*f)->treemem && !(*f)->tree_elements)
-      ans.append("CHAR(0)", 7);
+      ans.append(STRING_WITH_LEN("CHAR(0)"));
     else if ((*f)->item->type() == Item::FIELD_ITEM)
     {
       switch (((Item_field*) (*f)->item)->field->real_type())
       {
       case FIELD_TYPE_TIMESTAMP:
-	ans.append("TIMESTAMP", 9);
+	ans.append(STRING_WITH_LEN("TIMESTAMP"));
 	break;
       case FIELD_TYPE_DATETIME:
-	ans.append("DATETIME", 8);
+	ans.append(STRING_WITH_LEN("DATETIME"));
 	break;
       case FIELD_TYPE_DATE:
       case FIELD_TYPE_NEWDATE:
-	ans.append("DATE", 4);
+	ans.append(STRING_WITH_LEN("DATE"));
 	break;
       case FIELD_TYPE_SET:
-	ans.append("SET", 3);
+	ans.append(STRING_WITH_LEN("SET"));
 	break;
       case FIELD_TYPE_YEAR:
-	ans.append("YEAR", 4);
+	ans.append(STRING_WITH_LEN("YEAR"));
 	break;
       case FIELD_TYPE_TIME:
-	ans.append("TIME", 4);
+	ans.append(STRING_WITH_LEN("TIME"));
 	break;
       case FIELD_TYPE_DECIMAL:
-	ans.append("DECIMAL", 7);
+	ans.append(STRING_WITH_LEN("DECIMAL"));
 	// if item is FIELD_ITEM, it _must_be_ Field_num in this case
 	if (((Field_num*) ((Item_field*) (*f)->item)->field)->zerofill)
-	  ans.append(" ZEROFILL");
+	  ans.append(STRING_WITH_LEN(" ZEROFILL"));
 	break;
       default:
 	(*f)->get_opt_type(&ans, rows);
@@ -785,7 +785,7 @@
       }
     }
     if (!(*f)->nulls)
-      ans.append(" NOT NULL");
+      ans.append(STRING_WITH_LEN(" NOT NULL"));
     func_items[9]->set(ans.ptr(), ans.length(), ans.charset());
     if (result->send_data(result_fields))
       return -1;
@@ -829,18 +829,18 @@
       sprintf(buff, "BIGINT(%d)", num_info.integers);
     answer->append(buff, (uint) strlen(buff));
     if (ev_num_info.llval >= 0 && ev_num_info.min_dval >= 0)
-      answer->append(" UNSIGNED");
+      answer->append(STRING_WITH_LEN(" UNSIGNED"));
     if (num_info.zerofill)
-      answer->append(" ZEROFILL");
+      answer->append(STRING_WITH_LEN(" ZEROFILL"));
   }
   else if (max_length < 256)
   {
     if (must_be_blob)
     {
       if (item->collation.collation == &my_charset_bin)
-	answer->append("TINYBLOB", 8);
+	answer->append(STRING_WITH_LEN("TINYBLOB"));
       else
-	answer->append("TINYTEXT", 8);
+	answer->append(STRING_WITH_LEN("TINYTEXT"));
     }
     else if ((max_length * (total_rows - nulls)) < (sum + total_rows))
     {
@@ -856,23 +856,23 @@
   else if (max_length < (1L << 16))
   {
     if (item->collation.collation == &my_charset_bin)
-      answer->append("BLOB", 4);
+      answer->append(STRING_WITH_LEN("BLOB"));
     else
-      answer->append("TEXT", 4);
+      answer->append(STRING_WITH_LEN("TEXT"));
   }
   else if (max_length < (1L << 24))
   {
     if (item->collation.collation == &my_charset_bin)
-      answer->append("MEDIUMBLOB", 10);
+      answer->append(STRING_WITH_LEN("MEDIUMBLOB"));
     else
-      answer->append("MEDIUMTEXT", 10);
+      answer->append(STRING_WITH_LEN("MEDIUMTEXT"));
   }
   else
   {
     if (item->collation.collation == &my_charset_bin)
-      answer->append("LONGBLOB", 8);
+      answer->append(STRING_WITH_LEN("LONGBLOB"));
     else
-      answer->append("LONGTEXT", 8);
+      answer->append(STRING_WITH_LEN("LONGTEXT"));
   }
 } // field_str::get_opt_type
 
@@ -902,14 +902,14 @@
       sprintf(buff, "BIGINT(%d)", len);
     answer->append(buff, (uint) strlen(buff));
     if (min_arg >= 0)
-      answer->append(" UNSIGNED");
+      answer->append(STRING_WITH_LEN(" UNSIGNED"));
   }
   else if (item->decimals == NOT_FIXED_DEC)
   {
     if (min_arg >= -FLT_MAX && max_arg <= FLT_MAX)
-      answer->append("FLOAT", 5);      
+      answer->append(STRING_WITH_LEN("FLOAT"));
     else
-      answer->append("DOUBLE", 6);
+      answer->append(STRING_WITH_LEN("DOUBLE"));
   }
   else
   {
@@ -926,7 +926,7 @@
       // a single number shouldn't be zerofill
       (max_length - (item->decimals + 1)) != 1 &&
       ((Field_num*) ((Item_field*) item)->field)->zerofill)
-    answer->append(" ZEROFILL");
+    answer->append(STRING_WITH_LEN(" ZEROFILL"));
 } // field_real::get_opt_type
 
 
@@ -950,14 +950,14 @@
     sprintf(buff, "BIGINT(%d)", (int) max_length);
   answer->append(buff, (uint) strlen(buff));
   if (min_arg >= 0)
-    answer->append(" UNSIGNED");
+    answer->append(STRING_WITH_LEN(" UNSIGNED"));
 
   // if item is FIELD_ITEM, it _must_be_ Field_num in this class
   if ((item->type() == Item::FIELD_ITEM) &&
       // a single number shouldn't be zerofill
       max_length != 1 &&
       ((Field_num*) ((Item_field*) item)->field)->zerofill)
-    answer->append(" ZEROFILL");
+    answer->append(STRING_WITH_LEN(" ZEROFILL"));
 } // field_longlong::get_opt_type
 
 
@@ -982,7 +982,7 @@
       // a single number shouldn't be zerofill
       max_length != 1 &&
       ((Field_num*) ((Item_field*) item)->field)->zerofill)
-    answer->append(" ZEROFILL");
+    answer->append(STRING_WITH_LEN(" ZEROFILL"));
 } //field_ulonglong::get_opt_type
 
 

--- 1.173/sql/sql_lex.cc	2005-11-02 06:05:06 +02:00
+++ 1.174/sql/sql_lex.cc	2005-11-15 15:34:36 +02:00
@@ -1526,9 +1526,9 @@
   {
     if (sl != first_select())
     {
-      str->append(" union ", 7);
+      str->append(STRING_WITH_LEN(" union "));
       if (union_all)
-	str->append("all ", 4);
+	str->append(STRING_WITH_LEN("all "));
       else if (union_distinct == sl)
         union_all= TRUE;
     }
@@ -1542,7 +1542,7 @@
   {
     if (fake_select_lex->order_list.elements)
     {
-      str->append(" order by ", 10);
+      str->append(STRING_WITH_LEN(" order by "));
       fake_select_lex->print_order(str,
 				   (ORDER *) fake_select_lex->
 				   order_list.first);
@@ -1565,7 +1565,7 @@
     else
       (*order->item)->print(str);
     if (!order->asc)
-      str->append(" desc", 5);
+      str->append(STRING_WITH_LEN(" desc"));
     if (order->next)
       str->append(',');
   }
@@ -1588,7 +1588,7 @@
 
   if (explicit_limit)
   {
-    str->append(" limit ", 7);
+    str->append(STRING_WITH_LEN(" limit "));
     if (offset_limit)
     {
       offset_limit->print(str);

--- 1.88/sql/sql_load.cc	2005-10-27 20:04:33 +03:00
+++ 1.89/sql/sql_load.cc	2005-11-15 15:34:36 +02:00
@@ -680,7 +680,8 @@
       length=(uint) (read_info.row_end-pos);
 
       if (!read_info.enclosed &&
-	  (enclosed_length && length == 4 && !memcmp(pos,"NULL",4)) ||
+	  (enclosed_length && length == 4 &&
+           !memcmp(pos, STRING_WITH_LEN("NULL"))) ||
 	  (length == 1 && read_info.found_null))
       {
         if (item->type() == Item::FIELD_ITEM)

--- 1.511/sql/sql_parse.cc	2005-11-10 21:32:38 +02:00
+++ 1.512/sql/sql_parse.cc	2005-11-15 15:34:37 +02:00
@@ -4578,7 +4578,7 @@
         buff.append(command[thd->lex->create_view_mode].str,
                     command[thd->lex->create_view_mode].length);
         view_store_options(thd, first_table, &buff);
-        buff.append("VIEW ", 5);
+        buff.append(STRING_WITH_LEN("VIEW "));
         /* Test if user supplied a db (ie: we did not use thd->db) */
         if (first_table->db != thd->db && first_table->db[0])
         {
@@ -4588,7 +4588,7 @@
         }
         append_identifier(thd, &buff, first_table->table_name,
                           first_table->table_name_length);
-        buff.append(" AS ", 4);
+        buff.append(STRING_WITH_LEN(" AS "));
         buff.append(first_table->source.str, first_table->source.length);
 
         Query_log_event qinfo(thd, buff.ptr(), buff.length(), 0, FALSE);

--- 1.374/sql/sql_select.cc	2005-11-03 21:35:16 +02:00
+++ 1.375/sql/sql_select.cc	2005-11-15 15:34:37 +02:00
@@ -13672,7 +13672,7 @@
     {
       SELECT_LEX *sl= join->unit->first_select();
       uint len= 6, lastop= 0;
-      memcpy(table_name_buffer, "<union", 6);
+      memcpy(table_name_buffer, STRING_WITH_LEN("<union"));
       for (; sl && len + lastop + 5 < NAME_LEN; sl= sl->next_select())
       {
         len+= lastop;
@@ -13681,7 +13681,7 @@
       }
       if (sl || len + lastop >= NAME_LEN)
       {
-        memcpy(table_name_buffer + len, "...>", 5);
+        memcpy(table_name_buffer + len, STRING_WITH_LEN("...>") + 1);
         len+= 4;
       }
       else
@@ -13860,7 +13860,7 @@
             quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT ||
             quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE)
         {
-          extra.append("; Using ");
+          extra.append(STRING_WITH_LEN("; Using "));
           tab->select->quick->add_info_string(&extra);
         }
 	if (tab->select)
@@ -13868,7 +13868,8 @@
 	  if (tab->use_quick == 2)
 	  {
             char buf[MAX_KEY/8+1];
-            extra.append("; Range checked for each record (index map: 0x");
+            extra.append(STRING_WITH_LEN("; Range checked for each "
+                                         "record (index map: 0x"));
             extra.append(tab->keys.print(buf));
             extra.append(')');
 	  }
@@ -13878,38 +13879,39 @@
 
             if (thd->variables.engine_condition_pushdown && pushed_cond)
             {
-              extra.append("; Using where with pushed condition");
+              extra.append(STRING_WITH_LEN("; Using where with pushed "
+                                           "condition"));
               if (thd->lex->describe & DESCRIBE_EXTENDED)
               {
-                extra.append(": ");
+                extra.append(STRING_WITH_LEN(": "));
                 ((COND *)pushed_cond)->print(&extra);
               }
             }
             else
-              extra.append("; Using where");
+              extra.append(STRING_WITH_LEN("; Using where"));
           }
 	}
 	if (key_read)
         {
           if (quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
-            extra.append("; Using index for group-by");
+            extra.append(STRING_WITH_LEN("; Using index for group-by"));
           else
-            extra.append("; Using index");
+            extra.append(STRING_WITH_LEN("; Using index"));
         }
 	if (table->reginfo.not_exists_optimize)
-	  extra.append("; Not exists");
+	  extra.append(STRING_WITH_LEN("; Not exists"));
 	if (need_tmp_table)
 	{
 	  need_tmp_table=0;
-	  extra.append("; Using temporary");
+	  extra.append(STRING_WITH_LEN("; Using temporary"));
 	}
 	if (need_order)
 	{
 	  need_order=0;
-	  extra.append("; Using filesort");
+	  extra.append(STRING_WITH_LEN("; Using filesort"));
 	}
 	if (distinct & test_all_bits(used_tables,thd->used_tables))
-	  extra.append("; Distinct");
+	  extra.append(STRING_WITH_LEN("; Distinct"));
         
         /* Skip initial "; "*/
         const char *str= extra.ptr();
@@ -14026,15 +14028,18 @@
   {
     TABLE_LIST *curr= *tbl;
     if (curr->outer_join)
-      str->append(" left join ", 11); // MySQL converts right to left joins
+    {
+      /* MySQL converts right to left joins */
+      str->append(STRING_WITH_LEN(" left join "));
+    }
     else if (curr->straight)
-      str->append(" straight_join ", 15);
+      str->append(STRING_WITH_LEN(" straight_join "));
     else
-      str->append(" join ", 6);
+      str->append(STRING_WITH_LEN(" join "));
     curr->print(thd, str);
     if (curr->on_expr)
     {
-      str->append(" on(", 4);
+      str->append(STRING_WITH_LEN(" on("));
       curr->on_expr->print(str);
       str->append(')');
     }
@@ -14119,28 +14124,28 @@
   if (!thd)
     thd= current_thd;
 
-  str->append("select ", 7);
+  str->append(STRING_WITH_LEN("select "));
 
   /* First add options */
   if (options & SELECT_STRAIGHT_JOIN)
-    str->append("straight_join ", 14);
+    str->append(STRING_WITH_LEN("straight_join "));
   if ((thd->lex->lock_option == TL_READ_HIGH_PRIORITY) &&
       (this == &thd->lex->select_lex))
-    str->append("high_priority ", 14);
+    str->append(STRING_WITH_LEN("high_priority "));
   if (options & SELECT_DISTINCT)
-    str->append("distinct ", 9);
+    str->append(STRING_WITH_LEN("distinct "));
   if (options & SELECT_SMALL_RESULT)
-    str->append("sql_small_result ", 17);
+    str->append(STRING_WITH_LEN("sql_small_result "));
   if (options & SELECT_BIG_RESULT)
-    str->append("sql_big_result ", 15);
+    str->append(STRING_WITH_LEN("sql_big_result "));
   if (options & OPTION_BUFFER_RESULT)
-    str->append("sql_buffer_result ", 18);
+    str->append(STRING_WITH_LEN("sql_buffer_result "));
   if (options & OPTION_FOUND_ROWS)
-    str->append("sql_calc_found_rows ", 20);
+    str->append(STRING_WITH_LEN("sql_calc_found_rows "));
   if (!thd->lex->safe_to_cache_query)
-    str->append("sql_no_cache ", 13);
+    str->append(STRING_WITH_LEN("sql_no_cache "));
   if (options & OPTION_TO_QUERY_CACHE)
-    str->append("sql_cache ", 10);
+    str->append(STRING_WITH_LEN("sql_cache "));
 
   //Item List
   bool first= 1;
@@ -14161,7 +14166,7 @@
   */
   if (table_list.elements)
   {
-    str->append(" from ", 6);
+    str->append(STRING_WITH_LEN(" from "));
     /* go through join tree */
     print_join(thd, str, &top_join_list);
   }
@@ -14172,22 +14177,22 @@
     cur_where= join->conds;
   if (cur_where)
   {
-    str->append(" where ", 7);
+    str->append(STRING_WITH_LEN(" where "));
     cur_where->print(str);
   }
 
   // group by & olap
   if (group_list.elements)
   {
-    str->append(" group by ", 10);
+    str->append(STRING_WITH_LEN(" group by "));
     print_order(str, (ORDER *) group_list.first);
     switch (olap)
     {
       case CUBE_TYPE:
-	str->append(" with cube", 10);
+	str->append(STRING_WITH_LEN(" with cube"));
 	break;
       case ROLLUP_TYPE:
-	str->append(" with rollup", 12);
+	str->append(STRING_WITH_LEN(" with rollup"));
 	break;
       default:
 	;  //satisfy compiler
@@ -14201,13 +14206,13 @@
 
   if (cur_having)
   {
-    str->append(" having ", 8);
+    str->append(STRING_WITH_LEN(" having "));
     cur_having->print(str);
   }
 
   if (order_list.elements)
   {
-    str->append(" order by ", 10);
+    str->append(STRING_WITH_LEN(" order by "));
     print_order(str, (ORDER *) order_list.first);
   }
 

--- 1.295/sql/sql_show.cc	2005-11-11 02:25:17 +02:00
+++ 1.296/sql/sql_show.cc	2005-11-15 15:34:37 +02:00
@@ -490,22 +490,22 @@
   protocol->prepare_for_resend();
   protocol->store(dbname, strlen(dbname), system_charset_info);
   buffer.length(0);
-  buffer.append("CREATE DATABASE ", 16);
+  buffer.append(STRING_WITH_LEN("CREATE DATABASE "));
   if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS)
-    buffer.append("/*!32312 IF NOT EXISTS*/ ", 25);
+    buffer.append(STRING_WITH_LEN("/*!32312 IF NOT EXISTS*/ "));
   append_identifier(thd, &buffer, dbname, strlen(dbname));
 
   if (create.default_table_charset)
   {
-    buffer.append(" /*!40100", 9);
-    buffer.append(" DEFAULT CHARACTER SET ", 23);
+    buffer.append(STRING_WITH_LEN(" /*!40100"));
+    buffer.append(STRING_WITH_LEN(" DEFAULT CHARACTER SET "));
     buffer.append(create.default_table_charset->csname);
     if (!(create.default_table_charset->state & MY_CS_PRIMARY))
     {
-      buffer.append(" COLLATE ", 9);
+      buffer.append(STRING_WITH_LEN(" COLLATE "));
       buffer.append(create.default_table_charset->name);
     }
-    buffer.append(" */", 3);
+    buffer.append(STRING_WITH_LEN(" */"));
   }
   protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
 
@@ -716,7 +716,7 @@
     uint length= dirname_length(filename);
     packet->append(' ');
     packet->append(dir_type);
-    packet->append(" DIRECTORY='", 12);
+    packet->append(STRING_WITH_LEN(" DIRECTORY='"));
 #ifdef __WIN__
     /* Convert \ to / to be able to create table on unix */
     char *winfilename= (char*) thd->memdup(filename, length);
@@ -765,16 +765,16 @@
   restore_record(table, s->default_values); // Get empty record
 
   if (share->tmp_table)
-    packet->append("CREATE TEMPORARY TABLE ", 23);
+    packet->append(STRING_WITH_LEN("CREATE TEMPORARY TABLE "));
   else
-    packet->append("CREATE TABLE ", 13);
+    packet->append(STRING_WITH_LEN("CREATE TABLE "));
   if (table_list->schema_table)
     alias= table_list->schema_table->table_name;
   else
     alias= (lower_case_table_names == 2 ? table->alias :
             share->table_name);
   append_identifier(thd, packet, alias, strlen(alias));
-  packet->append(" (\n", 3);
+  packet->append(STRING_WITH_LEN(" (\n"));
 
   for (ptr=table->field ; (field= *ptr); ptr++)
   {
@@ -783,9 +783,9 @@
     uint flags = field->flags;
 
     if (ptr != table->field)
-      packet->append(",\n", 2);
+      packet->append(STRING_WITH_LEN(",\n"));
 
-    packet->append("  ", 2);
+    packet->append(STRING_WITH_LEN("  "));
     append_identifier(thd,packet,field->field_name, strlen(field->field_name));
     packet->append(' ');
     // check for surprises from the previous call to Field::sql_type()
@@ -802,7 +802,7 @@
     {
       if (field->charset() != share->table_charset)
       {
-	packet->append(" character set ", 15);
+	packet->append(STRING_WITH_LEN(" character set "));
 	packet->append(field->charset()->csname);
       }
       /* 
@@ -811,20 +811,20 @@
       */
       if (!(field->charset()->state & MY_CS_PRIMARY))
       {
-	packet->append(" collate ", 9);
+	packet->append(STRING_WITH_LEN(" collate "));
 	packet->append(field->charset()->name);
       }
     }
 
     if (flags & NOT_NULL_FLAG)
-      packet->append(" NOT NULL", 9);
+      packet->append(STRING_WITH_LEN(" NOT NULL"));
     else if (field->type() == FIELD_TYPE_TIMESTAMP)
     {
       /*
         TIMESTAMP field require explicit NULL flag, because unlike
         all other fields they are treated as NOT NULL by default.
       */
-      packet->append(" NULL", 5);
+      packet->append(STRING_WITH_LEN(" NULL"));
     }
 
     /* 
@@ -842,9 +842,9 @@
 
     if (has_default)
     {
-      packet->append(" default ", 9);
+      packet->append(STRING_WITH_LEN(" default "));
       if (has_now_default)
-        packet->append("CURRENT_TIMESTAMP",17);
+        packet->append(STRING_WITH_LEN("CURRENT_TIMESTAMP"));
       else if (!field->is_null())
       {                                             // Not null by default
         type.set(tmp, sizeof(tmp), field->charset());
@@ -859,10 +859,10 @@
           append_unescaped(packet, def_val.ptr(), def_val.length());
 	}
         else
-	  packet->append("''",2);
+	  packet->append(STRING_WITH_LEN("''"));
       }
       else if (field->maybe_null())
-        packet->append("NULL", 4);                    // Null as default
+        packet->append(STRING_WITH_LEN("NULL"));    // Null as default
       else
         packet->append(tmp);
     }
@@ -870,15 +870,15 @@
     if (!(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS) &&
         table->timestamp_field == field && 
         field->unireg_check != Field::TIMESTAMP_DN_FIELD)
-      packet->append(" on update CURRENT_TIMESTAMP",28);
+      packet->append(STRING_WITH_LEN(" on update CURRENT_TIMESTAMP"));
 
     if (field->unireg_check == Field::NEXT_NUMBER && 
         !(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS))
-      packet->append(" auto_increment", 15 );
+      packet->append(STRING_WITH_LEN(" auto_increment"));
 
     if (field->comment.length)
     {
-      packet->append(" COMMENT ",9);
+      packet->append(STRING_WITH_LEN(" COMMENT "));
       append_unescaped(packet, field->comment.str, field->comment.length);
     }
   }
@@ -893,20 +893,20 @@
   {
     KEY_PART_INFO *key_part= key_info->key_part;
     bool found_primary=0;
-    packet->append(",\n  ", 4);
+    packet->append(STRING_WITH_LEN(",\n  "));
 
     if (i == primary_key && !strcmp(key_info->name, primary_key_name))
     {
       found_primary=1;
-      packet->append("PRIMARY ", 8);
+      packet->append(STRING_WITH_LEN("PRIMARY "));
     }
     else if (key_info->flags & HA_NOSAME)
-      packet->append("UNIQUE ", 7);
+      packet->append(STRING_WITH_LEN("UNIQUE "));
     else if (key_info->flags & HA_FULLTEXT)
-      packet->append("FULLTEXT ", 9);
+      packet->append(STRING_WITH_LEN("FULLTEXT "));
     else if (key_info->flags & HA_SPATIAL)
-      packet->append("SPATIAL ", 8);
-    packet->append("KEY ", 4);
+      packet->append(STRING_WITH_LEN("SPATIAL "));
+    packet->append(STRING_WITH_LEN("KEY "));
 
     if (!found_primary)
      append_identifier(thd, packet, key_info->name, strlen(key_info->name));
@@ -915,19 +915,19 @@
 	!limited_mysql_mode && !foreign_db_mode)
     {
       if (key_info->algorithm == HA_KEY_ALG_BTREE)
-        packet->append(" USING BTREE", 12);
+        packet->append(STRING_WITH_LEN(" USING BTREE"));
 
       if (key_info->algorithm == HA_KEY_ALG_HASH)
-        packet->append(" USING HASH", 11);
+        packet->append(STRING_WITH_LEN(" USING HASH"));
 
       // +BAR: send USING only in non-default case: non-spatial rtree
       if ((key_info->algorithm == HA_KEY_ALG_RTREE) &&
 	  !(key_info->flags & HA_SPATIAL))
-        packet->append(" USING RTREE", 12);
+        packet->append(STRING_WITH_LEN(" USING RTREE"));
 
       // No need to send USING FULLTEXT, it is sent as FULLTEXT KEY
     }
-    packet->append(" (", 2);
+    packet->append(STRING_WITH_LEN(" ("));
 
     for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
     {
@@ -964,71 +964,71 @@
     file->free_foreign_key_create_info(for_str);
   }
 
-  packet->append("\n)", 2);
+  packet->append(STRING_WITH_LEN("\n)"));
   if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) &&
!foreign_db_mode)
   {
     if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
-      packet->append(" TYPE=", 6);
+      packet->append(STRING_WITH_LEN(" TYPE="));
     else
-      packet->append(" ENGINE=", 8);
+      packet->append(STRING_WITH_LEN(" ENGINE="));
     packet->append(file->table_type());
     
     if (share->table_charset &&
 	!(thd->variables.sql_mode & MODE_MYSQL323) &&
 	!(thd->variables.sql_mode & MODE_MYSQL40))
     {
-      packet->append(" DEFAULT CHARSET=", 17);
+      packet->append(STRING_WITH_LEN(" DEFAULT CHARSET="));
       packet->append(share->table_charset->csname);
       if (!(share->table_charset->state & MY_CS_PRIMARY))
       {
-	packet->append(" COLLATE=", 9);
+	packet->append(STRING_WITH_LEN(" COLLATE="));
 	packet->append(table->s->table_charset->name);
       }
     }
 
     if (share->min_rows)
     {
-      packet->append(" MIN_ROWS=", 10);
+      packet->append(STRING_WITH_LEN(" MIN_ROWS="));
       end= longlong10_to_str(share->min_rows, buff, 10);
       packet->append(buff, (uint) (end- buff));
     }
 
     if (share->max_rows && !table_list->schema_table)
     {
-      packet->append(" MAX_ROWS=", 10);
+      packet->append(STRING_WITH_LEN(" MAX_ROWS="));
       end= longlong10_to_str(share->max_rows, buff, 10);
       packet->append(buff, (uint) (end - buff));
     }
 
     if (share->avg_row_length)
     {
-      packet->append(" AVG_ROW_LENGTH=", 16);
+      packet->append(STRING_WITH_LEN(" AVG_ROW_LENGTH="));
       end= longlong10_to_str(share->avg_row_length, buff,10);
       packet->append(buff, (uint) (end - buff));
     }
 
     if (share->db_create_options & HA_OPTION_PACK_KEYS)
-      packet->append(" PACK_KEYS=1", 12);
+      packet->append(STRING_WITH_LEN(" PACK_KEYS=1"));
     if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
-      packet->append(" PACK_KEYS=0", 12);
+      packet->append(STRING_WITH_LEN(" PACK_KEYS=0"));
     if (share->db_create_options & HA_OPTION_CHECKSUM)
-      packet->append(" CHECKSUM=1", 11);
+      packet->append(STRING_WITH_LEN(" CHECKSUM=1"));
     if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
-      packet->append(" DELAY_KEY_WRITE=1",18);
+      packet->append(STRING_WITH_LEN(" DELAY_KEY_WRITE=1"));
     if (share->row_type != ROW_TYPE_DEFAULT)
     {
-      packet->append(" ROW_FORMAT=",12);
+      packet->append(STRING_WITH_LEN(" ROW_FORMAT="));
       packet->append(ha_row_type[(uint) share->row_type]);
     }
     table->file->append_create_info(packet);
     if (share->comment && share->comment[0])
     {
-      packet->append(" COMMENT=", 9);
+      packet->append(STRING_WITH_LEN(" COMMENT="));
       append_unescaped(packet, share->comment, strlen(share->comment));
     }
     if (share->connect_string.length)
     {
-      packet->append(" CONNECTION=", 12);
+      packet->append(STRING_WITH_LEN(" CONNECTION="));
       append_unescaped(packet, share->connect_string.str,
share->connect_string.length);
     }
     if (file->raid_type)
@@ -1049,25 +1049,25 @@
 void
 view_store_options(THD *thd, TABLE_LIST *table, String *buff)
 {
-  buff->append("ALGORITHM=", 10);
+  buff->append(STRING_WITH_LEN("ALGORITHM="));
   switch ((int8)table->algorithm) {
   case VIEW_ALGORITHM_UNDEFINED:
-    buff->append("UNDEFINED ", 10);
+    buff->append(STRING_WITH_LEN("UNDEFINED "));
     break;
   case VIEW_ALGORITHM_TMPTABLE:
-    buff->append("TEMPTABLE ", 10);
+    buff->append(STRING_WITH_LEN("TEMPTABLE "));
     break;
   case VIEW_ALGORITHM_MERGE:
-    buff->append("MERGE ", 6);
+    buff->append(STRING_WITH_LEN("MERGE "));
     break;
   default:
     DBUG_ASSERT(0); // never should happen
   }
   append_definer(thd, buff, &table->definer.user, &table->definer.host);
   if (table->view_suid)
-    buff->append("SQL SECURITY DEFINER ", 21);
+    buff->append(STRING_WITH_LEN("SQL SECURITY DEFINER "));
   else
-    buff->append("SQL SECURITY INVOKER ", 21);
+    buff->append(STRING_WITH_LEN("SQL SECURITY INVOKER "));
 }
 
 
@@ -1125,19 +1125,19 @@
     }
   }
 
-  buff->append("CREATE ", 7);
+  buff->append(STRING_WITH_LEN("CREATE "));
   if (!foreign_db_mode)
   {
     view_store_options(thd, table, buff);
   }
-  buff->append("VIEW ", 5);
+  buff->append(STRING_WITH_LEN("VIEW "));
   if (!table->compact_view_format)
   {
     append_identifier(thd, buff, table->view_db.str, table->view_db.length);
     buff->append('.');
   }
   append_identifier(thd, buff, table->view_name.str, table->view_name.length);
-  buff->append(" AS ", 4);
+  buff->append(STRING_WITH_LEN(" AS "));
 
   /*
     We can't just use table->query, because our SQL_MODE may trigger
@@ -1148,9 +1148,9 @@
   if (table->with_check != VIEW_CHECK_NONE)
   {
     if (table->with_check == VIEW_CHECK_LOCAL)
-      buff->append(" WITH LOCAL CHECK OPTION", 24);
+      buff->append(STRING_WITH_LEN(" WITH LOCAL CHECK OPTION"));
     else
-      buff->append(" WITH CASCADED CHECK OPTION", 27);
+      buff->append(STRING_WITH_LEN(" WITH CASCADED CHECK OPTION"));
   }
   return 0;
 }
@@ -2134,20 +2134,24 @@
             {
               if (with_i_schema)
               {
-                table->field[3]->store("SYSTEM VIEW", 11, system_charset_info);
+                table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"),
+                                       system_charset_info);
               }
               else
               {
                 my_snprintf(end, len, "/%s%s", file_name, reg_ext);
                 switch (mysql_frm_type(thd, path, &not_used)) {
                 case FRMTYPE_ERROR:
-                  table->field[3]->store("ERROR", 5, system_charset_info);
+                  table->field[3]->store(STRING_WITH_LEN("ERROR"),
+                                         system_charset_info);
                   break;
                 case FRMTYPE_TABLE:
-                  table->field[3]->store("BASE TABLE", 10, system_charset_info);
+                  table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
+                                         system_charset_info);
                   break;
                 case FRMTYPE_VIEW:
-                  table->field[3]->store("VIEW", 4, system_charset_info);
+                  table->field[3]->store(STRING_WITH_LEN("VIEW"),
+                                         system_charset_info);
                   break;
                 default:
                   DBUG_ASSERT(0);
@@ -2300,8 +2304,8 @@
   }
   else if (tables->view)
   {
-    table->field[3]->store("VIEW", 4, cs);
-    table->field[20]->store("VIEW", 4, cs);
+    table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
+    table->field[20]->store(STRING_WITH_LEN("VIEW"), cs);
   }
   else
   {
@@ -2312,11 +2316,11 @@
     file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO |
                HA_STATUS_NO_LOCK);
     if (share->tmp_table == SYSTEM_TMP_TABLE)
-      table->field[3]->store("SYSTEM VIEW", 11, cs);
+      table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
     else if (share->tmp_table)
-      table->field[3]->store("LOCAL TEMPORARY", 15, cs);
+      table->field[3]->store(STRING_WITH_LEN("LOCAL TEMPORARY"), cs);
     else
-      table->field[3]->store("BASE TABLE", 10, cs);
+      table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
 
     for (int i= 4; i < 20; i++)
     {
@@ -2552,7 +2556,7 @@
     if (show_table->timestamp_field == field &&
         field->unireg_check != Field::TIMESTAMP_UN_FIELD)
     {
-      table->field[5]->store("CURRENT_TIMESTAMP", 17, cs);
+      table->field[5]->store(STRING_WITH_LEN("CURRENT_TIMESTAMP"), cs);
       table->field[5]->set_notnull();
     }
     else if (field->unireg_check != Field::NEXT_NUMBER &&
@@ -2814,8 +2818,8 @@
         get_field(thd->mem_root, proc_table->field[10], &tmp_string);
         table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs);
       }
-      table->field[6]->store("SQL", 3, cs);
-      table->field[10]->store("SQL", 3, cs);
+      table->field[6]->store(STRING_WITH_LEN("SQL"), cs);
+      table->field[10]->store(STRING_WITH_LEN("SQL"), cs);
       get_field(thd->mem_root, proc_table->field[6], &tmp_string);
       table->field[11]->store(tmp_string.ptr(), tmp_string.length(), cs);
       table->field[12]->store(sp_data_access_name[enum_idx].str, 
@@ -2970,7 +2974,7 @@
         pos= show_table->file->index_type(i);
         table->field[13]->store(pos, strlen(pos), cs);
         if (!show_table->s->keys_in_use.is_set(i))
-          table->field[14]->store("disabled", 8, cs);
+          table->field[14]->store(STRING_WITH_LEN("disabled"), cs);
         else
           table->field[14]->store("", 0, cs);
         table->field[14]->set_notnull();
@@ -3083,13 +3087,15 @@
       if (i == primary_key && !strcmp(key_info->name, primary_key_name))
       {
         if (store_constraints(thd, table, base_name, file_name, key_info->name,
-                              strlen(key_info->name), "PRIMARY KEY", 11))
+                              strlen(key_info->name),
+                              STRING_WITH_LEN("PRIMARY KEY")))
           DBUG_RETURN(1);
       }
       else if (key_info->flags & HA_NOSAME)
       {
         if (store_constraints(thd, table, base_name, file_name, key_info->name,
-                              strlen(key_info->name), "UNIQUE", 6))
+                              strlen(key_info->name),
+                              STRING_WITH_LEN("UNIQUE")))
           DBUG_RETURN(1);
       }
     }
@@ -3130,11 +3136,11 @@
   table->field[5]->store(db, strlen(db), cs);
   table->field[6]->store(tname, strlen(tname), cs);
   table->field[9]->store(trigger_stmt->str, trigger_stmt->length, cs);
-  table->field[10]->store("ROW", 3, cs);
+  table->field[10]->store(STRING_WITH_LEN("ROW"), cs);
   table->field[11]->store(trg_action_time_type_names[timing].str,
                           trg_action_time_type_names[timing].length, cs);
-  table->field[14]->store("OLD", 3, cs);
-  table->field[15]->store("NEW", 3, cs);
+  table->field[14]->store(STRING_WITH_LEN("OLD"), cs);
+  table->field[15]->store(STRING_WITH_LEN("NEW"), cs);
 
   sql_mode_str=
     sys_var_thd_sql_mode::symbolic_mode_representation(thd,
@@ -3525,9 +3531,9 @@
     buffer.append(field_info->old_name);
     if (lex->wild && lex->wild->ptr())
     {
-      buffer.append(" (");
+      buffer.append(STRING_WITH_LEN(" ("));
       buffer.append(lex->wild->ptr());
-      buffer.append(")");
+      buffer.append(')');
     }
     field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
   }
@@ -3548,9 +3554,9 @@
   buffer.append(lex->select_lex.db);
   if (lex->wild && lex->wild->ptr())
   {
-    buffer.append(" (");
+    buffer.append(STRING_WITH_LEN(" ("));
     buffer.append(lex->wild->ptr());
-    buffer.append(")");
+    buffer.append(')');
   }
   Item_field *field= new Item_field(context,
                                     NullS, NullS, field_info->field_name);

--- 1.89/sql/sql_string.cc	2005-06-06 21:21:27 +03:00
+++ 1.90/sql/sql_string.cc	2005-11-15 15:34:38 +02:00
@@ -38,6 +38,8 @@
 
 #include "sql_string.h"
 
+#define STRING_WITH_LEN(X)  ((char*) X), (sizeof(X)-1)
+
 /*****************************************************************************
 ** String functions
 *****************************************************************************/
@@ -848,22 +850,22 @@
     switch (c)
     {
     case '\\':
-      str->append("\\\\", 2);
+      str->append(STRING_WITH_LEN("\\\\"));
       break;
     case '\0':
-      str->append("\\0", 2);
+      str->append(STRING_WITH_LEN("\\0"));
       break;
     case '\'':
-      str->append("\\'", 2);
+      str->append(STRING_WITH_LEN("\\'"));
       break;
     case '\n':
-      str->append("\\n", 2);
+      str->append(STRING_WITH_LEN("\\n"));
       break;
     case '\r':
-      str->append("\\r", 2);
+      str->append(STRING_WITH_LEN("\\r"));
       break;
     case 26: //Ctrl-Z
-      str->append("\\z", 2);
+      str->append(STRING_WITH_LEN("\\z"));
       break;
     default:
       str->append(c);

--- 1.284/sql/sql_table.cc	2005-11-09 09:12:54 +02:00
+++ 1.285/sql/sql_table.cc	2005-11-15 15:34:38 +02:00
@@ -700,7 +700,8 @@
 						    MY_CS_BINSORT,MYF(0))))
     {
       char tmp[64];
-      strmake(strmake(tmp, save_cs->csname, sizeof(tmp)-4), "_bin", 4);
+      strmake(strmake(tmp, save_cs->csname, sizeof(tmp)-4),
+              STRING_WITH_LEN("_bin"));
       my_error(ER_UNKNOWN_COLLATION, MYF(0), tmp);
       DBUG_RETURN(-1);
     }
@@ -1946,7 +1947,7 @@
   protocol->prepare_for_resend();
   protocol->store(table->alias, system_charset_info);
   protocol->store((char*) operator_name, system_charset_info);
-  protocol->store("error", 5, system_charset_info);
+  protocol->store(STRING_WITH_LEN("error"), system_charset_info);
   protocol->store(errmsg, system_charset_info);
   thd->clear_error();
   if (protocol->write())
@@ -2237,7 +2238,7 @@
       protocol->prepare_for_resend();
       protocol->store(table_name, system_charset_info);
       protocol->store(operator_name, system_charset_info);
-      protocol->store("error",5, system_charset_info);
+      protocol->store(STRING_WITH_LEN("error"), system_charset_info);
       if (!(err_msg=thd->net.last_error))
 	err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
       /* if it was a view will check md5 sum */
@@ -2274,7 +2275,7 @@
       protocol->prepare_for_resend();
       protocol->store(table_name, system_charset_info);
       protocol->store(operator_name, system_charset_info);
-      protocol->store("error", 5, system_charset_info);
+      protocol->store(STRING_WITH_LEN("error"), system_charset_info);
       length= my_snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY),
                           table_name);
       protocol->store(buff, length, system_charset_info);
@@ -2309,8 +2310,9 @@
       protocol->prepare_for_resend();
       protocol->store(table_name, system_charset_info);
       protocol->store(operator_name, system_charset_info);
-      protocol->store("warning", 7, system_charset_info);
-      protocol->store("Table is marked as crashed", 26, system_charset_info);
+      protocol->store(STRING_WITH_LEN("warning"), system_charset_info);
+      protocol->store(STRING_WITH_LEN("Table is marked as crashed"),
+                      system_charset_info);
       if (protocol->write())
         goto err;
     }
@@ -2334,7 +2336,7 @@
 	char buf[ERRMSGSIZE+20];
 	uint length=my_snprintf(buf, ERRMSGSIZE,
 				ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
-	protocol->store("note", 4, system_charset_info);
+	protocol->store(STRING_WITH_LEN("note"), system_charset_info);
 	protocol->store(buf, length, system_charset_info);
       }
       break;
@@ -2344,41 +2346,45 @@
         char buf[ERRMSGSIZE+20];
         uint length= my_snprintf(buf, ERRMSGSIZE,
                                  ER(ER_BAD_TABLE_ERROR), table_name);
-        protocol->store("note", 4, system_charset_info);
+        protocol->store(STRING_WITH_LEN("note"), system_charset_info);
         protocol->store(buf, length, system_charset_info);
       }
       break;
 
     case HA_ADMIN_OK:
-      protocol->store("status", 6, system_charset_info);
-      protocol->store("OK",2, system_charset_info);
+      protocol->store(STRING_WITH_LEN("status"), system_charset_info);
+      protocol->store(STRING_WITH_LEN("OK"), system_charset_info);
       break;
 
     case HA_ADMIN_FAILED:
-      protocol->store("status", 6, system_charset_info);
-      protocol->store("Operation failed",16, system_charset_info);
+      protocol->store(STRING_WITH_LEN("status"), system_charset_info);
+      protocol->store(STRING_WITH_LEN("Operation failed"),
+                      system_charset_info);
       break;
 
     case HA_ADMIN_REJECT:
-      protocol->store("status", 6, system_charset_info);
-      protocol->store("Operation need committed state",30, system_charset_info);
+      protocol->store(STRING_WITH_LEN("status"), system_charset_info);
+      protocol->store(STRING_WITH_LEN("Operation need committed state"),
+                      system_charset_info);
       open_for_modify= FALSE;
       break;
 
     case HA_ADMIN_ALREADY_DONE:
-      protocol->store("status", 6, system_charset_info);
-      protocol->store("Table is already up to date", 27, system_charset_info);
+      protocol->store(STRING_WITH_LEN("status"), system_charset_info);
+      protocol->store(STRING_WITH_LEN("Table is already up to date"),
+                      system_charset_info);
       break;
 
     case HA_ADMIN_CORRUPT:
-      protocol->store("error", 5, system_charset_info);
-      protocol->store("Corrupt", 7, system_charset_info);
+      protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+      protocol->store(STRING_WITH_LEN("Corrupt"), system_charset_info);
       fatal_error=1;
       break;
 
     case HA_ADMIN_INVALID:
-      protocol->store("error", 5, system_charset_info);
-      protocol->store("Invalid argument",16, system_charset_info);
+      protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+      protocol->store(STRING_WITH_LEN("Invalid argument"),
+                      system_charset_info);
       break;
 
     case HA_ADMIN_TRY_ALTER:
@@ -2414,7 +2420,7 @@
           else
           {
             /* Hijack the row already in-progress. */
-            protocol->store("error", 5, system_charset_info);
+            protocol->store(STRING_WITH_LEN("error"), system_charset_info);
             protocol->store(err_msg, system_charset_info);
             (void)protocol->write();
             /* Start off another row for HA_ADMIN_FAILED */
@@ -2431,7 +2437,7 @@
     }
     case HA_ADMIN_WRONG_CHECKSUM:
     {
-      protocol->store("note", 4, system_charset_info);
+      protocol->store(STRING_WITH_LEN("note"), system_charset_info);
       protocol->store(ER(ER_VIEW_CHECKSUM), strlen(ER(ER_VIEW_CHECKSUM)),
                       system_charset_info);
       break;
@@ -2443,7 +2449,7 @@
         uint length=my_snprintf(buf, ERRMSGSIZE,
                                 "Unknown - internal error %d during operation",
                                 result_code);
-        protocol->store("error", 5, system_charset_info);
+        protocol->store(STRING_WITH_LEN("error"), system_charset_info);
         protocol->store(buf, length, system_charset_info);
         fatal_error=1;
         break;

--- 1.208/sql/table.cc	2005-11-03 16:28:11 +02:00
+++ 1.209/sql/table.cc	2005-11-15 15:34:38 +02:00
@@ -110,7 +110,7 @@
   if (my_read(file,(byte*) head,64,MYF(MY_NABP)))
     goto err;
 
-  if (memcmp(head, "TYPE=", 5) == 0)
+  if (memcmp(head, STRING_WITH_LEN("TYPE=")) == 0)
   {
     // new .frm
     my_close(file,MYF(MY_WME));

--- 1.56/sql/share/errmsg.txt	2005-11-10 21:32:38 +02:00
+++ 1.57/sql/share/errmsg.txt	2005-11-15 15:34:36 +02:00
@@ -5423,3 +5423,5 @@
 	eng "Variable '%-.64s' must be quoted with `...`, or renamed"
 ER_TRG_NO_DEFINER
   eng "No definer attribute for trigger '%-.64s'.'%-.64s'. The trigger will be activated
under the authorization of the invoker, which may have insufficient privileges. Please
recreate the trigger."
+ER_OLD_FILE_FORMAT
+  eng "'%-.64s' has an old format, you should re-create the '%s' object(s)"

--- 1.24/sql/spatial.cc	2005-11-01 18:40:49 +02:00
+++ 1.25/sql/spatial.cc	2005-11-15 15:34:36 +02:00
@@ -1791,7 +1791,7 @@
     geom->set_data_ptr(data, (uint) (m_data_end - data));
     if (geom->as_wkt(txt, &data))
       return 1;
-    if (txt->append(",", 1, 512))
+    if (txt->append(STRING_WITH_LEN(","), 512))
       return 1;
   }
   txt->length(txt->length() - 1);

--- 1.120/sql/item_subselect.cc	2005-10-13 10:52:52 +03:00
+++ 1.121/sql/item_subselect.cc	2005-11-15 15:34:35 +02:00
@@ -533,7 +533,7 @@
 
 void Item_exists_subselect::print(String *str)
 {
-  str->append("exists", 6);
+  str->append(STRING_WITH_LEN("exists"));
   Item_subselect::print(str);
 }
 
@@ -1339,11 +1339,11 @@
 void Item_in_subselect::print(String *str)
 {
   if (transformed)
-    str->append("<exists>", 8);
+    str->append(STRING_WITH_LEN("<exists>"));
   else
   {
     left_expr->print(str);
-    str->append(" in ", 4);
+    str->append(STRING_WITH_LEN(" in "));
   }
   Item_subselect::print(str);
 }
@@ -1362,7 +1362,7 @@
 void Item_allany_subselect::print(String *str)
 {
   if (transformed)
-    str->append("<exists>", 8);
+    str->append(STRING_WITH_LEN("<exists>"));
   else
   {
     left_expr->print(str);
@@ -1794,16 +1794,16 @@
 
 void subselect_uniquesubquery_engine::print(String *str)
 {
-  str->append("<primary_index_lookup>(", 23);
+  str->append(STRING_WITH_LEN("<primary_index_lookup>("));
   tab->ref.items[0]->print(str);
-  str->append(" in ", 4);
+  str->append(STRING_WITH_LEN(" in "));
   str->append(tab->table->s->table_name);
   KEY *key_info= tab->table->key_info+ tab->ref.key;
-  str->append(" on ", 4);
+  str->append(STRING_WITH_LEN(" on "));
   str->append(key_info->name);
   if (cond)
   {
-    str->append(" where ", 7);
+    str->append(STRING_WITH_LEN(" where "));
     cond->print(str);
   }
   str->append(')');
@@ -1812,18 +1812,18 @@
 
 void subselect_indexsubquery_engine::print(String *str)
 {
-  str->append("<index_lookup>(", 15);
+  str->append(STRING_WITH_LEN("<index_lookup>("));
   tab->ref.items[0]->print(str);
-  str->append(" in ", 4);
+  str->append(STRING_WITH_LEN(" in "));
   str->append(tab->table->s->table_name);
   KEY *key_info= tab->table->key_info+ tab->ref.key;
-  str->append(" on ", 4);
+  str->append(STRING_WITH_LEN(" on "));
   str->append(key_info->name);
   if (check_null)
-    str->append(" checking NULL", 14);
+    str->append(STRING_WITH_LEN(" checking NULL"));
     if (cond)
   {
-    str->append(" where ", 7);
+    str->append(STRING_WITH_LEN(" where "));
     cond->print(str);
   }
   str->append(')');

--- 1.16/sql/parse_file.cc	2005-10-12 00:58:18 +03:00
+++ 1.17/sql/parse_file.cc	2005-11-15 15:34:36 +02:00
@@ -50,23 +50,23 @@
     */
     switch(*ptr) {
     case '\\': // escape character
-      if (my_b_append(file, (const byte *)"\\\\", 2))
+      if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\\\")))
 	return TRUE;
       break;
     case '\n': // parameter value delimiter
-      if (my_b_append(file, (const byte *)"\\n", 2))
+      if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\n")))
 	return TRUE;
       break;
     case '\0': // problem for some string processing utilities
-      if (my_b_append(file, (const byte *)"\\0", 2))
+      if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\0")))
 	return TRUE;
       break;
     case 26: // problem for windows utilities (Ctrl-Z)
-      if (my_b_append(file, (const byte *)"\\z", 2))
+      if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\z")))
 	return TRUE;
       break;
     case '\'': // list of string delimiter
-      if (my_b_append(file, (const byte *)"\\\'", 2))
+      if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\\'")))
 	return TRUE;
       break;
     default:
@@ -155,10 +155,10 @@
     while ((str= it++))
     {
       // We need ' ' after string to detect list continuation
-      if ((!first && my_b_append(file, (const byte *)" ", 1)) ||
-	  my_b_append(file, (const byte *)"\'", 1) ||
+      if ((!first && my_b_append(file, (const byte *)STRING_WITH_LEN(" "))) ||
+	  my_b_append(file, (const byte *)STRING_WITH_LEN("\'")) ||
           write_escaped_string(file, str) ||
-	  my_b_append(file, (const byte *)"\'", 1))
+	  my_b_append(file, (const byte *)STRING_WITH_LEN("\'")))
       {
 	DBUG_RETURN(TRUE);
       }
@@ -176,7 +176,7 @@
     {
       num.set(*val, &my_charset_bin);
       // We need ' ' after string to detect list continuation
-      if ((!first && my_b_append(file, (const byte *)" ", 1)) ||
+      if ((!first && my_b_append(file, (const byte *)STRING_WITH_LEN(" "))) ||
           my_b_append(file, (const byte *)num.ptr(), num.length()))
       {
         DBUG_RETURN(TRUE);
@@ -242,9 +242,9 @@
     goto err_w_file;
 
   // write header (file signature)
-  if (my_b_append(&file, (const byte *)"TYPE=", 5) ||
+  if (my_b_append(&file, (const byte *)STRING_WITH_LEN("TYPE=")) ||
       my_b_append(&file, (const byte *)type->str, type->length) ||
-      my_b_append(&file, (const byte *)"\n", 1))
+      my_b_append(&file, (const byte *)STRING_WITH_LEN("\n")))
     goto err_w_file;
 
   // write parameters to temporary file
@@ -252,9 +252,9 @@
   {
     if (my_b_append(&file, (const byte *)param->name.str,
                     param->name.length) ||
-	my_b_append(&file, (const byte *)"=", 1) ||
+	my_b_append(&file, (const byte *)STRING_WITH_LEN("=")) ||
 	write_parameter(&file, base, param, &old_version) ||
-	my_b_append(&file, (const byte *)"\n", 1))
+	my_b_append(&file, (const byte *)STRING_WITH_LEN("\n")))
       goto err_w_cache;
   }
 
@@ -664,6 +664,61 @@
 
 
 /*
+  FILE_OPTIONS_ULLLIST parser
+
+  SYNOPSIS
+    get_file_options_ulllist()
+    ptr                  [in/out] pointer to parameter
+    end                  [in] end of the configuration
+    line                 [in] pointer to the line begining
+    base                 [in] base address for parameter writing (structure
+                              like TABLE)
+    parameter            [in] description
+    mem_root             [in] MEM_ROOT for parameters allocation
+*/
+
+bool get_file_options_ulllist(char *&ptr, char *end, char *line,
+                              gptr base, File_option *parameter,
+                              MEM_ROOT *mem_root)
+{
+  List<ulonglong> *nlist= (List<ulonglong>*)(base + parameter->offset);
+  ulonglong *num;
+  nlist->empty();
+  // list parsing
+  while (ptr < end)
+  {
+    int not_used;
+    char *num_end= end;
+    if (!(num= (ulonglong*)alloc_root(mem_root, sizeof(ulonglong))) ||
+        nlist->push_back(num, mem_root))
+      goto nlist_err;
+    *num= my_strtoll10(ptr, &num_end, &not_used);
+    ptr= num_end;
+    switch (*ptr) {
+    case '\n':
+      goto end_of_nlist;
+    case ' ':
+      // we cant go over buffer bounds, because we have \0 at the end
+      ptr++;
+      break;
+    default:
+      goto nlist_err_w_message;
+    }
+  }
+
+end_of_nlist:
+  if (*(ptr++) != '\n')
+    goto nlist_err;
+  return FALSE;
+
+nlist_err_w_message:
+  my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), parameter->name.str, line);
+nlist_err:
+  return TRUE;
+}
+
+
+/*
   parse parameters
  
   SYNOPSIS
@@ -673,6 +728,8 @@
     mem_root            MEM_ROOT for parameters allocation
     parameters          parameters description
     required            number of required parameters in above list
+    hook                hook called for unknown keys
+    hook_data           some data specific for the hook
 
   RETURN
     FALSE - OK
@@ -681,7 +738,8 @@
 
 my_bool
 File_parser::parse(gptr base, MEM_ROOT *mem_root,
-                   struct File_option *parameters, uint required)
+                   struct File_option *parameters, uint required,
+                   unknown_key_hook hook, gptr hook_data)
 {
   uint first_param= 0, found= 0;
   register char *ptr= start;
@@ -689,7 +747,6 @@
   LEX_STRING *str;
   List<LEX_STRING> *list;
   ulonglong *num;
-  List<ulonglong> *nlist;
   DBUG_ENTER("File_parser::parse");
 
   while (ptr < end && found < required)
@@ -829,58 +886,63 @@
 	  DBUG_RETURN(TRUE);
 	}
         case FILE_OPTIONS_ULLLIST:
-        {
-          nlist= (List<ulonglong>*)(base + parameter->offset);
-          nlist->empty();
-          // list parsing
-          while (ptr < end)
-          {
-            int not_used;
-            char *num_end= end;
-            if (!(num= (ulonglong*)alloc_root(mem_root, sizeof(ulonglong))) ||
-                nlist->push_back(num, mem_root))
-              goto nlist_err;
-            *num= my_strtoll10(ptr, &num_end, &not_used);
-            ptr= num_end;
-            switch (*ptr) {
-            case '\n':
-              goto end_of_nlist;
-            case ' ':
-              // we cant go over buffer bounds, because we have \0 at the end
-              ptr++;
-              break;
-            default:
-              goto nlist_err_w_message;
-            }
-          }
-
-end_of_nlist:
-          if (*(ptr++) != '\n')
-            goto nlist_err;
+          if (get_file_options_ulllist(ptr, end, line, base,
+                                       parameter, mem_root))
+            DBUG_RETURN(TRUE);
           break;
-
-nlist_err_w_message:
-          my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
-                   parameter->name.str, line);
-nlist_err:
-          DBUG_RETURN(TRUE);
-
-        }
 	default:
 	  DBUG_ASSERT(0); // never should happened
 	}
       }
       else
       {
-	// skip unknown parameter
-	if (!(ptr= strchr(ptr, '\n')))
-	{
-	  my_error(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER, MYF(0), line);
-	  DBUG_RETURN(TRUE);
-	}
-	ptr++;
+        ptr= line;
+        if ((*hook)(ptr, base, mem_root, end, hook_data))
+        {
+          DBUG_RETURN(TRUE);
+        }
+        // skip unknown parameter
+        if (!(ptr= strchr(ptr, '\n')))
+        {
+          my_error(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER, MYF(0), line);
+          DBUG_RETURN(TRUE);
+        }
+        ptr++;
       }
     }
   }
+  DBUG_RETURN(FALSE);
+}
+
+
+/*
+  Dummy unknown key hook
+
+  SYNOPSIS
+    file_parser_dummy_hook()
+    unknown_key          [in/out] reference on the line with unknown
+                                  parameter and the parsing point
+    base                 [in] base address for parameter writing (structure like
+                         TABLE)
+    mem_root             [in] MEM_ROOT for parameters allocation
+    end                  [in] the end of the configuration
+    hook_data            [in] data for the hook
+
+  NOTE
+    such hook used to catch unsupported any more keys and process them for
+    bakward compatibility, but it will not slow down processing of modern
+    format files. This hook do nothing except debug output.
+
+  RETURN
+    FALSE OK
+    TRUE  Error
+
+*/
+
+bool file_parser_dummy_hook(char *&unknown_key, gptr base, MEM_ROOT *mem_root,
+                            char *end, gptr hook_data)
+{
+  DBUG_ENTER("file_parser_dummy_hook");
+  DBUG_PRINT("info", ("unknown key:%60s", unknown_key));
   DBUG_RETURN(FALSE);
 }

--- 1.9/sql/parse_file.h	2005-09-18 22:43:21 +03:00
+++ 1.10/sql/parse_file.h	2005-11-15 15:34:36 +02:00
@@ -40,6 +40,17 @@
   file_opt_type type;		/* Option type */
 };
 
+typedef bool (*unknown_key_hook)(char *&unknown_key, gptr base,
+                                 MEM_ROOT *mem_root, char *end,
+                                 gptr hook_data);
+
+bool file_parser_dummy_hook (char *&unknown_key, gptr base,
+                             MEM_ROOT *mem_root, char *end,
+                             gptr hook_data);
+bool get_file_options_ulllist(char *&ptr, char *end, char *line,
+                              gptr base, File_option *parameter,
+                              MEM_ROOT *mem_root);
+
 class File_parser;
 File_parser *sql_parse_prepare(const LEX_STRING *file_name,
 			       MEM_ROOT *mem_root, bool bad_format_errors);
@@ -64,7 +75,8 @@
   my_bool ok() { return content_ok; }
   LEX_STRING *type() { return &file_type; }
   my_bool parse(gptr base, MEM_ROOT *mem_root,
-		struct File_option *parameters, uint required);
+		struct File_option *parameters, uint required,
+                unknown_key_hook hook, gptr hook_data);
 
   friend File_parser *sql_parse_prepare(const LEX_STRING *file_name,
 					MEM_ROOT *mem_root,

--- 1.76/sql/sql_view.cc	2005-11-10 21:24:54 +02:00
+++ 1.77/sql/sql_view.cc	2005-11-15 15:34:38 +02:00
@@ -623,7 +623,8 @@
         TODO: special cascade/restrict procedure for alter?
       */
       if (parser->parse((gptr)view, thd->mem_root,
-                        view_parameters + revision_number_position, 1))
+                        view_parameters + revision_number_position, 1,
+                        &file_parser_dummy_hook, 0))
       {
         DBUG_RETURN(thd->net.report_error? -1 : 0);
       }
@@ -792,7 +793,7 @@
     be used here
   */
   if (parser->parse((gptr)table, thd->mem_root, view_parameters,
-                    required_view_parameters))
+                    required_view_parameters, &file_parser_dummy_hook, 0))
     goto err;
 
   /*
@@ -1502,7 +1503,8 @@
 
     /* get view definition and source */
     if (parser->parse((gptr)&view_def, thd->mem_root, view_parameters,
-                      array_elements(view_parameters)-1))
+                      array_elements(view_parameters)-1,
+                      &file_parser_dummy_hook, 0))
       goto err;
 
     /* rename view and it's backups */

--- 1.26/sql/tztime.cc	2005-09-14 01:41:38 +03:00
+++ 1.27/sql/tztime.cc	2005-11-15 15:34:38 +02:00
@@ -1558,7 +1558,7 @@
     sql_print_error("Fatal error: OOM while initializing time zones");
     goto end_with_cleanup;
   }
-  tmp_tzname->name.set("SYSTEM", 6, &my_charset_latin1);
+  tmp_tzname->name.set(STRING_WITH_LEN("SYSTEM"), &my_charset_latin1);
   tmp_tzname->tz= my_tz_SYSTEM;
   if (my_hash_insert(&tz_names, (const byte *)tmp_tzname))
   {

--- 1.32/sql/sql_trigger.cc	2005-11-10 21:32:38 +02:00
+++ 1.33/sql/sql_trigger.cc	2005-11-15 15:34:38 +02:00
@@ -20,7 +20,8 @@
 #include "sql_trigger.h"
 #include "parse_file.h"
 
-static const LEX_STRING triggers_file_type= {(char *)"TRIGGERS", 8};
+static const LEX_STRING triggers_file_type=
+  {(char *)STRING_WITH_LEN("TRIGGERS")};
 
 const char * const triggers_file_ext= ".TRG";
 
@@ -38,11 +39,7 @@
     FILE_OPTIONS_STRLIST
   },
   {
-    /*
-      FIXME: Length specified for "sql_modes" key is erroneous, problem caused
-      by this are reported as BUG#14090 and should be fixed ASAP.
-    */
-    { (char *) "sql_modes", 13 },
+    { (char *) STRING_WITH_LEN("sql_modes") },
     offsetof(class Table_triggers_list, definition_modes_list),
     FILE_OPTIONS_ULLLIST
   },
@@ -73,7 +70,8 @@
   LEX_STRING trigger_table;
 };
 
-static const LEX_STRING trigname_file_type= {(char *)"TRIGGERNAME", 11};
+static const LEX_STRING trigname_file_type=
+  {(char *)STRING_WITH_LEN("TRIGGERNAME")};
 
 const char * const trigname_file_ext= ".TRN";
 
@@ -84,7 +82,7 @@
       FIXME: Length specified for "trigger_table" key is erroneous, problem
       caused by this are reported as BUG#14090 and should be fixed ASAP.
     */
-    { (char *) "trigger_table", 15 },
+    { (char *) STRING_WITH_LEN("trigger_table")},
     offsetof(struct st_trigname, trigger_table),
    FILE_OPTIONS_ESTRING
   },
@@ -108,6 +106,10 @@
 
 static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig);
 
+bool handle_old_incorrect_sql_modes(char *&unknown_key, gptr base,
+                                    MEM_ROOT *mem_root,
+                                    char *end, gptr hook_data);
+
 
 /*
   Create or drop trigger for table.
@@ -237,7 +239,7 @@
       {
         log_query.set((char *) 0, 0, system_charset_info); /* reset log_query */
 
-        log_query.append("CREATE ");
+        log_query.append(STRING_WITH_LEN("CREATE "));
         append_definer(thd, &log_query, &definer_user, &definer_host);
         log_query.append(thd->lex->trigger_definition_begin);
       }
@@ -705,7 +707,9 @@
       triggers->definers_list.empty();
 
       if (parser->parse((gptr)triggers, &table->mem_root,
-                        triggers_file_parameters, TRG_NUM_REQUIRED_PARAMETERS))
+                        triggers_file_parameters,
+                        TRG_NUM_REQUIRED_PARAMETERS,
+                        &handle_old_incorrect_sql_modes, (gptr)path.str))
         DBUG_RETURN(1);
 
       List_iterator_fast<LEX_STRING> it(triggers->definitions_list);
@@ -1020,7 +1024,8 @@
   }
 
   if (parser->parse((gptr)&trigname, thd->mem_root,
-                    trigname_file_parameters, 1))
+                    trigname_file_parameters, 1,
+                    &file_parser_dummy_hook, 0))
     DBUG_RETURN(0);
 
   /* We need to reset statement table list to be PS/SP friendly. */
@@ -1171,4 +1176,64 @@
   }
 
   return res;
+}
+
+
+/*
+  Trigger BUG#14090 compatibility hook
+
+  SYNOPSIS
+    handle_old_incorrect_sql_modes()
+    unknown_key          [in/out] reference on the line with unknown
+                                  parameter and the parsing point
+    base                 [in] base address for parameter writing (structure
+                              like TABLE)
+    mem_root             [in] MEM_ROOT for parameters allocation
+    end                  [in] the end of the configuration
+    hook_data            [in] data for the hook: path to the file
+
+  NOTE: this hook process back compatibility for incorrectly written
+  sql_modes parameter (see BUG#14090).
+
+  RETURN
+    FALSE OK
+    TRUE  Error
+*/
+
+bool handle_old_incorrect_sql_modes(char *&unknown_key, gptr base,
+                                    MEM_ROOT *mem_root,
+                                    char *end, gptr hook_data)
+{
+  DBUG_ENTER("handle_old_incorrect_sql_modes");
+  DBUG_PRINT("info", ("unknown key:%60s", unknown_key));
+  if (unknown_key + 14 < end &&
+      unknown_key[13] == '=' &&
+      !memcmp(unknown_key, STRING_WITH_LEN("sql_modes")))
+  {
+    DBUG_PRINT("info", ("sql_modes affected by BUG#14090 detected"));
+    push_warning_printf(current_thd,
+                        MYSQL_ERROR::WARN_LEVEL_NOTE,
+                        ER_OLD_FILE_FORMAT,
+                        ER(ER_OLD_FILE_FORMAT),
+                        (char *)hook_data, "TRIGGER");
+    File_option sql_modes_parameters=
+      {
+        { (char *) STRING_WITH_LEN("sql_modes") },
+        offsetof(class Table_triggers_list, definition_modes_list),
+        FILE_OPTIONS_ULLLIST
+      };
+    char *ptr= unknown_key + 14;
+    if (get_file_options_ulllist(ptr, end, unknown_key, base,
+                                 &sql_modes_parameters, mem_root))
+    {
+      DBUG_RETURN(TRUE);
+    }
+    /*
+      Set parsing pointer to the last symbol of string (\n)
+      1) to avoid problem with \0 in the junk after sql_modes
+      2) to speed up skipping this line by parser.
+    */
+    unknown_key= ptr-1;
+  }
+  DBUG_RETURN(FALSE);
 }

--- 1.52/sql/ha_federated.cc	2005-10-19 01:54:16 +03:00
+++ 1.53/sql/ha_federated.cc	2005-11-15 15:34:35 +02:00
@@ -2627,9 +2627,9 @@
   DBUG_PRINT("enter", ("error: %d", error));
   if (error == HA_FEDERATED_ERROR_WITH_REMOTE_SYSTEM)
   {
-    buf->append("Error on remote system: ");
+    buf->append(STRING_WITH_LEN("Error on remote system: "));
     buf->qs_append(remote_error_number);
-    buf->append(": ");
+    buf->append(STRING_WITH_LEN(": "));
     buf->append(remote_error_buf, FEDERATED_QUERY_BUFFER_SIZE);
 
     remote_error_number= 0;

--- 1.98/sql/sp.cc	2005-11-10 21:32:38 +02:00
+++ 1.99/sql/sp.cc	2005-11-15 15:34:36 +02:00
@@ -1585,30 +1585,30 @@
 		 chistics->comment.length))
     return FALSE;
 
-  buf->append("CREATE ", 7);
+  buf->append(STRING_WITH_LEN("CREATE "));
   if (type == TYPE_ENUM_FUNCTION)
-    buf->append("FUNCTION ", 9);
+    buf->append(STRING_WITH_LEN("FUNCTION "));
   else
-    buf->append("PROCEDURE ", 10);
+    buf->append(STRING_WITH_LEN("PROCEDURE "));
   append_identifier(thd, buf, name->m_name.str, name->m_name.length);
   buf->append('(');
   buf->append(params, paramslen);
   buf->append(')');
   if (type == TYPE_ENUM_FUNCTION)
   {
-    buf->append(" RETURNS ", 9);
+    buf->append(STRING_WITH_LEN(" RETURNS "));
     buf->append(returns, returnslen);
   }
   buf->append('\n');
   switch (chistics->daccess) {
   case SP_NO_SQL:
-    buf->append("    NO SQL\n");
+    buf->append(STRING_WITH_LEN("    NO SQL\n"));
     break;
   case SP_READS_SQL_DATA:
-    buf->append("    READS SQL DATA\n");
+    buf->append(STRING_WITH_LEN("    READS SQL DATA\n"));
     break;
   case SP_MODIFIES_SQL_DATA:
-    buf->append("    MODIFIES SQL DATA\n");
+    buf->append(STRING_WITH_LEN("    MODIFIES SQL DATA\n"));
     break;
   case SP_DEFAULT_ACCESS:
   case SP_CONTAINS_SQL:
@@ -1616,12 +1616,12 @@
     break;
   }
   if (chistics->detistic)
-    buf->append("    DETERMINISTIC\n", 18);
+    buf->append(STRING_WITH_LEN("    DETERMINISTIC\n"));
   if (chistics->suid == SP_IS_NOT_SUID)
-    buf->append("    SQL SECURITY INVOKER\n", 25);
+    buf->append(STRING_WITH_LEN("    SQL SECURITY INVOKER\n"));
   if (chistics->comment.length)
   {
-    buf->append("    COMMENT ");
+    buf->append(STRING_WITH_LEN("    COMMENT "));
     append_unescaped(buf, chistics->comment.str, chistics->comment.length);
     buf->append('\n');
   }

--- 1.194/sql/sp_head.cc	2005-11-10 21:24:52 +02:00
+++ 1.195/sql/sp_head.cc	2005-11-15 15:34:36 +02:00
@@ -816,9 +816,9 @@
       prev_pos= (*splocal)->pos_in_query + (*splocal)->m_name.length;
       
       /* append the spvar substitute */
-      res|= qbuf.append(" NAME_CONST('");
+      res|= qbuf.append(STRING_WITH_LEN(" NAME_CONST('"));
       res|= qbuf.append((*splocal)->m_name.str, (*splocal)->m_name.length);
-      res|= qbuf.append("',");
+      res|= qbuf.append(STRING_WITH_LEN("',"));
       val= (*splocal)->this_item();
       DBUG_PRINT("info", ("print %p", val));
       val->print(&qbuf);
@@ -1173,7 +1173,7 @@
     char buf[256];
     String bufstr(buf, sizeof(buf), &my_charset_bin);
     bufstr.length(0);
-    bufstr.append("DO ", 3);
+    bufstr.append(STRING_WITH_LEN("DO "));
     append_identifier(thd, &bufstr, m_name.str, m_name.length);
     bufstr.append('(');
     for (uint i=0; i < argcount; i++)
@@ -2014,7 +2014,7 @@
 sp_instr_stmt::print(String *str)
 {
   str->reserve(12);
-  str->append("stmt ");
+  str->append(STRING_WITH_LEN("stmt "));
   str->qs_append((uint)m_lex_keeper.sql_command());
 }
 
@@ -2055,7 +2055,7 @@
 sp_instr_set::print(String *str)
 {
   str->reserve(12);
-  str->append("set ");
+  str->append(STRING_WITH_LEN("set "));
   str->qs_append(m_offset);
   str->append(' ');
   m_value->print(str);
@@ -2090,9 +2090,9 @@
 void
 sp_instr_set_trigger_field::print(String *str)
 {
-  str->append("set ", 4);
+  str->append(STRING_WITH_LEN("set "));
   trigger_field->print(str);
-  str->append(":=", 2);
+  str->append(STRING_WITH_LEN(":="));
   value->print(str);
 }
 
@@ -2115,7 +2115,7 @@
 sp_instr_jump::print(String *str)
 {
   str->reserve(12);
-  str->append("jump ");
+  str->append(STRING_WITH_LEN("jump "));
   str->qs_append(m_dest);
 }
 
@@ -2197,7 +2197,7 @@
 sp_instr_jump_if::print(String *str)
 {
   str->reserve(12);
-  str->append("jump_if ");
+  str->append(STRING_WITH_LEN("jump_if "));
   str->qs_append(m_dest);
   str->append(' ');
   m_expr->print(str);
@@ -2258,7 +2258,7 @@
 sp_instr_jump_if_not::print(String *str)
 {
   str->reserve(16);
-  str->append("jump_if_not ");
+  str->append(STRING_WITH_LEN("jump_if_not "));
   str->qs_append(m_dest);
   str->append(' ');
   m_expr->print(str);
@@ -2316,7 +2316,7 @@
 sp_instr_freturn::print(String *str)
 {
   str->reserve(12);
-  str->append("freturn ");
+  str->append(STRING_WITH_LEN("freturn "));
   str->qs_append((uint)m_type);
   str->append(' ');
   m_value->print(str);
@@ -2344,13 +2344,13 @@
 sp_instr_hpush_jump::print(String *str)
 {
   str->reserve(32);
-  str->append("hpush_jump ");
+  str->append(STRING_WITH_LEN("hpush_jump "));
   str->qs_append(m_dest);
-  str->append(" t=");
+  str->append(STRING_WITH_LEN(" t="));
   str->qs_append(m_type);
-  str->append(" f=");
+  str->append(STRING_WITH_LEN(" f="));
   str->qs_append(m_frame);
-  str->append(" h=");
+  str->append(STRING_WITH_LEN(" h="));
   str->qs_append(m_ip+1);
 }
 
@@ -2387,7 +2387,7 @@
 sp_instr_hpop::print(String *str)
 {
   str->reserve(12);
-  str->append("hpop ");
+  str->append(STRING_WITH_LEN("hpop "));
   str->qs_append(m_count);
 }
 
@@ -2422,7 +2422,7 @@
 sp_instr_hreturn::print(String *str)
 {
   str->reserve(16);
-  str->append("hreturn ");
+  str->append(STRING_WITH_LEN("hreturn "));
   str->qs_append(m_frame);
   if (m_dest)
   {
@@ -2474,7 +2474,7 @@
 void
 sp_instr_cpush::print(String *str)
 {
-  str->append("cpush");
+  str->append(STRING_WITH_LEN("cpush"));
 }
 
 
@@ -2496,7 +2496,7 @@
 sp_instr_cpop::print(String *str)
 {
   str->reserve(12);
-  str->append("cpop ");
+  str->append(STRING_WITH_LEN("cpop "));
   str->qs_append(m_count);
 }
 
@@ -2571,7 +2571,7 @@
 sp_instr_copen::print(String *str)
 {
   str->reserve(12);
-  str->append("copen ");
+  str->append(STRING_WITH_LEN("copen "));
   str->qs_append(m_cursor);
 }
 
@@ -2600,7 +2600,7 @@
 sp_instr_cclose::print(String *str)
 {
   str->reserve(12);
-  str->append("cclose ");
+  str->append(STRING_WITH_LEN("cclose "));
   str->qs_append(m_cursor);
 }
 
@@ -2631,7 +2631,7 @@
   sp_pvar_t *pv;
 
   str->reserve(12);
-  str->append("cfetch ");
+  str->append(STRING_WITH_LEN("cfetch "));
   str->qs_append(m_cursor);
   while ((pv= li++))
   {
@@ -2661,7 +2661,7 @@
 sp_instr_error::print(String *str)
 {
   str->reserve(12);
-  str->append("error ");
+  str->append(STRING_WITH_LEN("error "));
   str->qs_append(m_errcode);
 }
 

--- 1.58/sql/repl_failsafe.cc	2005-10-19 00:43:13 +03:00
+++ 1.59/sql/repl_failsafe.cc	2005-11-15 15:34:36 +02:00
@@ -502,7 +502,7 @@
   int port_ind;
   DBUG_ENTER("update_slave_list");
 
-  if (mysql_real_query(mysql,"SHOW SLAVE HOSTS",16) ||
+  if (mysql_real_query(mysql, STRING_WITH_LEN("SHOW SLAVE HOSTS")) ||
       !(res = mysql_store_result(mysql)))
   {
     error= mysql_error(mysql);
@@ -795,7 +795,7 @@
     MYSQL_RES *db_res, **table_res, **table_res_end, **cur_table_res;
     uint num_dbs;
 
-    if (mysql_real_query(&mysql, "SHOW DATABASES", 14) ||
+    if (mysql_real_query(&mysql, STRING_WITH_LEN("SHOW DATABASES")) ||
 	!(db_res = mysql_store_result(&mysql)))
     {
       my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
@@ -821,8 +821,9 @@
       we wait to issue FLUSH TABLES WITH READ LOCK for as long as we
       can to minimize the lock time.
     */
-    if (mysql_real_query(&mysql, "FLUSH TABLES WITH READ LOCK", 27) ||
-	mysql_real_query(&mysql, "SHOW MASTER STATUS",18) ||
+    if (mysql_real_query(&mysql,
+                         STRING_WITH_LEN("FLUSH TABLES WITH READ LOCK")) ||
+	mysql_real_query(&mysql, STRING_WITH_LEN("SHOW MASTER STATUS")) ||
 	!(master_status_res = mysql_store_result(&mysql)))
     {
       my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
@@ -875,7 +876,7 @@
       }
 
       if (mysql_select_db(&mysql, db) ||
-	  mysql_real_query(&mysql, "SHOW TABLES", 11) ||
+	  mysql_real_query(&mysql, STRING_WITH_LEN("SHOW TABLES")) ||
 	  !(*cur_table_res = mysql_store_result(&mysql)))
       {
 	my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
@@ -933,7 +934,7 @@
       mysql_free_result(master_status_res);
     }
 
-    if (mysql_real_query(&mysql, "UNLOCK TABLES", 13))
+    if (mysql_real_query(&mysql, STRING_WITH_LEN("UNLOCK TABLES")))
     {
       my_error(error= ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql));
       goto err;

--- 1.163/sql/sql_prepare.cc	2005-11-03 15:21:19 +02:00
+++ 1.164/sql/sql_prepare.cc	2005-11-15 15:34:37 +02:00
@@ -1927,7 +1927,7 @@
         variable absent or equal to NULL, so we need to set variable to
         something reasonable to get a readable error message during parsing
       */
-      str.set("NULL", 4, &my_charset_latin1);
+      str.set(STRING_WITH_LEN("NULL"), &my_charset_latin1);
     }
 
     needs_conversion= String::needs_conversion(var_value->length(),
Thread
bk commit into 5.0 tree (bell:1.1967) BUG#14090sanja15 Nov