List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:March 17 2006 4:40pm
Subject:bk commit into 5.0 tree (anozdrin:1.2074) BUG#15921
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of alik. When alik 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.2074 06/03/17 18:39:54 anozdrin@stripped +3 -0
  Fix for BUG#15921: DROP TRIGGER - can't be drop trigger created in older version
  
  The problem is that TRN-files created in "old" versions contain junk in trigger_table
  field, which is not acceptable in "new" versions.

  sql/sql_trigger.cc
    1.47 06/03/17 18:39:49 anozdrin@stripped +80 -7
    1. Polishing
    2. Removed declaration of global handle_old_incorrect_sql_modes()
       since it is not used anymore.
    3. Added a hook to support invalid "trigger_table" field in TRN-file
       from old versions.

  sql/parse_file.h
    1.12 06/03/17 18:39:49 anozdrin@stripped +3 -0
    Made parse_escaped_string() available globally.

  sql/parse_file.cc
    1.19 06/03/17 18:39:49 anozdrin@stripped +3 -3
    1. Made parse_escaped_string() available globally;
    2. Polishing: fixing the comments.

# 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:	anozdrin
# Host:	booka.home
# Root:	/mnt/hda4/home/alik/MySQL/devel/5.0-rt

--- 1.18/sql/parse_file.cc	2006-01-06 01:47:40 +03:00
+++ 1.19/sql/parse_file.cc	2006-03-17 18:39:49 +03:00
@@ -533,7 +533,7 @@
   read escaped string from ptr to eol in already allocated str
 
   SYNOPSIS
-    parse_escaped_string()
+    read_escaped_string()
     ptr		- pointer on string beginning
     eol		- pointer on character after end of string
     str		- target string
@@ -604,7 +604,7 @@
     #	- pointer on symbol after string
 */
 
-static char *
+char *
 parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str)
 {
   char *eol= strchr(ptr, '\n');
@@ -622,7 +622,7 @@
   parse '' delimited escaped string
 
   SYNOPSIS
-    parse_escaped_string()
+    parse_quoted_escaped_string()
     ptr		- pointer on string beginning
     end		- pointer on symbol after parsed string end (still owned
 		  by buffer and can be accessed

--- 1.11/sql/parse_file.h	2006-02-25 18:46:26 +03:00
+++ 1.12/sql/parse_file.h	2006-03-17 18:39:49 +03:00
@@ -72,6 +72,9 @@
                               gptr base, File_option *parameter,
                               MEM_ROOT *mem_root);
 
+char *
+parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str);
+
 class File_parser;
 File_parser *sql_parse_prepare(const LEX_STRING *file_name,
 			       MEM_ROOT *mem_root, bool bad_format_errors);

--- 1.46/sql/sql_trigger.cc	2006-03-07 14:24:18 +03:00
+++ 1.47/sql/sql_trigger.cc	2006-03-17 18:39:49 +03:00
@@ -86,7 +86,7 @@
   {
     {(char *) STRING_WITH_LEN("trigger_table")},
     offsetof(struct st_trigname, trigger_table),
-   FILE_OPTIONS_ESTRING
+    FILE_OPTIONS_ESTRING
   },
   { { 0, 0 }, 0, FILE_OPTIONS_STRING }
 };
@@ -108,10 +108,6 @@
 
 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);
-
 class Handle_old_incorrect_sql_modes_hook: public Unknown_key_hook
 {
 private:
@@ -124,6 +120,20 @@
                                       MEM_ROOT *mem_root, char *end);
 };
 
+class Handle_old_incorrect_trigger_table_hook: public Unknown_key_hook
+{
+public:
+  Handle_old_incorrect_trigger_table_hook(char *file_path,
+                                          LEX_STRING *trigger_table_arg)
+    :path(file_path), trigger_table_value(trigger_table_arg)
+  {};
+  virtual bool process_unknown_string(char *&unknown_key, gptr base,
+                                      MEM_ROOT *mem_root, char *end);
+private:
+  char *path;
+  LEX_STRING *trigger_table_value;
+};
+
 /*
   Create or drop trigger for table.
 
@@ -1129,6 +1139,9 @@
   LEX_STRING path;
   File_parser *parser;
   struct st_trigname trigname;
+  Handle_old_incorrect_trigger_table_hook trigger_table_hook(
+                                          path_buff, &trigname.trigger_table);
+  
   DBUG_ENTER("add_table_for_trigger");
 
   strxnmov(path_buff, FN_REFLEN, mysql_data_home, "/", trig->m_db.str, "/",
@@ -1154,7 +1167,7 @@
 
   if (parser->parse((gptr)&trigname, thd->mem_root,
                     trigname_file_parameters, 1,
-                    &file_parser_dummy_hook))
+                    &trigger_table_hook))
     DBUG_RETURN(0);
 
   /* We need to reset statement table list to be PS/SP friendly. */
@@ -1537,7 +1550,7 @@
                                                             MEM_ROOT *mem_root,
                                                             char *end)
 {
-  DBUG_ENTER("handle_old_incorrect_sql_modes");
+  DBUG_ENTER("Handle_old_incorrect_sql_modes_hook::process_unknown_string");
   DBUG_PRINT("info", ("unknown key:%60s", unknown_key));
 
   if (unknown_key + INVALID_SQL_MODES_LENGTH + 1 < end &&
@@ -1560,6 +1573,66 @@
     /*
       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);
+}
+
+/*
+  Trigger BUG#15921 compatibility hook
+
+  SYNOPSIS
+    Handle_old_incorrect_trigger_table_hook::process_unknown_string()
+    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
+
+  NOTE: this hook process back compatibility for incorrectly written
+  trigger_table parameter (see BUG#15921).
+
+  RETURN
+    FALSE OK
+    TRUE  Error
+*/
+
+#define INVALID_TRIGGER_TABLE_LENGTH 15
+
+bool
+Handle_old_incorrect_trigger_table_hook::process_unknown_string(char *&unknown_key,
+                                                                gptr base,
+                                                                MEM_ROOT *mem_root,
+                                                                char *end)
+{
+  DBUG_ENTER("Handle_old_incorrect_trigger_table_hook::process_unknown_string");
+  DBUG_PRINT("info", ("unknown key:%60s", unknown_key));
+
+  if (unknown_key + INVALID_TRIGGER_TABLE_LENGTH + 1 < end &&
+      unknown_key[INVALID_TRIGGER_TABLE_LENGTH] == '=' &&
+      !memcmp(unknown_key, STRING_WITH_LEN("trigger_table")))
+  {
+    char *ptr= unknown_key + INVALID_TRIGGER_TABLE_LENGTH + 1;
+
+    DBUG_PRINT("info", ("trigger_table affected by BUG#15921 detected"));
+    push_warning_printf(current_thd,
+                        MYSQL_ERROR::WARN_LEVEL_NOTE,
+                        ER_OLD_FILE_FORMAT,
+                        ER(ER_OLD_FILE_FORMAT),
+                        (char *)path, "TRIGGER");
+
+    if (!(ptr= parse_escaped_string(ptr, end, mem_root, trigger_table_value)))
+    {
+      my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), "trigger_table", unknown_key);
+      DBUG_RETURN(TRUE);
+    }
+
+    /*
+      Set parsing pointer to the last symbol of string (\n)
+      1) to avoid problem with \0 in the junk after trigger_table
       2) to speed up skipping this line by parser.
     */
     unknown_key= ptr-1;
Thread
bk commit into 5.0 tree (anozdrin:1.2074) BUG#15921Alexander Nozdrin17 Mar