List:Commits« Previous MessageNext Message »
From:kent Date:July 22 2006 8:47pm
Subject:bk commit into 5.1 tree (kent:1.2262) BUG#1641
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kent. When kent does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-07-22 20:46:52+02:00, kent@stripped +1 -0
  charset.c:
    If the argument 'to' in escape_{string,quotes}_for_mysql() is set to NULL,
    just count the number of bytes needed in out buffer (bug#1641)

  mysys/charset.c@stripped, 2006-07-22 20:44:21+02:00, kent@stripped +39 -4
    If the argument 'to' in escape_{string,quotes}_for_mysql() is set to NULL,
    just count the number of bytes needed in out buffer (bug#1641)

# 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:	kent
# Host:	c-4b4072d5.010-2112-6f72651.cust.bredbandsbolaget.se
# Root:	/Users/kent/mysql/bk/bugs/mysql-5.1-bug1641

--- 1.147/mysys/charset.c	2006-07-22 20:47:16 +02:00
+++ 1.148/mysys/charset.c	2006-07-22 20:47:16 +02:00
@@ -577,7 +577,7 @@
   SYNOPSIS
     escape_string_for_mysql()
     charset_info        Charset of the strings
-    to                  Buffer for escaped string
+    to                  Buffer for escaped string, or NULL if just counting
     to_length           Length of destination buffer, or 0
     from                The string to escape
     length              The length of the string to escape
@@ -587,6 +587,9 @@
     characters, and turning others into specific escape sequences, such as
     turning newlines into \n and null bytes into \0.
 
+    If 'to' is set to NULL, this function only counts how much buffer
+    size is needed.
+
   NOTE
     To maintain compatibility with the old C API, to_length may be 0 to mean
     "big enough"
@@ -613,6 +616,13 @@
     int tmp_length;
     if (use_mb_flag && (tmp_length= my_ismbchar(charset_info, from, end)))
     {
+      if (to_start == NULL)
+      {
+        to+=   tmp_length;            /* We are only counting bytes */
+        from+= tmp_length - 1;        /* Adjust for 'from++' in for-loop */
+        continue;
+      }
+
       if (to + tmp_length > to_end)
       {
         overflow= TRUE;
@@ -661,6 +671,13 @@
       escape= 'Z';
       break;
     }
+
+    if (to_start == NULL)
+    {
+      to+= escape ? 2 : 1;
+      continue;
+    }
+
     if (escape)
     {
       if (to + 2 > to_end)
@@ -681,7 +698,8 @@
       *to++= *from;
     }
   }
-  *to= 0;
+  if (to_start != NULL)
+    *to= 0;
   return overflow ? (ulong)~0 : (ulong) (to - to_start);
 }
 
@@ -717,7 +735,7 @@
   SYNOPSIS
     escape_quotes_for_mysql()
     charset_info        Charset of the strings
-    to                  Buffer for escaped string
+    to                  Buffer for escaped string, or NULL if just counting
     to_length           Length of destination buffer, or 0
     from                The string to escape
     length              The length of the string to escape
@@ -727,6 +745,9 @@
     it contains. This is used when the NO_BACKSLASH_ESCAPES SQL_MODE is in
     effect on the server.
 
+    If 'to' is set to NULL, this function only counts how much buffer
+    size is needed.
+
   NOTE
     To be consistent with escape_string_for_mysql(), to_length may be 0 to
     mean "big enough"
@@ -752,6 +773,13 @@
     int tmp_length;
     if (use_mb_flag && (tmp_length= my_ismbchar(charset_info, from, end)))
     {
+      if (to_start == NULL)
+      {
+        to+=   tmp_length;            /* We are only counting bytes */
+        from+= tmp_length - 1;        /* Adjust for 'from++' in for-loop */
+        continue;
+      }
+
       if (to + tmp_length > to_end)
       {
         overflow= TRUE;
@@ -768,6 +796,12 @@
       character, because we are only escaping the ' character with itself.
      */
 #endif
+    if (to_start == NULL)
+    {
+      to+= escape ? 2 : 1;
+      continue;
+    }
+
     if (*from == '\'')
     {
       if (to + 2 > to_end)
@@ -788,6 +822,7 @@
       *to++= *from;
     }
   }
-  *to= 0;
+  if (to_start != NULL)
+    *to= 0;
   return overflow ? (ulong)~0 : (ulong) (to - to_start);
 }
Thread
bk commit into 5.1 tree (kent:1.2262) BUG#1641kent22 Jul