List:Commits« Previous MessageNext Message »
From:antony Date:January 19 2006 9:41am
Subject:bk commit into 5.1 tree (acurtis:1.2079)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of antony. When antony 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.2079 06/01/19 01:41:37 acurtis@stripped +14 -0
  Merge xiphis.org:/home/antony/work2/mysql-5.1-plugable
  into  xiphis.org:/home/antony/work2/mysql-5.1-plugable.2

  storage/csv/ha_tina.cc
    1.29 06/01/19 01:41:34 acurtis@stripped +0 -1
    Merge fix

  sql/handler.h
    1.183 06/01/19 01:41:34 acurtis@stripped +0 -0
    Merge fix

  configure.in
    1.332 06/01/19 01:41:34 acurtis@stripped +0 -2
    Merge fix

  storage/example/ha_example.cc
    1.30 06/01/19 01:37:14 acurtis@stripped +0 -0
    Auto merged

  storage/archive/ha_archive.h
    1.38 06/01/19 01:37:14 acurtis@stripped +0 -0
    Auto merged

  storage/archive/ha_archive.cc
    1.73 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  storage/archive/ha_archive.h
    1.35.1.6 06/01/19 01:37:13 acurtis@stripped +0 -0
    Merge rename: sql/ha_archive.h -> storage/archive/ha_archive.h

  storage/archive/ha_archive.cc
    1.70.1.6 06/01/19 01:37:13 acurtis@stripped +0 -0
    Merge rename: sql/ha_archive.cc -> storage/archive/ha_archive.cc

  sql/sql_plugin.cc
    1.11 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  sql/sql_lex.h
    1.212 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  sql/sql_class.h
    1.282 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  sql/sql_class.cc
    1.233 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  sql/mysql_priv.h
    1.371 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  sql/item.h
    1.188 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  sql/handler.cc
    1.213 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

  sql/Makefile.am
    1.129 06/01/19 01:37:13 acurtis@stripped +0 -0
    Auto merged

# 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:	acurtis
# Host:	localhost.(none)
# Root:	/home/antony/work2/mysql-5.1-plugable.2/RESYNC

--- 1.331/configure.in	2006-01-07 15:35:26 -08:00
+++ 1.332/configure.in	2006-01-19 01:41:34 -08:00
@@ -7,19 +7,13 @@
 AC_CANONICAL_SYSTEM
 # The Docs Makefile.am parses this line!
 # remember to also change ndb version below and update version.c in ndb
-AM_INIT_AUTOMAKE(mysql, 5.1.5-alpha)
+AM_INIT_AUTOMAKE(mysql, 5.1.6-alpha)
 AM_CONFIG_HEADER(config.h)
 
 PROTOCOL_VERSION=10
 DOT_FRM_VERSION=6
 # See the libtool docs for information on how to do shared lib versions.
 SHARED_LIB_VERSION=15:0:0
-
-# ndb version
-NDB_VERSION_MAJOR=5
-NDB_VERSION_MINOR=0
-NDB_VERSION_BUILD=19
-NDB_VERSION_STATUS=""
 
 # Set all version vars based on $VERSION. How do we do this more elegant ?
 # Remember that regexps needs to quote [ and ] since this is run through m4

--- 1.128/sql/Makefile.am	2006-01-13 08:04:32 -08:00
+++ 1.129/sql/Makefile.am	2006-01-19 01:37:13 -08:00
@@ -102,8 +102,8 @@
                         event_executor.cc event.cc event_timed.cc \
 			sql_plugin.cc sql_binlog.cc \
 			handlerton.cc sql_tablespace.cc
-EXTRA_mysqld_SOURCES =	ha_innodb.cc ha_berkeley.cc ha_archive.cc \
-			ha_innodb.h  ha_berkeley.h  ha_archive.h \
+EXTRA_mysqld_SOURCES =	ha_innodb.cc ha_berkeley.cc \
+			ha_innodb.h  ha_berkeley.h  \
 			ha_blackhole.cc ha_federated.cc ha_ndbcluster.cc \
 			ha_blackhole.h  ha_federated.h  ha_ndbcluster.h \
 			ha_ndbcluster_binlog.cc ha_ndbcluster_binlog.h \

--- 1.212/sql/handler.cc	2006-01-16 23:37:24 -08:00
+++ 1.213/sql/handler.cc	2006-01-19 01:37:13 -08:00
@@ -44,6 +44,7 @@
 #endif
 
 extern handlerton *sys_table_types[];
+static handlerton *installed_htons[128];
 
 #define BITMAP_STACKBUF_SIZE (128/8)
 
@@ -133,30 +134,8 @@
 }
 
 
-struct plugin_find_dbtype_st
-{
-  enum legacy_db_type db_type;
-  handlerton *hton;
-};
-
-
-static my_bool plugin_find_dbtype(THD *unused, st_plugin_int *plugin,
-                                  void *arg)
-{
-  handlerton *types= (handlerton *) plugin->plugin->info;
-  if (types->db_type == ((struct plugin_find_dbtype_st *)arg)->db_type)
-  {
-    ((struct plugin_find_dbtype_st *)arg)->hton= types;
-    return TRUE;
-  }
-  return FALSE;
-}
-
-
 const char *ha_get_storage_engine(enum legacy_db_type db_type)
 {
-  struct plugin_find_dbtype_st info;
-  
   switch (db_type)
   {
   case DB_TYPE_DEFAULT:
@@ -164,13 +143,10 @@
   case DB_TYPE_UNKNOWN:
     return "UNKNOWN";
   default:
-    info.db_type= db_type;
-
-    if (!plugin_foreach(NULL, plugin_find_dbtype, 
-                        MYSQL_STORAGE_ENGINE_PLUGIN, &info))
-      return "*NONE*";
-
-    return info.hton->name;
+    if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT &&
+        installed_htons[db_type])
+      return installed_htons[db_type]->name;
+    return "*NONE*";
   }
 }
 
@@ -185,8 +161,6 @@
 
 handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
 {
-  struct plugin_find_dbtype_st info;
-
   switch (db_type)
   {
   case DB_TYPE_DEFAULT:
@@ -197,12 +171,9 @@
   case DB_TYPE_UNKNOWN:
     return NULL;
   default:
-    info.db_type= db_type;
-    if (!plugin_foreach(NULL, plugin_find_dbtype, 
-                        MYSQL_STORAGE_ENGINE_PLUGIN, &info))
-      return NULL;
-
-    return info.hton;
+    if (db_type > DB_TYPE_UNKNOWN && db_type < DB_TYPE_DEFAULT)
+      return installed_htons[db_type];
+    return NULL;
   }
 }
 
@@ -387,24 +358,38 @@
 }
 
 
-static void ha_was_inited_ok(handlerton *ht)
+int ha_finalize_handlerton(handlerton *hton)
 {
-  uint tmp= ht->savepoint_offset;
-  ht->savepoint_offset= savepoint_alloc_size;
-  savepoint_alloc_size+= tmp;
-  ht->slot= total_ha++;
-  if (ht->prepare)
-    total_ha_2pc++;
+  DBUG_ENTER("ha_finalize_handlerton");
+
+  if (hton == NULL)
+    DBUG_RETURN(1);
+
+  switch (hton->state)
+  {
+  case SHOW_OPTION_NO:
+  case SHOW_OPTION_DISABLED:
+    break;
+  case SHOW_OPTION_YES:
+    if (hton->panic && hton->panic(HA_PANIC_CLOSE))
+      DBUG_RETURN(1);
+    if (installed_htons[hton->db_type] == hton)
+      installed_htons[hton->db_type]= NULL;
+    break;
+  };
+  DBUG_RETURN(0);
 }
 
 
-int ha_initialize_handlerton(handlerton *hton)
+int ha_initialize_handlerton(char *name, handlerton *hton)
 {
   DBUG_ENTER("ha_initialize_handlerton");
 
   if (hton == NULL)
     DBUG_RETURN(1);
 
+  hton->name= name; /* sanity */
+
   switch (hton->state)
   {
   case SHOW_OPTION_NO:
@@ -412,7 +397,47 @@
   case SHOW_OPTION_YES:
     if (!hton->init || !hton->init())
     {
-      ha_was_inited_ok(hton);
+      uint tmp= hton->savepoint_offset;
+      hton->savepoint_offset= savepoint_alloc_size;
+      savepoint_alloc_size+= tmp;
+      hton->slot= total_ha++;
+      if (hton->prepare)
+        total_ha_2pc++;
+        
+      /* now check the db_type for conflict */
+      if (hton->db_type <= DB_TYPE_UNKNOWN || 
+          hton->db_type >= DB_TYPE_DEFAULT ||
+          installed_htons[hton->db_type])
+      {
+        uint32 tbl[256], crc, idx;
+
+	for (unsigned i = 0; i < 256; ++i)
+	{
+	  ulong reg = i << 24;
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+          reg= (reg << 1) ^ ((reg & 0x80000000) ? 0x04c11db7 : 0);
+	  tbl[i]= reg;
+	}
+
+        for (crc= 0; *name; name++)
+          crc= (crc << 8) ^ tbl[(crc >> 24) ^ *(uchar*)name];
+
+        idx= (crc % (127 - 32)) + 32;
+        while (installed_htons[idx])
+          idx= ((crc= (crc << 8) ^ tbl[crc >> 24]) % (127 - 32)) + 32;
+
+        if (hton->db_type >= DB_TYPE_UNKNOWN)
+          sql_print_warning("Storage engine '%s' has conflicting typecode. "
+                            "Assigning value %d.", hton->name, idx);
+        hton->db_type= (enum legacy_db_type) idx;
+      }
+      installed_htons[hton->db_type]= hton;
       break;
     }
     /* fall through */
@@ -429,7 +454,8 @@
 {
   if (plugin->state == PLUGIN_IS_UNINITIALIZED)
   {
-    ha_initialize_handlerton((handlerton *) plugin->plugin->info);
+    ha_initialize_handlerton(plugin->name.str,
+                             (handlerton *) plugin->plugin->info);
     plugin->state= PLUGIN_IS_READY;
   }
   return FALSE;
@@ -443,6 +469,8 @@
   show_table_alias_st *table_alias;
   total_ha= savepoint_alloc_size= 0;
 
+  bzero(installed_htons, sizeof(installed_htons));
+
   if (ha_init_errors())
     return 1;
 
@@ -1424,6 +1452,12 @@
 /****************************************************************************
 ** General handler functions
 ****************************************************************************/
+
+
+void handler::ha_statistic_increment(ulong SSV::*offset) const
+{
+  statistic_increment(table->in_use->status_var.*offset, &LOCK_status);
+}
 
 /*
   Open database-handler.

--- 1.182/sql/handler.h	2006-01-18 18:56:00 -08:00
+++ 1.183/sql/handler.h	2006-01-19 01:41:34 -08:00
@@ -237,6 +237,7 @@
   DB_TYPE_BLACKHOLE_DB,
   DB_TYPE_PARTITION_DB,
   DB_TYPE_BINLOG,
+  DB_TYPE_FIRST_DYNAMIC=32,
   DB_TYPE_DEFAULT=127 // Must be last
 };
 
@@ -1006,6 +1007,9 @@
   byte *end_of_used_area;     /* End of area that was used by handler */
 } HANDLER_BUFFER;
 
+typedef struct system_status_var SSV;
+
+
 class handler :public Sql_alloc
 {
 #ifdef WITH_PARTITION_STORAGE_ENGINE
@@ -1027,6 +1031,8 @@
   virtual int rnd_init(bool scan) =0;
   virtual int rnd_end() { return 0; }
 
+  void ha_statistic_increment(ulong SSV::*offset) const;
+
 private:
   virtual int reset() { return extra(HA_EXTRA_RESET); }
 public:
@@ -1704,7 +1710,7 @@
  virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
 					 uint table_changes)
  { return COMPATIBLE_DATA_NO; }
-
+  
 private:
 
   /*
@@ -1779,7 +1785,8 @@
 /* basic stuff */
 int ha_init(void);
 int ha_register_builtin_plugins();
-int ha_initialize_handlerton(handlerton *hton);
+int ha_initialize_handlerton(char *name, handlerton *hton);
+int ha_finalize_handlerton(handlerton *hton);
 
 TYPELIB *ha_known_exts(void);
 int ha_panic(enum ha_panic_function flag);

--- 1.187/sql/item.h	2006-01-06 10:34:56 -08:00
+++ 1.188/sql/item.h	2006-01-19 01:37:13 -08:00
@@ -1932,7 +1932,7 @@
   virtual Item *real_item() { return ref; }
 };
 
-
+#ifdef MYSQL_SERVER
 #include "gstream.h"
 #include "spatial.h"
 #include "item_sum.h"
@@ -1945,6 +1945,7 @@
 #include "item_uniq.h"
 #include "item_subselect.h"
 #include "item_xmlfunc.h"
+#endif
 
 class Item_copy_string :public Item
 {

--- 1.370/sql/mysql_priv.h	2006-01-18 18:56:00 -08:00
+++ 1.371/sql/mysql_priv.h	2006-01-19 01:37:13 -08:00
@@ -477,6 +477,10 @@
 }
 #define current_thd _current_thd()
 
+my_bool thd_in_lock_tables(const THD *thd);
+my_bool thd_tablespace_op(const THD *thd);
+const char *thd_proc_info(THD *thd, const char *info);
+
 /*
   External variables
 */
@@ -507,7 +511,9 @@
 class sys_var;
 #include "item.h"
 extern my_decimal decimal_zero;
+#ifdef MYSQL_SERVER
 typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
+#endif
 /* sql_parse.cc */
 void free_items(Item *item);
 void cleanup_items(Item *item);
@@ -545,6 +551,7 @@
 #include "sql_class.h"
 #include "sql_acl.h"
 #include "tztime.h"
+#ifdef MYSQL_SERVER
 #include "opt_range.h"
 
 #ifdef HAVE_QUERY_CACHE
@@ -841,6 +848,8 @@
 Field *
 find_field_in_table_sef(TABLE *table, const char *name);
 
+#endif /* MYSQL_SERVER */
+
 #ifdef HAVE_OPENSSL
 #include <openssl/des.h>
 struct st_des_keyblock
@@ -858,6 +867,7 @@
 bool load_des_key_file(const char *file_name);
 #endif /* HAVE_OPENSSL */
 
+#ifdef MYSQL_SERVER
 /* sql_do.cc */
 bool mysql_do(THD *thd, List<Item> &values);
 
@@ -1169,6 +1179,7 @@
 int key_rec_cmp(void *key_info, byte *a, byte *b);
 
 bool init_errmessage(void);
+#endif /* MYSQL_SERVER */
 void sql_perror(const char *message);
 
 int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
@@ -1191,6 +1202,7 @@
 
 bool fn_format_relative_to_data_home(my_string to, const char *name,
 				     const char *dir, const char *extension);
+#ifdef MYSQL_SERVER
 File open_binlog(IO_CACHE *log, const char *log_file_name,
                  const char **errmsg);
 
@@ -1739,4 +1751,5 @@
 #define check_stack_overrun(A, B, C) 0
 #endif
 
+#endif /* MYSQL_SERVER */
 #endif /* MYSQL_CLIENT */

--- 1.232/sql/sql_class.cc	2006-01-07 15:35:26 -08:00
+++ 1.233/sql/sql_class.cc	2006-01-19 01:37:13 -08:00
@@ -475,7 +475,12 @@
 
 
 /*
-  Add to one status variable another status variable
+  Add all status variables to another status variable array
+
+  SYNOPSIS
+   add_to_status()
+   to_var       add to this array
+   from_var     from this array
 
   NOTES
     This function assumes that all variables are long/ulong.
@@ -673,6 +678,9 @@
   charset_is_collation_connection= 
     !String::needs_conversion(0,charset(),variables.collation_connection,
                               &not_used);
+  charset_is_character_set_filesystem= 
+    !String::needs_conversion(0, charset(),
+                              variables.character_set_filesystem, &not_used);
 }
 
 
@@ -2193,7 +2201,8 @@
                                        MY_BITMAP const* cols,
                                        my_size_t colcnt,
                                        my_size_t needed,
-                                       bool is_transactional)
+                                       bool is_transactional,
+				       RowsEventT *hint __attribute__((unused)))
 {
   /* Pre-conditions */
   DBUG_ASSERT(table->s->table_map_id != ULONG_MAX);
@@ -2258,17 +2267,19 @@
   compiling option.
 */
 template Rows_log_event*
-THD::binlog_prepare_pending_rows_event<Write_rows_log_event>
-(TABLE*, uint32, MY_BITMAP const*, my_size_t colcnt, size_t, bool);
+THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*,
+				       my_size_t, my_size_t, bool,
+				       Write_rows_log_event*);
 
 template Rows_log_event*
-THD::binlog_prepare_pending_rows_event<Delete_rows_log_event>
-(TABLE*, uint32, MY_BITMAP const*, my_size_t colcnt, size_t, bool);
+THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*,
+				       my_size_t colcnt, my_size_t, bool,
+				       Delete_rows_log_event *);
 
 template Rows_log_event* 
-THD::binlog_prepare_pending_rows_event<Update_rows_log_event>
-(TABLE*, uint32, MY_BITMAP const*, my_size_t colcnt, size_t, bool);
-
+THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*,
+				       my_size_t colcnt, my_size_t, bool,
+				       Update_rows_log_event *);
 static char const* 
 field_type_name(enum_field_types type) 
 {
@@ -2342,7 +2353,7 @@
   for (uint *ptr= beg ; ptr != end ; ++ptr)
   {
     Field_blob* const blob= (Field_blob*) table->field[*ptr];
-    length+= blob->get_length(data + blob->offset()) + 2;
+    length+= blob->get_length((const char *) (data + blob->offset())) + 2;
   }
 
   return length;
@@ -2361,7 +2372,7 @@
   for (int i= 0 ; field ; i++, p_field++, field= *p_field)
   {
     if (bitmap_is_set(cols,i))
-      ptr= field->pack(ptr, field->ptr + offset);
+      ptr= (byte*)field->pack((char *) ptr, field->ptr + offset);
   }
 
   /*
@@ -2394,25 +2405,26 @@
     if (!table->s->blob_fields)
     {
       /* multiply max_len by 2 so it can be used for update_row as well */
-      table->write_row_record= alloc_root(&table->mem_root, 2*max_len);
+      table->write_row_record= (byte *) alloc_root(&table->mem_root, 2*max_len);
       if (!table->write_row_record)
         return HA_ERR_OUT_OF_MEM;
       row_data= table->write_row_record;
     }
-    else if (unlikely(!(row_data= my_malloc(max_len, MYF(MY_WME)))))
+    else if (unlikely(!(row_data= (byte *) my_malloc(max_len, MYF(MY_WME)))))
       return HA_ERR_OUT_OF_MEM;
   }
   my_size_t const len= pack_row(table, cols, row_data, record);
 
-  Rows_log_event* const
-    ev= binlog_prepare_pending_rows_event<Write_rows_log_event>
-    (table, server_id, cols, colcnt, len, is_trans);
+  Rows_log_event* const ev=
+    binlog_prepare_pending_rows_event(table, server_id, cols, colcnt,
+				      len, is_trans,
+				      static_cast<Write_rows_log_event*>(0));
 
   /* add_row_data copies row_data to internal buffer */
   error= likely(ev != 0) ? ev->add_row_data(row_data,len) : HA_ERR_OUT_OF_MEM ;
 
   if (table->write_row_record == 0)
-    my_free(row_data, MYF(MY_WME));
+    my_free((gptr) row_data, MYF(MY_WME));
 
   return error;
 }
@@ -2437,7 +2449,7 @@
   }
   else
   {
-    if (unlikely(!(row_data= my_multi_malloc(MYF(MY_WME),
+    if (unlikely(!(row_data= (byte*)my_multi_malloc(MYF(MY_WME),
                                              &before_row, before_maxlen,
                                              &after_row, after_maxlen,
                                              NULL))))
@@ -2449,9 +2461,10 @@
   my_size_t const after_size= pack_row(table, cols, after_row, 
                                        after_record);
   
-  Rows_log_event* const
-    ev= binlog_prepare_pending_rows_event<Update_rows_log_event>
-    (table, server_id, cols, colcnt, before_size + after_size, is_trans);
+  Rows_log_event* const ev=
+    binlog_prepare_pending_rows_event(table, server_id, cols, colcnt,
+				      before_size + after_size, is_trans,
+				      static_cast<Update_rows_log_event*>(0));
 
   error= (unlikely(!ev)) || ev->add_row_data(before_row, before_size) ||
     ev->add_row_data(after_row, after_size);
@@ -2459,7 +2472,7 @@
   if (!table->write_row_record)
   {
     /* add_row_data copies row_data to internal buffer */
-    my_free(row_data, MYF(MY_WME));
+    my_free((gptr)row_data, MYF(MY_WME));
   }
   
   return error;
@@ -2478,19 +2491,20 @@
   bool error= 0;
   my_size_t const max_len= max_row_length(table, record);
   byte *row_data= table->write_row_record;
-  if (!row_data && unlikely(!(row_data= my_malloc(max_len, MYF(MY_WME)))))
+  if (!row_data && unlikely(!(row_data= (byte*)my_malloc(max_len, MYF(MY_WME)))))
     return HA_ERR_OUT_OF_MEM;
   my_size_t const len= pack_row(table, cols, row_data, record);
 
-  Rows_log_event* const
-    ev= binlog_prepare_pending_rows_event<Delete_rows_log_event>
-    (table, server_id, cols, colcnt, len, is_trans);
+  Rows_log_event* const ev=
+    binlog_prepare_pending_rows_event(table, server_id, cols, colcnt,
+				      len, is_trans,
+				      static_cast<Delete_rows_log_event*>(0));
 
   error= (unlikely(!ev)) || ev->add_row_data(row_data, len);
 
   /* add_row_data copies row_data */
   if (table->write_row_record == 0)
-    my_free(row_data, MYF(MY_WME));
+    my_free((gptr)row_data, MYF(MY_WME));
 
   return error;
 }

--- 1.281/sql/sql_class.h	2006-01-07 15:35:26 -08:00
+++ 1.282/sql/sql_class.h	2006-01-19 01:37:13 -08:00
@@ -259,6 +259,7 @@
   my_bool old_passwords;
 
   /* Only charset part of these variables is sensible */
+  CHARSET_INFO  *character_set_filesystem;
   CHARSET_INFO  *character_set_client;
   CHARSET_INFO  *character_set_results;
 
@@ -924,7 +925,8 @@
                                       MY_BITMAP const* cols,
                                       my_size_t colcnt,
                                       my_size_t needed,
-                                      bool is_transactional);
+                                      bool is_transactional,
+				      RowsEventT* hint);
   Rows_log_event* binlog_get_pending_rows_event() const;
   void            binlog_set_pending_rows_event(Rows_log_event* ev);
   int             binlog_setup_trx_data();
@@ -1127,6 +1129,7 @@
   bool       query_error, bootstrap, cleanup_done;
   bool	     tmp_table_used;
   bool	     charset_is_system_charset, charset_is_collation_connection;
+  bool       charset_is_character_set_filesystem;
   bool       enable_slow_log;   /* enable slow log for current statement */
   bool	     no_trans_update, abort_on_warning;
   bool 	     got_warning;       /* Set on call to push_warning() */
@@ -1384,6 +1387,7 @@
 #define SYSTEM_THREAD_DELAYED_INSERT 1
 #define SYSTEM_THREAD_SLAVE_IO 2
 #define SYSTEM_THREAD_SLAVE_SQL 4
+#define SYSTEM_THREAD_NDBCLUSTER_BINLOG 8
 
 /*
   Used to hold information about file and file structure in exchainge 

--- 1.211/sql/sql_lex.h	2006-01-16 23:37:27 -08:00
+++ 1.212/sql/sql_lex.h	2006-01-19 01:37:13 -08:00
@@ -29,6 +29,7 @@
 class partition_info;
 class event_timed;
 
+#ifdef MYSQL_SERVER
 /*
   The following hack is needed because mysql_yacc.cc does not define
   YYSTYPE before including this file
@@ -43,6 +44,7 @@
 #include "sql_yacc.h"
 #define LEX_YYSTYPE YYSTYPE *
 #endif
+#endif
 
 /*
   When a command is added here, be sure it's also added in mysqld.cc
@@ -115,6 +117,8 @@
 */
 #define DESCRIBE_PARTITIONS	4
 
+#ifdef MYSQL_SERVER
+
 enum enum_sp_suid_behaviour
 {
   SP_IS_DEFAULT_SUID= 0,
@@ -1109,3 +1113,5 @@
 extern pthread_key(LEX*,THR_LEX);
 
 #define current_lex (current_thd->lex)
+
+#endif

--- 1.70.1.5/sql/ha_archive.cc	2006-01-16 23:37:21 -08:00
+++ 1.73/storage/archive/ha_archive.cc	2006-01-19 01:37:13 -08:00
@@ -19,10 +19,15 @@
 #endif
 
 #include "mysql_priv.h"
+#include <myisam.h>
 
 #include "ha_archive.h"
 #include <my_dir.h>
 
+#ifdef MYSQL_PLUGIN
+#include <plugin.h>
+#endif
+
 /*
   First, if you want to understand storage engines you should look at 
   ha_example.cc and ha_example.h. 
@@ -148,7 +153,7 @@
   SHOW_OPTION_YES,
   "Archive storage engine", 
   DB_TYPE_ARCHIVE_DB,
-  archive_db_init,
+  (bool (*)())archive_db_init,
   0,       /* slot */
   0,       /* savepoint size. */
   NULL,    /* close_connection */
@@ -204,9 +209,11 @@
     TRUE        Error
 */
 
-bool archive_db_init()
+int archive_db_init()
 {
   DBUG_ENTER("archive_db_init");
+  if (archive_inited)
+    DBUG_RETURN(FALSE);
   if (pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST))
     goto error;
   if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
@@ -220,7 +227,6 @@
     DBUG_RETURN(FALSE);
   }
 error:
-  have_archive_db= SHOW_OPTION_DISABLED;	// If we couldn't use handler
   DBUG_RETURN(TRUE);
 }
 
@@ -228,14 +234,14 @@
   Release the archive handler.
 
   SYNOPSIS
-    archive_db_end()
+    archive_db_done()
     void
 
   RETURN
     FALSE       OK
 */
 
-int archive_db_end(ha_panic_function type)
+int archive_db_done()
 {
   if (archive_inited)
   {
@@ -246,6 +252,12 @@
   return 0;
 }
 
+
+int archive_db_end(ha_panic_function type)
+{
+  return archive_db_done();
+}
+
 ha_archive::ha_archive(TABLE_SHARE *table_arg)
   :handler(&archive_hton, table_arg), delayed_insert(0), bulk_insert(0)
 {
@@ -716,7 +728,7 @@
   if (share->crashed)
       DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
 
-  statistic_increment(table->in_use->status_var.ha_write_count, &LOCK_status);
+  ha_statistic_increment(&SSV::ha_write_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
   pthread_mutex_lock(&share->mutex);
@@ -1028,8 +1040,7 @@
     DBUG_RETURN(HA_ERR_END_OF_FILE);
   scan_rows--;
 
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   current_position= aztell(&archive);
   rc= get_row(&archive, buf);
 
@@ -1065,8 +1076,7 @@
 int ha_archive::rnd_pos(byte * buf, byte *pos)
 {
   DBUG_ENTER("ha_archive::rnd_pos");
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   current_position= (my_off_t)my_get_ptr(pos, ref_length);
   (void)azseek(&archive, current_position, SEEK_SET);
 
@@ -1225,8 +1235,8 @@
     */
 
     if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
-         lock_type <= TL_WRITE) && !thd->in_lock_tables
-        && !thd->tablespace_op)
+         lock_type <= TL_WRITE) && !thd_in_lock_tables(thd)
+        && !thd_tablespace_op(thd))
       lock_type = TL_WRITE_ALLOW_WRITE;
 
     /* 
@@ -1237,7 +1247,7 @@
       concurrent inserts to t2. 
     */
 
-    if (lock_type == TL_READ_NO_INSERT && !thd->in_lock_tables) 
+    if (lock_type == TL_READ_NO_INSERT && !thd_in_lock_tables(thd)) 
       lock_type = TL_READ;
 
     lock.type=lock_type;
@@ -1346,11 +1356,11 @@
 {
   int rc= 0;
   byte *buf; 
-  const char *old_proc_info=thd->proc_info;
+  const char *old_proc_info;
   ha_rows count= share->rows_recorded;
   DBUG_ENTER("ha_archive::check");
 
-  thd->proc_info= "Checking table";
+  old_proc_info= thd_proc_info(thd, "Checking table");
   /* Flush any waiting data */
   azflush(&(share->archive_write), Z_SYNC_FLUSH);
 
@@ -1374,7 +1384,7 @@
 
   my_free((char*)buf, MYF(0));
 
-  thd->proc_info= old_proc_info;
+  thd_proc_info(thd, old_proc_info);
 
   if ((rc && rc != HA_ERR_END_OF_FILE) || count)  
   {
@@ -1406,3 +1416,19 @@
     DBUG_RETURN(HA_ADMIN_OK);
   }
 }
+
+
+#ifdef MYSQL_PLUGIN
+mysql_declare_plugin
+{
+  MYSQL_STORAGE_ENGINE_PLUGIN,
+  &archive_hton,
+  archive_hton.name,
+  "Brian Aker, MySQL AB",
+  "Archive Storage Engine",
+  archive_db_init, /* Plugin Init */
+  archive_db_done, /* Plugin Deinit */
+  0x0100 /* 1.0 */,
+}
+mysql_declare_plugin_end;
+#endif

--- 1.35.1.5/sql/ha_archive.h	2006-01-11 22:58:57 -08:00
+++ 1.38/storage/archive/ha_archive.h	2006-01-19 01:37:14 -08:00
@@ -19,7 +19,7 @@
 #endif
 
 #include <zlib.h>
-#include "../storage/archive/azlib.h"
+#include "azlib.h"
 
 /*
   Please read ha_archive.cc first. If you are looking for more general
@@ -125,6 +125,6 @@
   bool check_and_repair(THD *thd);
 };
 
-bool archive_db_init(void);
+int archive_db_init(void);
 int archive_db_end(ha_panic_function type);
 

--- 1.28/storage/csv/ha_tina.cc	2006-01-07 15:35:26 -08:00
+++ 1.29/storage/csv/ha_tina.cc	2006-01-19 01:41:34 -08:00
@@ -90,6 +90,9 @@
   NULL,    /* Start Consistent Snapshot */
   NULL,    /* Flush logs */
   NULL,    /* Show status */
+  NULL,    /* Partition flags */
+  NULL,    /* Alter table flags */
+  NULL,    /* Alter Tablespace */
   HTON_CAN_RECREATE
 };
 
@@ -196,8 +199,16 @@
   char *tmp_name;
   uint length;
 
+  if (!tina_init)
+     tina_init_func();
+
   pthread_mutex_lock(&tina_mutex);
   length=(uint) strlen(table_name);
+
+  /*
+    If share is not present in the hash, create a new share and
+    initialize its members.
+  */
   if (!(share=(TINA_SHARE*) hash_search(&tina_open_tables,
                                         (byte*) table_name,
                                         length)))
@@ -213,6 +224,7 @@
     }
 
     share->use_count= 0;
+    share->is_log_table= FALSE;
     share->table_name_length= length;
     share->table_name= tmp_name;
     strmov(share->table_name, table_name);
@@ -237,6 +249,9 @@
     share->mapped_file= NULL; // We don't know the state as we just allocated it
     if (get_mmap(share, 0) > 0)
       goto error3;
+
+    /* init file length value used by readers */
+    share->saved_data_file_length= share->file_stat.st_size;
   }
   share->use_count++;
   pthread_mutex_unlock(&tina_mutex);
@@ -310,14 +325,16 @@
     These definitions are found in handler.h
     They are not probably completely right.
   */
-  current_position(0), next_position(0), chain_alloced(0),
-  chain_size(DEFAULT_CHAIN_LENGTH), records_is_known(0)
+  current_position(0), next_position(0), local_saved_data_file_length(0),
+  chain_alloced(0), chain_size(DEFAULT_CHAIN_LENGTH),
+  records_is_known(0)
 {
   /* Set our original buffers from pre-allocated memory */
   buffer.set(byte_buffer, IO_SIZE, system_charset_info);
   chain= chain_buffer;
 }
 
+
 /*
   Encode a buffer into the quoted format.
 */
@@ -426,13 +443,18 @@
 */
 int ha_tina::find_current_row(byte *buf)
 {
-  byte *mapped_ptr= (byte *)share->mapped_file + current_position;
+  byte *mapped_ptr;
   byte *end_ptr;
   DBUG_ENTER("ha_tina::find_current_row");
 
-  /* EOF should be counted as new line */
+  mapped_ptr= (byte *)share->mapped_file + current_position;
+
+  /*
+    We do not read further then local_saved_data_file_length in order
+    not to conflict with undergoing concurrent insert.
+  */
   if ((end_ptr=  find_eoln(share->mapped_file, current_position,
-                           share->file_stat.st_size)) == 0)
+                           local_saved_data_file_length)) == 0)
     DBUG_RETURN(HA_ERR_END_OF_FILE);
 
   for (Field **field=table->field ; *field ; field++)
@@ -490,6 +512,112 @@
   return ha_tina_exts;
 }
 
+/*
+  Three functions below are needed to enable concurrent insert functionality
+  for CSV engine. For more details see mysys/thr_lock.c
+*/
+
+void tina_get_status(void* param, int concurrent_insert)
+{
+  ha_tina *tina= (ha_tina*) param;
+  tina->get_status();
+}
+
+void tina_update_status(void* param)
+{
+  ha_tina *tina= (ha_tina*) param;
+  tina->update_status();
+}
+
+/* this should exist and return 0 for concurrent insert to work */
+my_bool tina_check_status(void* param)
+{
+  return 0;
+}
+
+/*
+  Save the state of the table
+
+  SYNOPSIS
+    get_status()
+
+  DESCRIPTION
+    This function is used to retrieve the file length. During the lock
+    phase of concurrent insert. For more details see comment to
+    ha_tina::update_status below.
+*/
+
+void ha_tina::get_status()
+{
+  if (share->is_log_table)
+  {
+    /*
+      We have to use mutex to follow pthreads memory visibility
+      rules for share->saved_data_file_length
+    */
+    pthread_mutex_lock(&share->mutex);
+    local_saved_data_file_length= share->saved_data_file_length;
+    pthread_mutex_unlock(&share->mutex);
+    return;
+  }
+  local_saved_data_file_length= share->saved_data_file_length;
+}
+
+
+/*
+  Correct the state of the table. Called by unlock routines
+  before the write lock is released.
+
+  SYNOPSIS
+    update_status()
+
+  DESCRIPTION
+    When we employ concurrent insert lock, we save current length of the file
+    during the lock phase. We do not read further saved value, as we don't
+    want to interfere with undergoing concurrent insert. Writers update file
+    length info during unlock with update_status().
+
+  NOTE
+    For log tables concurrent insert works different. The reason is that
+    log tables are always opened and locked. And as they do not unlock
+    tables, the file length after writes should be updated in a different
+    way. For this purpose we need is_log_table flag. When this flag is set
+    we call update_status() explicitly after each row write.
+*/
+
+void ha_tina::update_status()
+{
+  /* correct local_saved_data_file_length for writers */
+  share->saved_data_file_length= share->file_stat.st_size;
+}
+
+
+bool ha_tina::check_if_locking_is_allowed(THD *thd, TABLE *table, uint count)
+{
+  /*
+    Deny locking of the log tables, which is incompatible with
+    concurrent insert. Unless called from a logger THD:
+    general_log_thd or slow_log_thd.
+  */
+  if (table->s->log_table &&
+      thd->lex->sql_command != SQLCOM_TRUNCATE &&
+      !(thd->lex->sql_command == SQLCOM_FLUSH &&
+        thd->lex->type & REFRESH_LOG) &&
+      (thd != logger.get_general_log_thd()) &&
+      (thd != logger.get_slow_log_thd()) &&
+      (table->reginfo.lock_type >= TL_READ_NO_INSERT))
+  {
+    /*
+      The check  >= TL_READ_NO_INSERT denies all write locks
+      plus the only read lock (TL_READ_NO_INSERT itself)
+    */
+    table->reginfo.lock_type == TL_READ_NO_INSERT ?
+      my_error(ER_CANT_READ_LOCK_LOG_TABLE, MYF(0)) :
+        my_error(ER_CANT_WRITE_LOCK_LOG_TABLE, MYF(0));
+    return FALSE;
+  }
+  return TRUE;
+}
 
 /*
   Open a database file. Keep in mind that tables are caches, so
@@ -502,9 +630,19 @@
 
   if (!(share= get_share(name, table)))
     DBUG_RETURN(1);
-  thr_lock_data_init(&share->lock,&lock,NULL);
+
+  /*
+    Init locking. Pass handler object to the locking routines,
+    so that they could save/update local_saved_data_file_length value
+    during locking. This is needed to enable concurrent inserts.
+  */
+  thr_lock_data_init(&share->lock, &lock, (void*) this);
   ref_length=sizeof(off_t);
 
+  share->lock.get_status= tina_get_status;
+  share->lock.update_status= tina_update_status;
+  share->lock.check_status= tina_check_status;
+
   DBUG_RETURN(0);
 }
 
@@ -548,6 +686,18 @@
   */
   if (get_mmap(share, 0) > 0)
     DBUG_RETURN(-1);
+
+  /* update local copy of the max position to see our own changes */
+  local_saved_data_file_length= share->file_stat.st_size;
+
+  /* update status for the log tables */
+  if (share->is_log_table)
+  {
+    pthread_mutex_lock(&share->mutex);
+    update_status();
+    pthread_mutex_unlock(&share->mutex);
+  }
+
   records++;
   DBUG_RETURN(0);
 }
@@ -578,6 +728,13 @@
 
   if (my_write(share->data_file, buffer.ptr(), size, MYF(MY_WME | MY_NABP)))
     DBUG_RETURN(-1);
+
+  /* UPDATE should never happen on the log tables */
+  DBUG_ASSERT(!share->is_log_table);
+
+  /* update local copy of the max position to see our own changes */
+  local_saved_data_file_length= share->file_stat.st_size;
+
   DBUG_RETURN(0);
 }
 
@@ -601,6 +758,9 @@
 
   --records;
 
+  /* DELETE should never happen on the log table */
+  DBUG_ASSERT(!share->is_log_table);
+
   DBUG_RETURN(0);
 }
 
@@ -806,6 +966,12 @@
 int ha_tina::extra(enum ha_extra_function operation)
 {
   DBUG_ENTER("ha_tina::extra");
+ if (operation == HA_EXTRA_MARK_AS_LOG_TABLE)
+ {
+   pthread_mutex_lock(&share->mutex);
+   share->is_log_table= TRUE;
+   pthread_mutex_unlock(&share->mutex);
+ }
   DBUG_RETURN(0);
 }
 

--- 1.29/storage/example/ha_example.cc	2006-01-07 15:35:26 -08:00
+++ 1.30/storage/example/ha_example.cc	2006-01-19 01:37:14 -08:00
@@ -105,6 +105,9 @@
   NULL,    /* Start Consistent Snapshot */
   NULL,    /* Flush logs */
   NULL,    /* Show status */
+  NULL,    /* Partition flags */
+  NULL,    /* Alter table flags */
+  NULL,    /* Alter tablespace */
   HTON_CAN_RECREATE
 };
 

--- 1.10/sql/sql_plugin.cc	2006-01-07 05:49:42 -08:00
+++ 1.11/sql/sql_plugin.cc	2006-01-19 01:37:13 -08:00
@@ -517,7 +517,8 @@
   switch (plugin->plugin->type)
   {
   case MYSQL_STORAGE_ENGINE_PLUGIN:
-    if (ha_initialize_handlerton((handlerton*) plugin->plugin->info))
+    if (ha_initialize_handlerton(plugin->name.str,
+                                 (handlerton*) plugin->plugin->info))
     {
       sql_print_error("Plugin '%s' handlerton init returned error.",
                       plugin->name.str);
@@ -535,6 +536,44 @@
   DBUG_RETURN(1);
 }
 
+static int plugin_finalize(struct st_plugin_int *plugin)
+{
+  int rc;
+  DBUG_ENTER("plugin_finalize");
+  
+  if (plugin->plugin->deinit)
+  {
+    if ((rc= plugin->plugin->deinit()))
+    {
+      sql_print_error("Plugin '%s' deinit function returned error rc=%d",
+                      plugin->name.str, rc);
+      DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error rc=%d",
+                             plugin->name.str, rc))
+      goto err;
+    }
+  }
+  
+  switch (plugin->plugin->type)
+  {
+  case MYSQL_STORAGE_ENGINE_PLUGIN:
+    if (ha_finalize_handlerton((handlerton*) plugin->plugin->info))
+    {
+      sql_print_error("Plugin '%s' handlerton deinit returned error.",
+                      plugin->name.str);
+      DBUG_PRINT("warning", ("Plugin '%s' handlerton deinit returned error.",
+                             plugin->name.str))
+      goto err;
+    }
+    break;
+  default:
+    break;
+  }
+
+  DBUG_RETURN(0);
+err:
+  DBUG_RETURN(1);
+}
+
 static void plugin_call_initializer(void)
 {
   uint i;
@@ -818,7 +857,7 @@
     goto err;
   }
 
-  if (plugin->ref_count)
+  if (plugin->ref_count || plugin_finalize(plugin))
   {
     plugin->state= PLUGIN_IS_DELETED;
     push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
@@ -826,8 +865,6 @@
   }
   else
   {
-    if (plugin->plugin->deinit)
-      plugin->plugin->deinit();
     plugin_del(name);
   }
 
Thread
bk commit into 5.1 tree (acurtis:1.2079)antony19 Jan