List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:June 14 2007 6:47am
Subject:bk commit into 5.1 tree (anozdrin:1.2550) BUG#11986
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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@stripped, 2007-06-14 10:47:17+04:00, anozdrin@ibm. +9 -0
  The second cleanup patch in scope of BUG#11986.
  
  1. Introduce parse_sql() as a high-level replacement for MYSQLparse().
  parse_sql() is responsible to switch and restore "parser context"
  (THD::m_lip for now).
  
  2. Fix typo in sp.cc: THD::spcont should be reset *before* calling
  the parser.

  sql/event_data_objects.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +1 -3
    Use parse_sql() instead of MYSQLparse().

  sql/mysql_priv.h@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +2 -1
    Introduce parse_sql() instead of auto-generated MYSQLparse.

  sql/sp.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +20 -20
    1. Use parse_sql() instead of MYSQLparse().
    2. THD::spcont should be reset before calling the parser.

  sql/sql_class.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +2 -1
    Reset THD::m_lip.

  sql/sql_parse.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +23 -8
    1. Introduce parse_sql() instead of auto-generated MYSQLparse().
    2. Backup, switch and restore THD::m_lip inside parse_sql().
    3. Use parse_sql() instead of MYSQLparse().

  sql/sql_partition.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +1 -2
    Use parse_sql() instead of MYSQLparse().

  sql/sql_prepare.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +3 -4
    Use parse_sql() instead of MYSQLparse().

  sql/sql_trigger.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +1 -3
    Use parse_sql() instead of MYSQLparse().

  sql/sql_view.cc@stripped, 2007-06-14 10:47:13+04:00, anozdrin@ibm. +3 -4
    Use parse_sql() instead of MYSQLparse().

# 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:	ibm.
# Root:	/home/alik/Documents/MySQL/devel/5.1-rt-cs-4

--- 1.517/sql/mysql_priv.h	2007-06-12 01:57:13 +04:00
+++ 1.518/sql/mysql_priv.h	2007-06-14 10:47:13 +04:00
@@ -618,6 +618,8 @@
                               uint max_char_length, CHARSET_INFO *cs,
                               bool no_error);
 
+bool parse_sql(THD *thd, class Lex_input_stream *lip);
+
 enum enum_mysql_completiontype {
   ROLLBACK_RELEASE=-2, ROLLBACK=1,  ROLLBACK_AND_CHAIN=7,
   COMMIT_RELEASE=-1,   COMMIT=0,    COMMIT_AND_CHAIN=6
@@ -1953,7 +1955,6 @@
 void free_list(I_List <i_string> *list);
 
 /* sql_yacc.cc */
-extern int MYSQLparse(void *thd);
 #ifndef DBUG_OFF
 extern void turn_parser_debug_on();
 #endif

--- 1.338/sql/sql_class.cc	2007-06-10 14:43:54 +04:00
+++ 1.339/sql/sql_class.cc	2007-06-14 10:47:13 +04:00
@@ -342,7 +342,8 @@
    in_lock_tables(0),
    bootstrap(0),
    derived_tables_processing(FALSE),
-   spcont(NULL)
+   spcont(NULL),
+   m_lip(NULL)
 {
   ulong tmp;
 

--- 1.678/sql/sql_parse.cc	2007-06-12 01:57:14 +04:00
+++ 1.679/sql/sql_parse.cc	2007-06-14 10:47:13 +04:00
@@ -5343,12 +5343,11 @@
     sp_cache_flush_obsolete(&thd->sp_func_cache);
 
     Lex_input_stream lip(thd, inBuf, length);
-    thd->m_lip= &lip;
 
-    int err= MYSQLparse(thd);
+    bool err= parse_sql(thd, &lip);
     *found_semicolon= lip.found_semicolon;
 
-    if (!err && ! thd->is_fatal_error)
+    if (!err)
     {
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
       if (mqh_used && thd->user_connect &&
@@ -5371,8 +5370,8 @@
             PROCESSLIST.
             Note that we don't need LOCK_thread_count to modify query_length.
           */
-          if (lip.found_semicolon &&
-              (thd->query_length= (ulong)(lip.found_semicolon - thd->query)))
+          if (*found_semicolon &&
+              (thd->query_length= (ulong)(*found_semicolon - thd->query)))
             thd->query_length--;
           /* Actually execute the query */
 	  mysql_execute_command(thd);
@@ -5426,12 +5425,10 @@
   DBUG_ENTER("mysql_test_parse_for_slave");
 
   Lex_input_stream lip(thd, inBuf, length);
-  thd->m_lip= &lip;
   lex_start(thd);
   mysql_reset_thd_for_next_command(thd);
-  int err= MYSQLparse((void*) thd);
 
-  if (!err && ! thd->is_fatal_error &&
+  if (!parse_sql(thd, &lip) &&
       all_tables_not_ok(thd,(TABLE_LIST*) lex->select_lex.table_list.first))
     error= 1;                  /* Ignore question */
   thd->end_statement();
@@ -7122,4 +7119,22 @@
   if (!no_error)
     my_error(ER_WRONG_STRING_LENGTH, MYF(0), str->str, err_msg, max_char_length);
   return TRUE;
+}
+
+
+extern int MYSQLparse(void *thd); // from sql_yacc.cc
+
+
+bool parse_sql(THD *thd, Lex_input_stream *lip)
+{
+  bool err_status;
+  Lex_input_stream *saved_lip= thd->m_lip;
+
+  thd->m_lip= lip;
+
+  err_status= MYSQLparse(thd) != 0 || thd->is_fatal_error;
+
+  thd->m_lip= saved_lip;
+
+  return err_status;
 }

--- 1.102/sql/event_data_objects.cc	2007-06-12 21:04:18 +04:00
+++ 1.103/sql/event_data_objects.cc	2007-06-14 10:47:13 +04:00
@@ -1875,11 +1875,9 @@
 
   {
     Lex_input_stream lip(thd, thd->query, thd->query_length);
-    thd->m_lip= &lip;
     lex_start(thd);
-    int err= MYSQLparse(thd);
 
-    if (err || thd->is_fatal_error)
+    if (parse_sql(thd, &lip))
     {
       sql_print_error("Event Scheduler: "
                       "%serror during compilation of %s.%s",

--- 1.139/sql/sql_view.cc	2007-06-12 21:04:18 +04:00
+++ 1.140/sql/sql_view.cc	2007-06-14 10:47:13 +04:00
@@ -893,7 +893,7 @@
   LEX *old_lex, *lex;
   Query_arena *arena, backup;
   TABLE_LIST *top_view= table->top_table();
-  int res;
+  bool res;
   bool result, view_is_mergeable;
   TABLE_LIST *view_main_select_tables;
   DBUG_ENTER("mysql_make_view");
@@ -1005,7 +1005,6 @@
 
   {
     Lex_input_stream lip(thd, table->query.str, table->query.length);
-    thd->m_lip= &lip;
     lex_start(thd);
     view_select= &lex->select_lex;
     view_select->select_number= ++thd->select_number;
@@ -1039,7 +1038,7 @@
                                 MODE_IGNORE_SPACE | MODE_NO_BACKSLASH_ESCAPES);
     CHARSET_INFO *save_cs= thd->variables.character_set_client;
     thd->variables.character_set_client= system_charset_info;
-    res= MYSQLparse((void *)thd);
+    res= parse_sql(thd, &lip);
 
     if ((old_lex->sql_command == SQLCOM_SHOW_FIELDS) ||
         (old_lex->sql_command == SQLCOM_SHOW_CREATE))
@@ -1048,7 +1047,7 @@
     thd->variables.character_set_client= save_cs;
     thd->variables.sql_mode= save_mode;
   }
-  if (!res && !thd->is_fatal_error)
+  if (!res)
   {
     TABLE_LIST *view_tables= lex->query_tables;
     TABLE_LIST *view_tables_tail= 0;

--- 1.95/sql/sql_trigger.cc	2007-06-12 21:04:18 +04:00
+++ 1.96/sql/sql_trigger.cc	2007-06-14 10:47:13 +04:00
@@ -981,12 +981,10 @@
         thd->variables.sql_mode= (ulong)*trg_sql_mode;
 
         Lex_input_stream lip(thd, trg_create_str->str, trg_create_str->length);
-        thd->m_lip= &lip;
         lex_start(thd);
         thd->spcont= 0;
-        int err= MYSQLparse((void *)thd);
 
-        if (err || thd->is_fatal_error)
+        if (parse_sql(thd, &lip))
         {
           /* Currently sphead is always deleted in case of a parse error */
           DBUG_ASSERT(lex.sphead == 0);

--- 1.106/sql/sql_partition.cc	2007-06-01 11:43:54 +04:00
+++ 1.107/sql/sql_partition.cc	2007-06-14 10:47:13 +04:00
@@ -3696,7 +3696,6 @@
   thd->variables.character_set_client= system_charset_info;
 
   Lex_input_stream lip(thd, part_buf, part_info_len);
-  thd->m_lip= &lip;
 
   lex_start(thd);
   /*
@@ -3725,7 +3724,7 @@
   lex.part_info->part_state= part_state;
   lex.part_info->part_state_len= part_state_len;
   DBUG_PRINT("info", ("Parse: %s", part_buf));
-  if (MYSQLparse((void*)thd) || thd->is_fatal_error)
+  if (parse_sql(thd, &lip))
   {
     thd->free_items();
     goto end;

--- 1.155/sql/sp.cc	2007-06-12 21:04:18 +04:00
+++ 1.156/sql/sp.cc	2007-06-14 10:47:13 +04:00
@@ -384,32 +384,32 @@
   if ((ret= sp_use_new_db(thd, name->m_db, &old_db, 1, &dbchanged)))
     goto end;
 
+  thd->spcont= NULL;
+
   {
     Lex_input_stream lip(thd, defstr.c_ptr(), defstr.length());
-    thd->m_lip= &lip;
     lex_start(thd);
-    ret= MYSQLparse(thd);
-  }
 
-  thd->spcont= 0;
-  if (ret || thd->is_fatal_error || newlex.sphead == NULL)
-  {
-    sp_head *sp= newlex.sphead;
+    if (parse_sql(thd, &lip) || newlex.sphead == NULL)
+    {
+      sp_head *sp= newlex.sphead;
 
-    if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE)))
-      goto end;
-    delete sp;
-    ret= SP_PARSE_ERROR;
-  }
-  else
-  {
-    if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE)))
-      goto end;
-    *sphp= newlex.sphead;
-    (*sphp)->set_definer(&definer_user_name, &definer_host_name);
-    (*sphp)->set_info(created, modified, &chistics, sql_mode);
-    (*sphp)->optimize();
+      if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE)))
+        goto end;
+      delete sp;
+      ret= SP_PARSE_ERROR;
+    }
+    else
+    {
+      if (dbchanged && (ret= mysql_change_db(thd, &old_db, TRUE)))
+        goto end;
+      *sphp= newlex.sphead;
+      (*sphp)->set_definer(&definer_user_name, &definer_host_name);
+      (*sphp)->set_info(created, modified, &chistics, sql_mode);
+      (*sphp)->optimize();
+    }
   }
+
 end:
   lex_end(thd->lex);
   thd->spcont= old_spcont;

--- 1.221/sql/sql_prepare.cc	2007-06-06 01:55:51 +04:00
+++ 1.222/sql/sql_prepare.cc	2007-06-14 10:47:13 +04:00
@@ -2858,12 +2858,11 @@
 
   Lex_input_stream lip(thd, thd->query, thd->query_length);
   lip.stmt_prepare_mode= TRUE;
-  thd->m_lip= &lip;
   lex_start(thd);
-  int err= MYSQLparse((void *)thd);
 
-  error= err || thd->is_fatal_error ||
-      thd->net.report_error || init_param_array(this);
+  error= parse_sql(thd, &lip) ||
+         thd->net.report_error ||
+         init_param_array(this);
 
   /*
     While doing context analysis of the query (in check_prepared_statement)
Thread
bk commit into 5.1 tree (anozdrin:1.2550) BUG#11986Alexander Nozdrin14 Jun