List:Commits« Previous MessageNext Message »
From:konstantin Date:April 5 2007 6:50pm
Subject:bk commit into 5.1 tree (kostja:1.2565)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kostja. When kostja 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-04-05 20:50:28+04:00, kostja@vajra.(none) +4 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
  into  vajra.(none):/opt/local/work/mysql-5.1-c1
  MERGE: 1.2550.1.6

  sql/mysqld.cc@stripped, 2007-04-05 20:50:20+04:00, kostja@vajra.(none) +0 -0
    Auto merged
    MERGE: 1.626.1.1

  sql/sql_show.cc@stripped, 2007-04-05 20:50:21+04:00, kostja@vajra.(none) +0 -0
    Auto merged
    MERGE: 1.400.1.2

  sql/sql_yacc.yy@stripped, 2007-04-05 20:50:22+04:00, kostja@vajra.(none) +0 -0
    Auto merged
    MERGE: 1.558.1.2

  sql/table.cc@stripped, 2007-04-05 20:50:22+04:00, kostja@vajra.(none) +0 -0
    Auto merged
    MERGE: 1.282.1.1

# 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:	kostja
# Host:	vajra.(none)
# Root:	/opt/local/work/mysql-5.1-c1/RESYNC

--- 1.627/sql/mysqld.cc	2007-04-04 13:05:09 +04:00
+++ 1.628/sql/mysqld.cc	2007-04-05 20:50:20 +04:00
@@ -885,7 +885,7 @@
   }
   (void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list
 
-  Events::get_instance()->deinit();
+  Events::deinit();
   end_slave();
 
   if (thread_count)
@@ -1330,7 +1330,7 @@
   (void) pthread_mutex_destroy(&LOCK_bytes_sent);
   (void) pthread_mutex_destroy(&LOCK_bytes_received);
   (void) pthread_mutex_destroy(&LOCK_user_conn);
-  Events::get_instance()->destroy_mutexes();
+  Events::destroy_mutexes();
 #ifdef HAVE_OPENSSL
   (void) pthread_mutex_destroy(&LOCK_des_key_file);
 #ifndef HAVE_YASSL
@@ -3058,7 +3058,7 @@
   (void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST);
   (void) pthread_cond_init(&COND_server_started,NULL);
   sp_cache_init();
-  Events::get_instance()->init_mutexes();
+  Events::init_mutexes();
   /* Parameter for threads created for connections */
   (void) pthread_attr_init(&connection_attrib);
   (void) pthread_attr_setdetachstate(&connection_attrib,
@@ -3844,21 +3844,15 @@
   create_shutdown_thread();
   create_maintenance_thread();
 
+  if (Events::init(opt_noacl))
+    unireg_abort(1);
+
   sql_print_information(ER(ER_STARTUP),my_progname,server_version,
                         ((unix_sock == INVALID_SOCKET) ? (char*) ""
                                                        : mysqld_unix_port),
                          mysqld_port,
                          MYSQL_COMPILATION_COMMENT);
 
-  if (!opt_noacl)
-  {
-    if (Events::get_instance()->init())
-      unireg_abort(1);
-  }
-  else
-  {
-    Events::opt_event_scheduler = Events::EVENTS_DISABLED; 
-  }
 
   /* Signal threads waiting for server to be started */
   pthread_mutex_lock(&LOCK_server_started);
@@ -7597,32 +7591,8 @@
   }
 #endif
   case OPT_EVENT_SCHEDULER:
-    if (!argument)
-      Events::opt_event_scheduler= Events::EVENTS_DISABLED;
-    else
-    {
-      int type;
-      /* 
-        type=     5          1   2      3   4
-             (DISABLE ) - (OFF | ON) - (0 | 1)
-      */
-      switch ((type=find_type(argument, &Events::opt_typelib, 1))) {
-      case 0:
-	fprintf(stderr, "Unknown option to event-scheduler: %s\n",argument);
-	exit(1);
-      case 5: /* OPT_DISABLED */
-        Events::opt_event_scheduler= Events::EVENTS_DISABLED;
-        break;
-      case 2: /* OPT_ON  */
-      case 4: /* 1   */
-        Events::opt_event_scheduler= Events::EVENTS_ON;
-        break;
-      case 1: /* OPT_OFF */
-      case 3: /*  0  */
-        Events::opt_event_scheduler= Events::EVENTS_OFF;
-        break;
-      }
-    }
+    if (Events::set_opt_event_scheduler(argument))
+      exit(1);
     break;
   case (int) OPT_SKIP_NEW:
     opt_specialflag|= SPECIAL_NO_NEW_FUNC;

--- 1.402/sql/sql_show.cc	2007-04-02 12:54:28 +04:00
+++ 1.403/sql/sql_show.cc	2007-04-05 20:50:21 +04:00
@@ -3761,8 +3761,7 @@
                           LEX_STRING *definer_buffer)
 {
   CHARSET_INFO *cs= system_charset_info;
-  byte *sql_mode_str;
-  ulong sql_mode_len;
+  LEX_STRING sql_mode_rep;
 
   restore_record(table, s->default_values);
   table->field[1]->store(db, strlen(db), cs);
@@ -3778,11 +3777,9 @@
   table->field[14]->store(STRING_WITH_LEN("OLD"), cs);
   table->field[15]->store(STRING_WITH_LEN("NEW"), cs);
 
-  sql_mode_str=
-    sys_var_thd_sql_mode::symbolic_mode_representation(thd,
-                                                       sql_mode,
-                                                       &sql_mode_len);
-  table->field[17]->store((const char*)sql_mode_str, sql_mode_len, cs);
+  sys_var_thd_sql_mode::symbolic_mode_representation(thd, sql_mode,
+                                                     &sql_mode_rep);
+  table->field[17]->store(sql_mode_rep.str, sql_mode_rep.length, cs);
   table->field[18]->store((const char *)definer_buffer->str,
definer_buffer->length, cs);
   return schema_table_store_record(thd, table);
 }
@@ -4308,13 +4305,13 @@
   CHARSET_INFO *scs= system_charset_info;
   TIME time;
   Event_timed et;    
-  DBUG_ENTER("fill_events_copy_to_schema_tab");
+  DBUG_ENTER("copy_event_to_schema_table");
 
   restore_record(sch_table, s->default_values);
 
   if (et.load_from_row(thd, event_table))
   {
-    my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0));
+    my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0), event_table->alias);
     DBUG_RETURN(1);
   }
 
@@ -4349,13 +4346,11 @@
 
   /* SQL_MODE */
   {
-    byte *sql_mode_str;
-    ulong sql_mode_len= 0;
-    sql_mode_str=
-           sys_var_thd_sql_mode::symbolic_mode_representation(thd, et.sql_mode,
-                                                              &sql_mode_len);
+    LEX_STRING sql_mode;
+    sys_var_thd_sql_mode::symbolic_mode_representation(thd, et.sql_mode,
+                                                       &sql_mode);
     sch_table->field[ISE_SQL_MODE]->
-                                store((const char*)sql_mode_str, sql_mode_len, scs);
+                                store(sql_mode.str, sql_mode.length, scs);
   }
 
   int not_used=0;

--- 1.561/sql/sql_yacc.yy	2007-04-04 13:38:07 +04:00
+++ 1.562/sql/sql_yacc.yy	2007-04-05 20:50:22 +04:00
@@ -949,7 +949,6 @@
 %token  SIGNED_SYM
 %token  SIMPLE_SYM                    /* SQL-2003-N */
 %token  SLAVE
-%token  SLAVESIDE_DISABLE_SYM         
 %token  SMALLINT                      /* SQL-2003-R */
 %token  SNAPSHOT_SYM
 %token  SOCKET_SYM
@@ -10010,7 +10009,6 @@
 	| SIMPLE_SYM		{}
 	| SHARE_SYM		{}
 	| SHUTDOWN		{}
-	| SLAVESIDE_DISABLE_SYM {} 
 	| SNAPSHOT_SYM		{}
 	| SOUNDS_SYM		{}
 	| SQL_CACHE_SYM		{}

--- 1.283/sql/table.cc	2007-04-04 13:05:14 +04:00
+++ 1.284/sql/table.cc	2007-04-05 20:50:22 +04:00
@@ -250,7 +250,7 @@
   Currently these are:
 
   help_category, help_keyword, help_relation, help_topic,
-  proc,
+  proc, event
   time_zone, time_zone_leap_second, time_zone_name, time_zone_transition,
   time_zone_transition_type
 
@@ -283,7 +283,14 @@
            my_tolower(ci, name[0]) == 't' &&
            my_tolower(ci, name[1]) == 'i' &&
            my_tolower(ci, name[2]) == 'm' &&
-           my_tolower(ci, name[3]) == 'e'
+           my_tolower(ci, name[3]) == 'e' ||
+
+           /* mysql.event table */
+           my_tolower(ci, name[0]) == 'e' &&
+           my_tolower(ci, name[1]) == 'v' &&
+           my_tolower(ci, name[2]) == 'e' &&
+           my_tolower(ci, name[3]) == 'n' &&
+           my_tolower(ci, name[4]) == 't'
           )
          );
 }
@@ -2432,153 +2439,143 @@
 }
 
 
-/*
+/**
   Checks whether a table is intact. Should be done *just* after the table has
   been opened.
-  
-  SYNOPSIS
-    table_check_intact()
-      table             The table to check
-      table_f_count     Expected number of columns in the table
-      table_def         Expected structure of the table (column name and type)
-      last_create_time  The table->file->create_time of the table in memory
-                        we have checked last time
-      error_num         ER_XXXX from the error messages file. When 0 no error
-                        is sent to the client in case types does not match.
-                        If different col number either 
-                        ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE or 
-                        ER_COL_COUNT_DOESNT_MATCH_CORRUPTED is used
-
-  RETURNS
-    FALSE  OK
-    TRUE   There was an error
+
+  @param[in] table             The table to check
+  @param[in] table_f_count     Expected number of columns in the table
+  @param[in] table_def         Expected structure of the table (column name
+                               and type)
+
+  @retval  FALSE  OK
+  @retval  TRUE   There was an error. An error message is output
+                  to the error log.  We do not push an error
+                  message into the error stack because this
+                  function is currently only called at start up,
+                  and such errors never reach the user.
 */
 
 my_bool
 table_check_intact(TABLE *table, const uint table_f_count,
-                   const TABLE_FIELD_W_TYPE *table_def,
-                   time_t *last_create_time, int error_num)
+                   const TABLE_FIELD_W_TYPE *table_def)
 {
   uint i;
   my_bool error= FALSE;
   my_bool fields_diff_count;
   DBUG_ENTER("table_check_intact");
-  DBUG_PRINT("info",("table: %s  expected_count: %d  last_create_time: %ld",
-                     table->alias, table_f_count, *last_create_time));
-  
-  if ((fields_diff_count= (table->s->fields != table_f_count)) ||
-      (*last_create_time != table->file->stats.create_time))
+  DBUG_PRINT("info",("table: %s  expected_count: %d",
+                     table->alias, table_f_count));
+
+  fields_diff_count= (table->s->fields != table_f_count);
+  if (fields_diff_count)
   {
-    DBUG_PRINT("info", ("I am suspecting, checking table"));
-    if (fields_diff_count)
+    DBUG_PRINT("info", ("Column count has changed, checking the definition"));
+
+    /* previous MySQL version */
+    if (MYSQL_VERSION_ID > table->s->mysql_version)
     {
-      /* previous MySQL version */
-      error= TRUE;
-      if (MYSQL_VERSION_ID > table->s->mysql_version)
-      {
-        my_error(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE, MYF(0), table->alias,
-                 table_f_count, table->s->fields, table->s->mysql_version,
-                 MYSQL_VERSION_ID);
-        sql_print_error(ER(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE),
-                        table->alias, table_f_count, table->s->fields,
-                        table->s->mysql_version, MYSQL_VERSION_ID);
-        DBUG_RETURN(error);
-
-      }
-      else if (MYSQL_VERSION_ID == table->s->mysql_version)
-      {
-        my_error(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED,MYF(0), table->alias,
-                 table_f_count, table->s->fields);
-        sql_print_error(ER(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED), table->alias,
-                        table_f_count, table->s->fields);
-      }
-      else
+      sql_print_error(ER(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE),
+                      table->alias, table_f_count, table->s->fields,
+                      table->s->mysql_version, MYSQL_VERSION_ID);
+      DBUG_RETURN(TRUE);
+    }
+    else if (MYSQL_VERSION_ID == table->s->mysql_version)
+    {
+      sql_print_error(ER(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED), table->alias,
+                      table_f_count, table->s->fields);
+      DBUG_RETURN(TRUE);
+    }
+    /*
+      Something has definitely changed, but we're running an older
+      version of MySQL with new system tables.
+      Let's check column definitions. If a column was added at
+      the end of the table, then we don't care much since such change
+      is backward compatible.
+    */
+  }
+  char buffer[STRING_BUFFER_USUAL_SIZE];
+  for (i=0 ; i < table_f_count; i++, table_def++)
+  {
+    String sql_type(buffer, sizeof(buffer), system_charset_info);
+    sql_type.length(0);
+    if (i < table->s->fields)
+    {
+      Field *field= table->field[i];
+
+      if (strncmp(field->field_name, table_def->name.str,
+                  table_def->name.length))
       {
         /*
-          Moving from newer mysql to older one -> let's say not an error but
-          will check the definition afterwards. If a column was added at the
-          end then we don't care much since it's not in the middle.
+          Name changes are not fatal, we use ordinal numbers to access columns.
+          Still this can be a sign of a tampered table, output an error
+          to the error log.
         */
-        error= FALSE;
+        sql_print_error("Incorrect definition of table %s.%s: "
+                        "expected column '%s' at position %d, found '%s'.",
+                        table->s->db.str, table->alias, table_def->name.str,
i,
+                        field->field_name);
       }
-    }
-    /* definitely something has changed */
-    char buffer[255];
-    for (i=0 ; i < table_f_count; i++, table_def++)
-    {      
-      String sql_type(buffer, sizeof(buffer), system_charset_info);
-      sql_type.length(0);
+      field->sql_type(sql_type);
       /*
-        Name changes are not fatal, we use sequence numbers => no problem
-        for us but this can show tampered table or broken table.
-      */
-      if (i < table->s->fields)
-      {
-        Field *field= table->field[i];
-        if (strncmp(field->field_name, table_def->name.str,
-                                       table_def->name.length))
-        {
-          sql_print_error("(%s) Expected field %s at position %d, found %s",
-                          table->alias, table_def->name.str, i,
-                          field->field_name);
-        }
-                        
-        /*
-          If the type does not match than something is really wrong
-          Check up to length - 1. Why?
-          1. datetime -> datetim -> the same
-          2. int(11) -> int(11  -> the same
-          3. set('one','two') -> set('one','two'  
-             so for sets if the same prefix is there it's ok if more are
-             added as part of the set. The same is valid for enum. So a new
-             table running on a old server will be valid.
-        */ 
-        field->sql_type(sql_type);
-        if (strncmp(sql_type.c_ptr_safe(), table_def->type.str,
-                    table_def->type.length - 1))
-        {
-          sql_print_error("(%s) Expected field %s at position %d to have type "
-                          "%s, found %s", table->alias, table_def->name.str,
-                          i, table_def->type.str, sql_type.c_ptr_safe()); 
-          error= TRUE;
-        }
-        else if (table_def->cset.str && !field->has_charset())
-        {
-          sql_print_error("(%s) Expected field %s at position %d to have "
-                          "character set '%s' but found no such", table->alias,
-                          table_def->name.str, i, table_def->cset.str);        
-          error= TRUE;
-        }
-        else if (table_def->cset.str && 
-                 strcmp(field->charset()->csname, table_def->cset.str))
-        {
-          sql_print_error("(%s) Expected field %s at position %d to have "
-                          "character set '%s' but found '%s'", table->alias,
-                          table_def->name.str, i, table_def->cset.str,
-                          field->charset()->csname);
-          error= TRUE;
-        }
-      }
-      else
-      {
-        sql_print_error("(%s) Expected field %s at position %d to have type %s "
-                        " but no field found.", table->alias,
-                        table_def->name.str, i, table_def->type.str);
-        error= TRUE;        
+        Generally, if column types don't match, then something is
+        wrong.
+
+        However, we only compare column definitions up to the
+        length of the original definition, since we consider the
+        following definitions compatible:
+
+        1. DATETIME and DATETIM
+        2. INT(11) and INT(11
+        3. SET('one', 'two') and SET('one', 'two', 'more')
+
+        For SETs or ENUMs, if the same prefix is there it's OK to
+        add more elements - they will get higher ordinal numbers and
+        the new table definition is backward compatible with the
+        original one.
+       */
+      if (strncmp(sql_type.c_ptr_safe(), table_def->type.str,
+                  table_def->type.length - 1))
+      {
+        sql_print_error("Incorrect definition of table %s.%s: "
+                        "expected column '%s' at position %d to have type "
+                        "%s, found type %s.", table->s->db.str, table->alias,
+                        table_def->name.str, i, table_def->type.str,
+                        sql_type.c_ptr_safe());
+        error= TRUE;
+      }
+      else if (table_def->cset.str && !field->has_charset())
+      {
+        sql_print_error("Incorrect definition of table %s.%s: "
+                        "expected the type of column '%s' at position %d "
+                        "to have character set '%s' but the type has no "
+                        "character set.", table->s->db.str, table->alias,
+                        table_def->name.str, i, table_def->cset.str);
+        error= TRUE;
+      }
+      else if (table_def->cset.str &&
+               strcmp(field->charset()->csname, table_def->cset.str))
+      {
+        sql_print_error("Incorrect definition of table %s.%s: "
+                        "expected the type of column '%s' at position %d "
+                        "to have character set '%s' but found "
+                        "character set '%s'.", table->s->db.str, table->alias,
+                        table_def->name.str, i, table_def->cset.str,
+                        field->charset()->csname);
+        error= TRUE;
       }
     }
-    if (!error)
-      *last_create_time= table->file->stats.create_time;
-    else if (!fields_diff_count && error_num)
-      my_error(error_num,MYF(0), table->alias, table_f_count, table->s->fields);
-  }
-  else
-  {
-    DBUG_PRINT("info", ("Table seems ok without thorough checking."));
-    *last_create_time= table->file->stats.create_time;
+    else
+    {
+      sql_print_error("Incorrect definition of table %s.%s: "
+                      "expected column '%s' at position %d to have type %s "
+                      " but the column is not found.",
+                      table->s->db.str, table->alias,
+                      table_def->name.str, i, table_def->type.str);
+      error= TRUE;
+    }
   }
-   
-  DBUG_RETURN(error);  
+  DBUG_RETURN(error);
 }
 
 
Thread
bk commit into 5.1 tree (kostja:1.2565)konstantin5 Apr