MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:November 4 2010 5:29pm
Subject:bzr commit into mysql-5.1-bugteam branch (alfranio.correia:3551) Bug#57873
View as plain text  
#At file:///home/acorreia/workspace.sun/repository.mysql.new/bzrwork/bug-57873/mysql-5.1-bugteam/ based on revid:georgi.kodinov@stripped

 3551 Alfranio Correia	2010-11-04
      BUG#57873 Backtick in savepoint name causes replication failure
      
      Savepoint name in the binary log is always enclosed with backticks;
      however, internal backticks in the name are not duplicated, so ids
      like `xx`yy` make the slave SQL to stop with a syntax error.
      
      To fix the problem, we duplicate internal backtics, e.g. `xx``yy`.
     @ sql/log.cc
        Call MYSQL_BIN_LOG::get_ansi_id().
     @ sql/log.h
        Added get_ansi_id() that doubles any backtick in "id" and stores
        the result string in "ansi_id".

    modified:
      sql/log.cc
      sql/log.h
=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-10-20 18:21:40 +0000
+++ b/sql/log.cc	2010-11-04 17:29:40 +0000
@@ -1713,7 +1713,7 @@ static int binlog_savepoint_set(handlert
   String log_query;
   if (log_query.append(STRING_WITH_LEN("SAVEPOINT ")) ||
       log_query.append("`") ||
-      log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
+      MYSQL_BIN_LOG::get_ansi_id(&log_query, &thd->lex->ident) ||
       log_query.append("`"))
     DBUG_RETURN(1);
   int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
@@ -1737,7 +1737,7 @@ static int binlog_savepoint_rollback(han
     String log_query;
     if (log_query.append(STRING_WITH_LEN("ROLLBACK TO ")) ||
         log_query.append("`") ||
-        log_query.append(thd->lex->ident.str, thd->lex->ident.length) ||
+        MYSQL_BIN_LOG::get_ansi_id(&log_query, &thd->lex->ident) ||
         log_query.append("`"))
       DBUG_RETURN(1);
     int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);

=== modified file 'sql/log.h'
--- a/sql/log.h	2010-08-02 19:48:56 +0000
+++ b/sql/log.h	2010-11-04 17:29:40 +0000
@@ -337,6 +337,37 @@ public:
     bytes_written=0;
     DBUG_VOID_RETURN;
   }
+  /**
+    Doubles any backtick in "id" and stores result string in 
+    "ansi_id".
+
+    @param[out] ansi_id Place where the string is stored
+    @param[in]  id      String that will have their backticks
+                        doubled
+
+    @return
+      @c true if there is any problem, otherwise @c false.
+  */
+  static bool get_ansi_id(String *ansi_id, LEX_STRING *id)
+  {
+    DBUG_ENTER("MYSQL_BIN_LOG::get_ansi_quote_id");
+  
+    char *stickpos= NULL;
+    char *ident= id->str;
+    int  size= id->length;
+  
+    for(; size && (stickpos= (char *) memchr(ident,'`', size)); )
+    { 
+      if (ansi_id->append(ident, int (stickpos - ident))
+          || ansi_id->append("``", 2))
+        DBUG_RETURN(TRUE);
+
+      size= size - (stickpos - ident) - 1;
+      ident= stickpos + 1;
+    }
+
+    DBUG_RETURN(FALSE);
+  }
   void set_max_size(ulong max_size_arg);
   void signal_update();
   void wait_for_update(THD* thd, bool master_or_slave);


Attachment: [text/bzr-bundle] bzr/alfranio.correia@oracle.com-20101104172940-3pm3gqwgvbt0qkr8.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (alfranio.correia:3551) Bug#57873Alfranio Correia4 Nov