List:Commits« Previous MessageNext Message »
From:Lars Thalmann Date:December 20 2005 12:12am
Subject:bk commit into 5.1 tree (lars:1.1966)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of lthalmann. When lthalmann 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.1966 05/12/20 01:12:27 lars@stripped +15 -0
  WL#2321:  Review fixes

  sql/sql_yacc.yy
    1.432 05/12/20 01:12:06 lars@stripped +3 -3
    Changed names

  sql/sql_parse.cc
    1.489 05/12/20 01:12:06 lars@stripped +8 -9
    Should always close

  sql/sql_lex.h
    1.212 05/12/20 01:12:06 lars@stripped +1 -1
    Renamed enum value

  sql/sql_class.h
    1.278 05/12/20 01:12:05 lars@stripped +0 -3
    Should always close tables

  sql/sql_class.cc
    1.231 05/12/20 01:12:05 lars@stripped +2 -2
    Newline

  sql/sql_binlog.cc
    1.3 05/12/20 01:12:05 lars@stripped +65 -54
    Copyright
    Changed OOM checking
    Reorganization
    Added no_send_ok trick
    Added error checks

  sql/sql_base.cc
    1.282 05/12/20 01:12:05 lars@stripped +0 -2
    Removed printout

  sql/slave.h
    1.97 05/12/20 01:12:04 lars@stripped +1 -1
    Local function

  sql/slave.cc
    1.265 05/12/20 01:12:04 lars@stripped +6 -4
    Added sql-thread error messages also for BINLOG statement
    Cleanup of code that is local

  sql/rpl_rli.h
    1.3 05/12/20 01:12:04 lars@stripped +5 -1
    Comment

  sql/mysql_priv.h
    1.348 05/12/20 01:12:03 lars@stripped +1 -1
    Changed name

  sql/log_event.cc
    1.203 05/12/20 01:12:03 lars@stripped +8 -3
    Print error to stderr
    Reset in_use

  mysql-test/t/mysqlbinlog_base64.test
    1.3 05/12/20 01:12:03 lars@stripped +6 -0
    Added test

  mysql-test/r/mysqlbinlog_base64.result
    1.2 05/12/20 01:12:03 lars@stripped +76 -0
    Added test

  libmysqld/Makefile.am
    1.75 05/12/20 01:12:02 lars@stripped +1 -2
    Removed dependencies

# 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:	lars
# Host:	dl145k.mysql.com
# Root:	/users/lthalmann/bk/mysql-5.1-wl1012-v3-wl2321-max

--- 1.202/sql/log_event.cc	2005-12-14 23:36:36 +01:00
+++ 1.203/sql/log_event.cc	2005-12-20 01:12:03 +01:00
@@ -986,13 +986,13 @@
   char *tmp_str=
     (char *) my_malloc(base64_needed_encoded_length(size), MYF(MY_WME));
   if (!tmp_str) {
-    fprintf(file, "\nError: Out of memory. "
+    fprintf(stderr, "\nError: Out of memory. "
             "Could not print correct binlog event.\n");
-    exit(1);
+    return;
   }
   int res= base64_encode(ptr, size, tmp_str);
   fprintf(file, "\nBINLOG '\n%s\n';\n", tmp_str);
-  my_free(tmp_str, MYF(MY_ALLOW_ZERO_PTR));
+  my_free(tmp_str, MYF(0));
 }
 
 
@@ -5342,7 +5342,12 @@
       DBUG_ASSERT(row_end != NULL); // cannot happen
       DBUG_ASSERT(row_end <= m_rows_end);
 
+      /* in_use can have been set to NULL in close_tables_for_reopen */
+      THD* old_thd= table->in_use;
+      if (!table->in_use)
+        table->in_use= thd;
       error= do_exec_row(table);
+      table->in_use = old_thd;
       switch (error)
       {
         /* Some recoverable errors */

--- 1.347/sql/mysql_priv.h	2005-12-14 19:58:04 +01:00
+++ 1.348/sql/mysql_priv.h	2005-12-20 01:12:03 +01:00
@@ -600,7 +600,7 @@
 bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
 bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
 void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
-void mysql_binlog_statement(THD *thd);
+void mysql_client_binlog_statement(THD *thd);
 bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
                     my_bool drop_temporary);
 int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,

--- 1.264/sql/slave.cc	2005-12-14 19:58:06 +01:00
+++ 1.265/sql/slave.cc	2005-12-20 01:12:04 +01:00
@@ -922,6 +922,11 @@
   {
   case ERROR_LEVEL:
     /*
+      This my_error call only has effect in client threads.
+      Slave threads do nothing in my_error().
+    */
+    my_error(ER_UNKNOWN_ERROR, MYF(0), msg);
+    /*
       It's an error, it must be reported in Last_error and Last_errno in SHOW
       SLAVE STATUS.
     */
@@ -4379,9 +4384,6 @@
   DBUG_ASSERT(rli->cur_log_fd == -1);
   DBUG_ENTER("reopen_relay_log");
 
-  if (rli->no_storage)
-    DBUG_RETURN(0);
-
   IO_CACHE *cur_log = rli->cur_log=&rli->cache_buf;
   if ((rli->cur_log_fd=open_binlog(cur_log,rli->event_relay_log_name,
 				   errmsg)) <0)
@@ -4397,7 +4399,7 @@
 }
 
 
-Log_event* next_event(RELAY_LOG_INFO* rli)
+static Log_event* next_event(RELAY_LOG_INFO* rli)
 {
   Log_event* ev;
   IO_CACHE* cur_log = rli->cur_log;

--- 1.281/sql/sql_base.cc	2005-12-13 16:10:49 +01:00
+++ 1.282/sql/sql_base.cc	2005-12-20 01:12:05 +01:00
@@ -2369,8 +2369,6 @@
   static ulong last_table_id= ULONG_MAX;
 
   DBUG_ENTER("assign_new_table_id(TABLE*)");
-  DBUG_PRINT("enter", ("table=%p (%s.%s)",
-                       table, table->s->db, table->s->table_name));
 
   /* Preconditions */
   DBUG_ASSERT(table != NULL);

--- 1.230/sql/sql_class.cc	2005-12-14 19:58:06 +01:00
+++ 1.231/sql/sql_class.cc	2005-12-20 01:12:05 +01:00
@@ -177,7 +177,6 @@
 THD::THD()
   :Statement(CONVENTIONAL_EXECUTION, 0, ALLOC_ROOT_MIN_BLOCK_SIZE, 0),
    Open_tables_state(refresh_version), rli_fake(0),
-   should_close_thread_tables(TRUE),
    lock_id(&main_lock_id),
    user_time(0), in_sub_stmt(0), global_read_lock(0), is_fatal_error(0),
    rand_used(0), time_zone_used(0),
@@ -447,7 +446,8 @@
   dbug_sentry= THD_SENTRY_GONE;
 #endif  
 #ifndef EMBEDDED_LIBRARY
-  if (rli_fake) delete rli_fake;
+  if (rli_fake)
+    delete rli_fake;
 #endif
 
   DBUG_VOID_RETURN;

--- 1.277/sql/sql_class.h	2005-12-14 19:58:07 +01:00
+++ 1.278/sql/sql_class.h	2005-12-20 01:12:05 +01:00
@@ -791,9 +791,6 @@
   /* Used to execute base64 coded binlog events in MySQL server */
   RELAY_LOG_INFO* rli_fake;
 
-  /* When executing base64 binlog events, the tables should not be closed */
-  bool should_close_thread_tables;
-
   /*
     Constant for THD::where initialization in the beginning of every query.
 

--- 1.211/sql/sql_lex.h	2005-12-14 19:58:08 +01:00
+++ 1.212/sql/sql_lex.h	2005-12-20 01:12:06 +01:00
@@ -93,7 +93,7 @@
   SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
   SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
   SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN,
-  SQLCOM_SHOW_AUTHORS, SQLCOM_BINLOG,
+  SQLCOM_SHOW_AUTHORS, SQLCOM_BINLOG_BASE64_EVENT,
   /* This should be the last !!! */
 
   SQLCOM_END

--- 1.488/sql/sql_parse.cc	2005-12-14 19:58:09 +01:00
+++ 1.489/sql/sql_parse.cc	2005-12-20 01:12:06 +01:00
@@ -2058,8 +2058,8 @@
     my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
     break;
   }
-  if ((thd->lock || thd->open_tables || thd->derived_tables ||
-       thd->prelocked_mode) && thd->should_close_thread_tables)
+  if (thd->lock || thd->open_tables || thd->derived_tables ||
+      thd->prelocked_mode)
   {
     thd->proc_info="closing tables";
     close_thread_tables(thd);			/* Free tables */
@@ -2427,11 +2427,6 @@
     statistic_increment(thd->status_var.com_stat[lex->sql_command],
                         &LOCK_status);
 
-  /*
-    Any non-binlog statement should close thread tables
-  */
-  thd->should_close_thread_tables= TRUE;
-
   switch (lex->sql_command) {
   case SQLCOM_SELECT:
   {
@@ -4831,9 +4826,13 @@
     if (! (res= mysql_uninstall_plugin(thd, &thd->lex->comment)))
       send_ok(thd);
     break;
-  case SQLCOM_BINLOG:
+  case SQLCOM_BINLOG_BASE64_EVENT:
   {
-    mysql_binlog_statement(thd);
+#ifndef EMBEDDED_LIBRARY
+    mysql_client_binlog_statement(thd);
+#else /* EMBEDDED_LIBRARY */
+    my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "embedded");
+#endif /* EMBEDDED_LIBRARY */
     break;
   }
   default:

--- 1.431/sql/sql_yacc.yy	2005-12-14 19:58:11 +01:00
+++ 1.432/sql/sql_yacc.yy	2005-12-20 01:12:06 +01:00
@@ -897,7 +897,7 @@
 	  alter
 	| analyze
 	| backup
-	| binlog_event
+	| binlog_base64_event
 	| call
 	| change
 	| check
@@ -4401,10 +4401,10 @@
 	{}
 	;
 
-binlog_event:
+binlog_base64_event:
         BINLOG_SYM TEXT_STRING_sys
         {
-           Lex->sql_command = SQLCOM_BINLOG;
+           Lex->sql_command = SQLCOM_BINLOG_BASE64_EVENT;
            Lex->comment= $2;
         }
 

--- 1.1/mysql-test/r/mysqlbinlog_base64.result	2005-12-07 17:26:42 +01:00
+++ 1.2/mysql-test/r/mysqlbinlog_base64.result	2005-12-20 01:12:03 +01:00
@@ -4,10 +4,86 @@
 insert into t1 values (3);
 update t1 set a=a+2 where a=2;
 update t1 set a=a+2 where a=3;
+create table t2 (word varchar(20));
+load data infile '../../std_data/words.dat' into table t2;
 drop table t1;
+drop table t2;
 select * from t1;
 a
 1
 4
 5
+select * from t2;
+word
+Aarhus
+Aaron
+Ababa
+aback
+abaft
+abandon
+abandoned
+abandoning
+abandonment
+abandons
+Aarhus
+Aaron
+Ababa
+aback
+abaft
+abandon
+abandoned
+abandoning
+abandonment
+abandons
+abase
+abased
+abasement
+abasements
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+Abba
+abbe
+abbey
+abbeys
+abbot
+abbots
+Abbott
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+Abby
+abdomen
+abdomens
+abdominal
+abduct
+abducted
+abduction
+abductions
+abductor
+abductors
+abducts
+Abe
+abed
+Abel
+Abelian
+Abelson
+Aberdeen
+Abernathy
+aberrant
+aberration
 drop table t1;
+drop table t2;

--- 1.2/mysql-test/t/mysqlbinlog_base64.test	2005-12-14 01:39:45 +01:00
+++ 1.3/mysql-test/t/mysqlbinlog_base64.test	2005-12-20 01:12:03 +01:00
@@ -8,6 +8,9 @@
 update t1 set a=a+2 where a=2;
 update t1 set a=a+2 where a=3;
 
+create table t2 (word varchar(20));
+load data infile '../../std_data/words.dat' into table t2;
+
 #
 #  Save binlog
 #
@@ -17,15 +20,18 @@
 #  Clear database and restore from binlog
 #
 drop table t1;
+drop table t2;
 --exec $MYSQL test < $MYSQL_TEST_DIR/var/tmp/mysqlbinlog_base64.sql
 
 #
 #  Verify that all binlog events have been executed
 #
 select * from t1;
+select * from t2;
 
 #
 #  Test cleanup
 #
 --exec rm $MYSQL_TEST_DIR/var/tmp/mysqlbinlog_base64.sql
 drop table t1;
+drop table t2;

--- 1.2/sql/rpl_rli.h	2005-12-14 01:39:46 +01:00
+++ 1.3/sql/rpl_rli.h	2005-12-20 01:12:04 +01:00
@@ -49,7 +49,11 @@
 
 typedef struct st_relay_log_info
 {
-  /* If flag set, then rli does not store its state in any info file */
+  /*
+    If flag set, then rli does not store its state in any info file.
+    This is the case only when we execute BINLOG SQL commands inside
+    a client, non-replication thread.
+  */
   bool no_storage;
 
   /*** The following variables can only be read when protect by data lock ****/

--- 1.2/sql/sql_binlog.cc	2005-12-14 19:22:40 +01:00
+++ 1.3/sql/sql_binlog.cc	2005-12-20 01:12:05 +01:00
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2005 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,41 +17,61 @@
 #include "mysql_priv.h"
 #include "base64.h"
 
-void mysql_binlog_statement(THD* thd)
-{
-#ifndef EMBEDDED_LIBRARY
-  if (!thd->rli_fake)
-    thd->rli_fake= new RELAY_LOG_INFO;
-  if (!thd->rli_fake)
-  {
-    my_error(ER_OUTOFMEMORY, MYF(0));
-    return;
-  }
-  thd->rli_fake->sql_thd= thd;
+/*
+  Execute a BINLOG statement
 
-  const Format_description_log_event *desc=
-    new Format_description_log_event(4);
+  TODO: This currently assumes a MySQL 5.x binlog.
+  When we'll have binlog with a different format, to execute the
+  BINLOG command properly the server will need to know which format
+  the BINLOG command's event is in.  mysqlbinlog should then send
+  the Format_description_log_event of the binlog it reads and the
+  server thread should cache this format into
+  rli->description_event_for_exec.
+*/
 
-  DBUG_PRINT("info",("binlog base64: '%*s'", thd->lex->comment.length,
+void mysql_client_binlog_statement(THD* thd)
+{
+  DBUG_PRINT("info",("binlog base64: '%*s'",
+                     (thd->lex->comment.length < 2048 ?
+                      thd->lex->comment.length : 2048),
                      thd->lex->comment.str));
 
-  thd->rli_fake->no_storage= TRUE;
+  /*
+    Temporarily turn off send_ok, since different events handle this
+    differently
+  */
+  my_bool nsok= thd->net.no_send_ok;
+  thd->net.no_send_ok= TRUE;
 
   const my_size_t coded_len= thd->lex->comment.length + 1;
   const my_size_t event_len= base64_needed_decoded_length(coded_len);
+  DBUG_ASSERT(coded_len > 0);
 
+  /*
+    Allocation
+  */
+  if (!thd->rli_fake)
+    thd->rli_fake= new RELAY_LOG_INFO;
+
+  const Format_description_log_event *desc=
+    new Format_description_log_event(4);
+
+  const char *error= 0;
   char *buf= (char *) my_malloc(event_len, MYF(MY_WME));
-  if (!buf)
+
+  /*
+    Out of memory check
+  */
+  if (!(thd->rli_fake && desc && buf))
   {
-    my_error(ER_OUTOFMEMORY, MYF(0));
-    delete desc;
-    return;
+    my_error(ER_OUTOFMEMORY, MYF(0), 1);  /* needed 1 bytes */
+    goto end;
   }
 
-  DBUG_ASSERT(coded_len>0);
-  const int res= base64_decode(thd->lex->comment.str, coded_len, buf);
+  thd->rli_fake->sql_thd= thd;
+  thd->rli_fake->no_storage= TRUE;
 
-  const char *error= 0;
+  const int res= base64_decode(thd->lex->comment.str, coded_len, buf);
 
   DBUG_PRINT("info",("binlog base64 decoded_len=%d, event_len=%d\n",
                      res, uint4korr(buf + EVENT_LEN_OFFSET)));
@@ -64,9 +84,7 @@
       || (uint) res != uint4korr(buf+EVENT_LEN_OFFSET))
   {
     my_error(ER_SYNTAX_ERROR, MYF(0));
-    delete desc;
-    my_free(buf, MYF(0));
-    return;
+    goto end;
   }
 
   Log_event *ev= Log_event::read_log_event(buf, res, &error, desc);
@@ -79,44 +97,37 @@
       likely causes by a bad statement
     */
     my_error(ER_SYNTAX_ERROR, MYF(0));
-    delete desc;
-    my_free(buf, MYF(0));
-    return;
+    goto end;
   }
 
   DBUG_PRINT("info",("ev->get_type_code()=%d", ev->get_type_code()));
   DBUG_PRINT("info",("buf+EVENT_TYPE_OFFSET=%d", buf+EVENT_TYPE_OFFSET));
 
-  ev->thd= current_thd;
-  ev->exec_event(thd->rli_fake);
-
-  DBUG_PRINT("info",("binlog base64 execution finished"));
+  ev->thd= thd;
+  if (ev->exec_event(thd->rli_fake))
+  {
+    my_error(ER_UNKNOWN_ERROR, MYF(0), "Error executing BINLOG statement");
+    goto end;
+  }
 
   /*
-    Don't send_ok() for QUERY_EVENTs. It is the responsibility of
-    query execution send it.  Some other events also execute their own
-    send_ok, so for them this code does not work.
+    Restore setting of no_send_ok
   */
-  if (ev->get_type_code() != QUERY_EVENT)
-    send_ok(thd);
+  thd->net.no_send_ok= nsok;
 
+  DBUG_PRINT("info",("binlog base64 execution finished successfully"));
+  send_ok(thd);
+
+end:
   /*
-    If rows event without trans_end, then do not close tables
+    Restore setting of no_send_ok
   */
-  if (ev->get_type_code() == TABLE_MAP_EVENT ||
-      ((ev->get_type_code() == WRITE_ROWS_EVENT ||
-        ev->get_type_code() == UPDATE_ROWS_EVENT ||
-        ev->get_type_code() == DELETE_ROWS_EVENT) && 
-       !((Rows_log_event*) ev)->get_flags(Rows_log_event::STMT_END_F)))
-  {
-    DBUG_PRINT("info", ("set thd->should_close_thread_tables=FALSE"));
-    thd->should_close_thread_tables= FALSE;
-  }
+  thd->net.no_send_ok= nsok;
 
-  delete ev;
-  delete desc;
-  my_free(buf, MYF(0));
-#else /* EMBEDDED_LIBRARY */
-  my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "embedded");
-#endif /* EMBEDDED_LIBRARY */
+  if (ev)
+    delete ev;
+  if (desc)
+    delete desc;
+  if (buf)
+    my_free(buf, MYF(0));
 }

--- 1.74/libmysqld/Makefile.am	2005-12-14 19:58:01 +01:00
+++ 1.75/libmysqld/Makefile.am	2005-12-20 01:12:02 +01:00
@@ -63,8 +63,7 @@
 	spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \
 	sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
 	parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
-        rpl_filter.cc sql_partition.cc handlerton.cc sql_plugin.cc \
-	slave.cc sql_binlog.cc
+        rpl_filter.cc sql_partition.cc handlerton.cc sql_plugin.cc
 
 libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources)
 EXTRA_libmysqld_a_SOURCES =	ha_innodb.cc ha_berkeley.cc ha_archive.cc \

--- 1.96/sql/slave.h	2005-12-09 13:53:05 +01:00
+++ 1.97/sql/slave.h	2005-12-20 01:12:04 +01:00
@@ -112,7 +112,7 @@
 #define MYSQL_SLAVE_RUN_NOT_CONNECT 1
 #define MYSQL_SLAVE_RUN_CONNECT     2
 
-Log_event* next_event(RELAY_LOG_INFO* rli);
+static Log_event* next_event(RELAY_LOG_INFO* rli);
 
 /*****************************************************************************
 
Thread
bk commit into 5.1 tree (lars:1.1966)Lars Thalmann20 Dec