List:Commits« Previous MessageNext Message »
From:tim Date:June 11 2007 8:57pm
Subject:bk commit into 5.1 tree (tsmith:1.2538)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tsmith. When tsmith 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-11 14:57:45-06:00, tsmith@stripped +13 -0
  WL#3914: Additonal accessors required to compile InnoDB as a plugin storage engine
  
  Add more accessors to MySQL internals in mysql/plugin.h, for storage
  engine plugins.
  
  Add some accessors specific to the InnoDB storage engine, to allow
  InnoDB to be compiled as a plugin (without MYSQL_SERVER).  InnoDB
  has additional requirements, due to its foreign key support, etc.

  include/m_string.h@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +6 -6
    Add structure tag to LEX_STRING definition, so that it can be referred
    to by forward declarations.  Allow struct st_mysql_lex_string to be
    defined here, or in mysql/plugin.h.

  include/my_global.h@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +11 -0
    Define INNODB_COMPATIBILITY_HOOKS unconditionally; it brackets
    some definitions needed for the InnoDB storage engine plugin
    which do not belong in our general plugin interface.

  include/mysql/plugin.h@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +122 -0
    Additional accessors for MySQL internals:
    
    - Full definition of MYSQL_LEX_STRING (identical to LEX_STRING from
      m_string.h)
    - Full definition of MYSQL_XID (binary compatible with XID from
      handler.h)
    - mysql_tmpfile(), creates a temporary file in mysqld's tmpdir
    - thd_killed(), to check killed state of connection
    - thd_alloc() and similar allocation functions
    - thd_get_xid(), to get XID of connection's transaction
    - mysql_query_cache_invalidate4, to invalidate a table's query cache entries

  sql/handler.h@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +9 -1
    Use MYSQL_XIDDATASIZE definition from mysql/plugin.h, to avoid redundant definitions

  sql/log.cc@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +23 -0
    Add definitions for two InnoDB compatibility hooks:
    - mysql_bin_log_file(), to get log filename
    - mysql_bin_log_file_pos, to get position in file
    
    These are defined only if INNODB_COMPATIBILITY_HOOKS is defined;
    they are needed by the InnoDB plugin, but aren't part of the general
    plugin interface.  They are declared in ha_innodb.h for InnoDB's
    use.

  sql/mysql_priv.h@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +47 -9
    Expose some server internals when INNODB_COMPATIBILITY_HOOKS is
    defined, so that InnoDB can be built as a plugin when MYSQL_SERVER
    is not defined.
    
    Move make_lex_string inside THD class.

  sql/sql_cache.cc@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +12 -0
    Add definiton of mysql_query_cache_invalidate4(), a part of the
    plugin API (mysql/plugin.h).

  sql/sql_class.cc@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +112 -0
    Add definitions for several accessor functions which form part
    of the plugin API (mysql/plugin.h):
    - mysql_tmpfile()
    - thd_alloc() and friends
    - thd_make_lex_string()
    - thd_get_xid()
    
    Add definitons for two accessor functions which InnoDB requires,
    but which are not part of the plugin interface:
    - thd_charset()
    - thd_query()
    
    Move definition of make_lex_string() from sql_show.cc into THD class

  sql/sql_class.h@stripped, 2007-06-11 14:57:40-06:00, tsmith@stripped +4 -6
    Remove LEX_STRING_make(), and move make_lex_string() from sql_show.cc inside THD class.

  sql/sql_parse.cc@stripped, 2007-06-11 14:57:41-06:00, tsmith@stripped +3 -3
    Use thd->make_lex_string() instead of thd->LEX_STRING_make()

  sql/sql_show.cc@stripped, 2007-06-11 14:57:41-06:00, tsmith@stripped +4 -18
    Move make_lex_string() inside THD class

  storage/innobase/handler/ha_innodb.cc@stripped, 2007-06-11 14:57:41-06:00, tsmith@stripped +20 -31
    Use mysql_tmpfile() function inside innobase_mysql_tmpfile().
    
    Call thd_make_lex_string() instead of make_lex_string().

  storage/innobase/handler/ha_innodb.h@stripped, 2007-06-11 14:57:41-06:00, tsmith@stripped +23 -0
    Declare some accessor functions which are required for InnoDB
    to be built as a plugin, but which do not belong in the general
    plugin interface:
    - thd_charset()
    - thd_query()
    - mysql_bin_log_file_name()
    - mysql_bin_log_file_pos()

# 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:	tsmith
# Host:	siva.hindu.god
# Root:	/home/tsmith/m/bk/maint/inno-thd-patch/51

--- 1.49/include/m_string.h	2007-05-31 02:21:16 -06:00
+++ 1.50/include/m_string.h	2007-06-11 14:57:40 -06:00
@@ -246,17 +246,17 @@ extern int my_snprintf(char *to, size_t 
 
 /*
   LEX_STRING -- a pair of a C-string and its length.
-
-  NOTE: this exactly form of declaration is required for some C-compilers
-  (for one, Sun C 5.7 2005/01/07). Unfortunatelt with such declaration
-  LEX_STRING can not be forward declared.
 */
 
-typedef struct
+#ifndef _my_plugin_h
+/* This definition must match the one given in mysql/plugin.h */
+struct st_mysql_lex_string
 {
   char *str;
   uint length;
-} LEX_STRING;
+};
+#endif /* _my_plugin_h */
+typedef struct st_mysql_lex_string LEX_STRING;
 
 #define STRING_WITH_LEN(X) (X), ((uint) (sizeof(X) - 1))
 #define C_STRING_WITH_LEN(X) ((char *) (X)), ((uint) (sizeof(X) - 1))

--- 1.258/sql/handler.h	2007-04-16 10:16:12 -06:00
+++ 1.259/sql/handler.h	2007-06-11 14:57:40 -06:00
@@ -315,13 +315,21 @@ typedef ulonglong my_xid; // this line i
 #define MYSQL_XID_OFFSET (MYSQL_XID_PREFIX_LEN+sizeof(server_id))
 #define MYSQL_XID_GTRID_LEN (MYSQL_XID_OFFSET+sizeof(my_xid))
 
-#define XIDDATASIZE 128
+#define XIDDATASIZE MYSQL_XIDDATASIZE
 #define MAXGTRIDSIZE 64
 #define MAXBQUALSIZE 64
 
 #define COMPATIBLE_DATA_YES 0
 #define COMPATIBLE_DATA_NO  1
 
+/**
+  struct xid_t is binary compatible with the XID structure as
+  in the X/Open CAE Specification, Distributed Transaction Processing:
+  The XA Specification, X/Open Company Ltd., 1991.
+  http://www.opengroup.org/bookstore/catalog/c193.htm
+
+  @see MYSQL_XID in mysql/plugin.h
+*/
 struct xid_t {
   long formatID;
   long gtrid_length;

--- 1.281/sql/log.cc	2007-05-17 14:21:26 -06:00
+++ 1.282/sql/log.cc	2007-06-11 14:57:40 -06:00
@@ -5114,6 +5114,29 @@ err1:
   return 1;
 }
 
+
+#ifdef INNODB_COMPATIBILITY_HOOKS
+/**
+  Get the file name of the MySQL binlog.
+  @return the name of the binlog file
+*/
+extern "C"
+const char* mysql_bin_log_file_name(void)
+{
+  return mysql_bin_log.get_log_fname();
+}
+/**
+  Get the current position of the MySQL binlog.
+  @return byte offset from the beginning of the binlog
+*/
+extern "C"
+ulonglong mysql_bin_log_file_pos(void)
+{
+  return (ulonglong) mysql_bin_log.get_log_file()->pos_in_file;
+}
+#endif /* INNODB_COMPATIBILITY_HOOKS */
+
+
 struct st_mysql_storage_engine binlog_storage_engine=
 { MYSQL_HANDLERTON_INTERFACE_VERSION };
 

--- 1.514/sql/mysql_priv.h	2007-05-28 05:36:13 -06:00
+++ 1.515/sql/mysql_priv.h	2007-06-11 14:57:40 -06:00
@@ -1093,7 +1093,11 @@ bool mysqld_show_open_tables(THD *thd,co
 bool mysqld_show_logs(THD *thd);
 void append_identifier(THD *thd, String *packet, const char *name,
 		       uint length);
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
 int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
 void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
 int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
 bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
@@ -1122,9 +1126,6 @@ void reset_status_vars();
 /* information schema */
 extern LEX_STRING INFORMATION_SCHEMA_NAME;
 extern const LEX_STRING partition_keywords[];
-LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
-                            const char* str, uint length,
-                            bool allocate_lex_string);
 ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
 ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
 int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
@@ -1605,8 +1606,13 @@ extern int creating_table;    // How man
 */
 
 extern time_t server_start_time;
-extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
-	    mysql_real_data_home[], *opt_mysql_tmpdir, mysql_charsets_dir[],
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
+extern char *mysql_data_home, server_version[SERVER_VERSION_LENGTH],
+	    mysql_real_data_home[];
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
+extern char *opt_mysql_tmpdir, mysql_charsets_dir[],
             def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
 #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
 extern MY_TMPDIR mysql_tmpdir_list;
@@ -1623,8 +1629,13 @@ extern Gt_creator gt_creator;
 extern Lt_creator lt_creator;
 extern Ge_creator ge_creator;
 extern Le_creator le_creator;
-extern char language[FN_REFLEN], reg_ext[FN_EXTLEN];
+extern char language[FN_REFLEN];
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
+extern char reg_ext[FN_EXTLEN];
 extern uint reg_ext_length;
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
 extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
 extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
 extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
@@ -1653,17 +1664,32 @@ extern ulong max_binlog_size, max_relay_
 extern ulong opt_binlog_rows_event_max_size;
 extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
 extern ulong back_log;
-extern ulong specialflag, current_pid;
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
+extern ulong specialflag;
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
+extern ulong current_pid;
 extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
 extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
 extern ulong tc_log_page_waits;
 extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
 extern uint test_flags,select_errors,ha_open_options;
 extern uint protocol_version, mysqld_port, dropping_tables;
-extern uint delay_key_write_options, lower_case_table_names;
+extern uint delay_key_write_options;
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
+extern uint lower_case_table_names;
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
 extern bool opt_endinfo, using_udf_functions;
 extern my_bool locked_in_memory;
-extern bool opt_using_transactions, mysqld_embedded;
+extern bool opt_using_transactions;
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
+extern bool mysqld_embedded;
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
 extern bool using_update_log, opt_large_files, server_id_supplied;
 extern bool opt_update_log, opt_bin_log, opt_error_log;
 extern my_bool opt_log, opt_slow_log;
@@ -1687,7 +1713,11 @@ extern uint opt_crash_binlog_innodb;
 extern char *shared_memory_base_name, *mysqld_unix_port;
 extern my_bool opt_enable_shared_memory;
 extern char *default_tz_name;
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
 extern my_bool opt_large_pages;
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
 extern uint opt_large_page_size;
 extern char *opt_logname, *opt_slow_logname;
 extern const char *log_output_str;
@@ -1724,7 +1754,11 @@ extern MY_BITMAP temp_pool;
 extern String my_empty_string;
 extern const String my_null_string;
 extern SHOW_VAR status_vars[];
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
 extern struct system_variables global_system_variables;
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
 extern struct system_variables max_system_variables;
 extern struct system_status_var global_status_var;
 extern struct rand_struct sql_rand;
@@ -1921,10 +1955,14 @@ int wild_case_compare(CHARSET_INFO *cs, 
 char *fn_rext(char *name);
 
 /* Conversion functions */
+#endif /* MYSQL_SERVER */
+#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
 uint strconvert(CHARSET_INFO *from_cs, const char *from,
                 CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors);
 uint filename_to_tablename(const char *from, char *to, uint to_length);
 uint tablename_to_filename(const char *from, char *to, uint to_length);
+#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
+#ifdef MYSQL_SERVER
 uint build_table_filename(char *buff, size_t bufflen, const char *db,
                           const char *table, const char *ext, uint flags);
 /* Flags for conversion functions. */

--- 1.109/sql/sql_cache.cc	2007-05-15 07:44:38 -06:00
+++ 1.110/sql/sql_cache.cc	2007-06-11 14:57:40 -06:00
@@ -765,6 +765,18 @@ void query_cache_invalidate_by_MyISAM_fi
 }
 
 
+/*
+  The following function forms part of the C plugin API
+*/
+extern "C"
+void mysql_query_cache_invalidate4(THD *thd,
+                                   const char *key, unsigned key_length,
+                                   int using_trx)
+{
+  query_cache.invalidate(thd, key, (uint32) key_length, (my_bool) using_trx);
+}
+
+
 /*****************************************************************************
    Query_cache methods
 *****************************************************************************/

--- 1.334/sql/sql_class.cc	2007-05-15 07:44:38 -06:00
+++ 1.335/sql/sql_class.cc	2007-06-11 14:57:40 -06:00
@@ -173,6 +173,31 @@ Open_tables_state::Open_tables_state(ulo
   The following functions form part of the C plugin API
 */
 
+extern "C" int mysql_tmpfile(const char *prefix)
+{
+  char filename[FN_REFLEN];
+  File fd = create_temp_file(filename, mysql_tmpdir, prefix,
+#ifdef __WIN__
+                             O_BINARY | O_TRUNC | O_SEQUENTIAL |
+                             O_SHORT_LIVED |
+#endif /* __WIN__ */
+                             O_CREAT | O_EXCL | O_RDWR | O_TEMPORARY,
+                             MYF(MY_WME));
+  if (fd >= 0) {
+#ifndef __WIN__
+    /*
+      This can be removed once the following bug is fixed:
+      Bug #28903  create_temp_file() doesn't honor O_TEMPORARY option
+                  (file not removed) (Unix)
+    */
+    unlink(filename);
+#endif /* !__WIN__ */
+  }
+
+  return fd;
+}
+
+
 extern "C"
 int thd_in_lock_tables(const THD *thd)
 {
@@ -219,6 +244,52 @@ int thd_tx_isolation(const THD *thd)
   return (int) thd->variables.tx_isolation;
 }
 
+extern "C"
+char *thd_alloc(THD *thd, unsigned int size)
+{
+  return thd->alloc(size);
+}
+
+extern "C"
+char *thd_calloc(THD *thd, unsigned int size)
+{
+  return thd->calloc(size);
+}
+
+extern "C"
+char *thd_strdup(THD *thd, const char *str)
+{
+  return thd->strdup(str);
+}
+
+extern "C"
+char *thd_strmake(THD *thd, const char *str, unsigned int size)
+{
+  return thd->strmake(str, size);
+}
+
+extern "C"
+char *thd_memdup(THD *thd, const char* str, unsigned int size)
+{
+  return thd->memdup(str, size);
+}
+
+extern "C"
+MYSQL_LEX_STRING *thd_make_lex_string(THD *thd, LEX_STRING *lex_str,
+                                const char *str, unsigned int size,
+                                int allocate_lex_string)
+{
+  return thd->make_lex_string(lex_str, str, size,
+                                       (bool) allocate_lex_string);
+}
+
+extern "C"
+MYSQL_XID *thd_get_xid(const THD *thd)
+{
+  // MYSQL_XID and XID are binary compatible
+  return (MYSQL_XID *) &thd->transaction.xid_state.xid;
+}
+
 
 /*
   Dumps a text description of a thread, its security context
@@ -287,6 +358,24 @@ char *thd_security_context(THD *thd, cha
   return thd->strmake(str.ptr(), str.length());
 }
 
+/*
+  The following functions are required for the InnoDB
+  storage engine plugin, but do not form part of the
+  general plugin interface
+*/
+#ifdef INNODB_COMPATIBILITY_HOOKS
+extern "C"
+struct charset_info_st *thd_charset(THD *thd)
+{
+  return thd->charset();
+}
+
+extern "C"
+char **thd_query(THD *thd)
+{
+  return &(thd->query);
+}
+#endif /* INNODB_COMPATIBILITY_HOOKS */
 
 
 THD::THD()
@@ -813,6 +902,29 @@ void THD::cleanup_after_query()
   free_items();
   /* Reset where. */
   where= THD::DEFAULT_WHERE;
+}
+
+
+/**
+  Create a LEX_STRING in this connection
+  @param lex_str  pointer to LEX_STRING object to be initialized
+  @param str      initializer to be copied into lex_str
+  @param length   length of str, in bytes
+  @param allocate_lex_string  if TRUE, allocate new LEX_STRING object,
+                              instead of using lex_str value
+  @return  NULL on failure, or pointer to the LEX_STRING object
+*/
+LEX_STRING *THD::make_lex_string(LEX_STRING *lex_str,
+                                 const char* str, uint length,
+                                 bool allocate_lex_string)
+{
+  if (allocate_lex_string)
+    if (!(lex_str= (LEX_STRING *)alloc(sizeof(LEX_STRING))))
+      return 0;
+  if (!(lex_str->str= strmake_root(mem_root, str, length)))
+    return 0;
+  lex_str->length= length;
+  return lex_str;
 }
 
 

--- 1.362/sql/sql_class.h	2007-05-17 14:27:08 -06:00
+++ 1.363/sql/sql_class.h	2007-06-11 14:57:40 -06:00
@@ -447,12 +447,6 @@ public:
   { return strdup_root(mem_root,str); }
   inline char *strmake(const char *str, uint size)
   { return strmake_root(mem_root,str,size); }
-  inline bool LEX_STRING_make(LEX_STRING *lex_str, const char *str, uint size)
-  {
-    return ((lex_str->str= 
-             strmake_root(mem_root, str, (lex_str->length= size)))) == 0;
-  }
-
   inline char *memdup(const char *str, uint size)
   { return memdup_root(mem_root,str,size); }
   inline char *memdup_w_gap(const char *str, uint size, uint gap)
@@ -1543,6 +1537,10 @@ public:
   {
     return alloc_root(&transaction.mem_root,size);
   }
+
+  LEX_STRING *make_lex_string(LEX_STRING *lex_str,
+                              const char* str, uint length,
+                              bool allocate_lex_string);
 
   bool convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
 		      const char *from, uint from_length,

--- 1.670/sql/sql_parse.cc	2007-05-24 12:53:17 -06:00
+++ 1.671/sql/sql_parse.cc	2007-06-11 14:57:41 -06:00
@@ -1025,8 +1025,8 @@ bool dispatch_command(enum enum_server_c
 
       statistic_increment(thd->status_var.com_stat[SQLCOM_CREATE_DB],
 			  &LOCK_status);
-      if (thd->LEX_STRING_make(&db, packet, packet_length -1) ||
-          thd->LEX_STRING_make(&alias, db.str, db.length) ||
+      if (thd->make_lex_string(&db, packet, packet_length - 1, FALSE) ||
+          thd->make_lex_string(&alias, db.str, db.length, FALSE) ||
           check_db_name(&db))
       {
 	my_error(ER_WRONG_DB_NAME, MYF(0), db.str ? db.str : "NULL");
@@ -1047,7 +1047,7 @@ bool dispatch_command(enum enum_server_c
 			  &LOCK_status);
       LEX_STRING db;
 
-      if (thd->LEX_STRING_make(&db, packet, packet_length - 1) ||
+      if (thd->make_lex_string(&db, packet, packet_length - 1, FALSE) ||
           check_db_name(&db))
       {
 	my_error(ER_WRONG_DB_NAME, MYF(0), db.str ? db.str : "NULL");

--- 1.413/sql/sql_show.cc	2007-05-23 01:15:46 -06:00
+++ 1.414/sql/sql_show.cc	2007-06-11 14:57:41 -06:00
@@ -2202,20 +2202,6 @@ void calc_sum_of_all_status(STATUS_VAR *
 }
 
 
-LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str,
-                            const char* str, uint length,
-                            bool allocate_lex_string)
-{
-  MEM_ROOT *mem= thd->mem_root;
-  if (allocate_lex_string)
-    if (!(lex_str= (LEX_STRING *)thd->alloc(sizeof(LEX_STRING))))
-      return 0;
-  lex_str->str= strmake_root(mem, str, length);
-  lex_str->length= length;
-  return lex_str;
-}
-
-
 /* INFORMATION_SCHEMA name */
 LEX_STRING INFORMATION_SCHEMA_NAME= { C_STRING_WITH_LEN("information_schema")};
 
@@ -5137,10 +5123,10 @@ int make_schema_select(THD *thd, SELECT_
      We have to make non const db_name & table_name
      because of lower_case_table_names
   */
-  make_lex_string(thd, &db, INFORMATION_SCHEMA_NAME.str,
-                  INFORMATION_SCHEMA_NAME.length, 0);
-  make_lex_string(thd, &table, schema_table->table_name,
-                  strlen(schema_table->table_name), 0);
+  thd->make_lex_string(&db, INFORMATION_SCHEMA_NAME.str,
+                       INFORMATION_SCHEMA_NAME.length, 0);
+  thd->make_lex_string(&table, schema_table->table_name,
+                       strlen(schema_table->table_name), 0);
   if (schema_table->old_format(thd, schema_table) ||   /* Handle old syntax */
       !sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0),
                               0, 0, TL_READ))

--- 1.338/storage/innobase/handler/ha_innodb.cc	2007-05-05 00:35:10 -06:00
+++ 1.339/storage/innobase/handler/ha_innodb.cc	2007-06-11 14:57:41 -06:00
@@ -837,22 +837,9 @@ innobase_mysql_tmpfile(void)
 /*========================*/
 			/* out: temporary file descriptor, or < 0 on error */
 {
-	char	filename[FN_REFLEN];
 	int	fd2 = -1;
-	File	fd = create_temp_file(filename, mysql_tmpdir, "ib",
-#ifdef __WIN__
-				O_BINARY | O_TRUNC | O_SEQUENTIAL |
-				O_TEMPORARY | O_SHORT_LIVED |
-#endif /* __WIN__ */
-				O_CREAT | O_EXCL | O_RDWR,
-				MYF(MY_WME));
+	File	fd = mysql_tmpfile("ib");
 	if (fd >= 0) {
-#ifndef __WIN__
-		/* On Windows, open files cannot be removed, but files can be
-		created with the O_TEMPORARY flag to the same effect
-		("delete on close"). */
-		unlink(filename);
-#endif /* !__WIN__ */
 		/* Copy the file descriptor, so that the additional resources
 		allocated by create_temp_file() can be freed by invoking
 		my_close().
@@ -867,7 +854,7 @@ innobase_mysql_tmpfile(void)
 			my_errno=errno;
 			my_error(EE_OUT_OF_FILERESOURCES,
 				 MYF(ME_BELL+ME_WAITTANG),
-				 filename, my_errno);
+				 "ib*", my_errno);
 		}
 		my_close(fd, MYF(MY_WME));
 	}
@@ -5893,8 +5880,8 @@ ha_innobase::get_foreign_key_list(THD *t
 	  while (tmp_buff[i] != '/')
 		  i++;
 	  tmp_buff+= i + 1;
-	  f_key_info.forein_id= make_lex_string(thd, 0, tmp_buff,
-		  (uint) strlen(tmp_buff), 1);
+	  f_key_info.forein_id= thd_make_lex_string(thd, 0,
+		  tmp_buff, (uint) strlen(tmp_buff), 1);
 	  tmp_buff= foreign->referenced_table_name;
 
           /* Database name */
@@ -5906,22 +5893,23 @@ ha_innobase::get_foreign_key_list(THD *t
           }
           db_name[i]= 0;
           ulen= filename_to_tablename(db_name, uname, sizeof(uname));
-          f_key_info.referenced_db= make_lex_string(thd, 0, uname, ulen, 1);
+	  f_key_info.referenced_db=
+		  thd_make_lex_string(thd, 0, uname, ulen, 1);
 
           /* Table name */
 	  tmp_buff+= i + 1;
           ulen= filename_to_tablename(tmp_buff, uname, sizeof(uname));
-          f_key_info.referenced_table= make_lex_string(thd, 0, uname,
-                                                       ulen, 1);
+	  f_key_info.referenced_table=
+		  thd_make_lex_string(thd, 0, uname, ulen, 1);
 
 	  for (i= 0;;) {
 		  tmp_buff= foreign->foreign_col_names[i];
-		  name= make_lex_string(thd, name, tmp_buff,
-			  (uint) strlen(tmp_buff), 1);
+		  name= thd_make_lex_string(thd, name,
+			  tmp_buff, (uint) strlen(tmp_buff), 1);
 		  f_key_info.foreign_fields.push_back(name);
 		  tmp_buff= foreign->referenced_col_names[i];
-		  name= make_lex_string(thd, name, tmp_buff,
-			  (uint) strlen(tmp_buff), 1);
+		  name= thd_make_lex_string(thd, name,
+			  tmp_buff, (uint) strlen(tmp_buff), 1);
 		  f_key_info.referenced_fields.push_back(name);
 		  if (++i >= foreign->n_fields)
 			  break;
@@ -5948,8 +5936,8 @@ ha_innobase::get_foreign_key_list(THD *t
             length=8;
             tmp_buff= "RESTRICT";
           }
-          f_key_info.delete_method= make_lex_string(thd, f_key_info.delete_method,
-                                                    tmp_buff, length, 1);
+	  f_key_info.delete_method= thd_make_lex_string(thd,
+		  f_key_info.delete_method, tmp_buff, length, 1);
  
  
           if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE)
@@ -5972,15 +5960,16 @@ ha_innobase::get_foreign_key_list(THD *t
             length=8;
             tmp_buff= "RESTRICT";
           }
-          f_key_info.update_method= make_lex_string(thd, f_key_info.update_method,
-                                                    tmp_buff, length, 1);
+	  f_key_info.update_method= thd_make_lex_string(thd,
+		  f_key_info.update_method, tmp_buff, length, 1);
           if (foreign->referenced_index &&
               foreign->referenced_index->name)
           {
             f_key_info.referenced_key_name= 
-              make_lex_string(thd, f_key_info.referenced_key_name,
-                              foreign->referenced_index->name,
-                              strlen(foreign->referenced_index->name), 1);
+	      thd_make_lex_string(thd,
+		      f_key_info.referenced_key_name,
+		      foreign->referenced_index->name,
+		      strlen(foreign->referenced_index->name), 1);
           }
 
 	  FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *)

--- 1.139/storage/innobase/handler/ha_innodb.h	2007-04-30 18:46:00 -06:00
+++ 1.140/storage/innobase/handler/ha_innodb.h	2007-06-11 14:57:41 -06:00
@@ -213,6 +213,29 @@ extern ulong srv_commit_concurrency;
 extern ulong srv_flush_log_at_trx_commit;
 }
 
+/* Some accessor functions which the InnoDB plugin needs, but which
+can not be added to mysql/plugin.h as part of the public interface;
+the definitions are bracketed with #ifdef INNODB_COMPATIBILITY_HOOKS */
+
+#ifndef INNODB_COMPATIBILITY_HOOKS
+#error INNODB_COMPATIBILITY_HOOKS must be defined to build InnoDB
+#endif
+
+extern "C" {
+struct charset_info_st *thd_charset(MYSQL_THD thd);
+char **thd_query(MYSQL_THD thd);
+
+/** Get the file name of the MySQL binlog.
+ * @return the name of the binlog file
+ */
+const char* mysql_bin_log_file_name(void);
+
+/** Get the current position of the MySQL binlog.
+ * @return byte offset from the beginning of the binlog
+ */
+ulonglong mysql_bin_log_file_pos(void);
+}
+
 /*
   don't delete it - it may be re-enabled later
   as an optimization for the most common case InnoDB+binlog

--- 1.171/include/my_global.h	2007-05-30 15:48:12 -06:00
+++ 1.172/include/my_global.h	2007-06-11 14:57:40 -06:00
@@ -23,6 +23,17 @@
 #define HAVE_EXTERNAL_CLIENT
 #endif
 
+/*
+  InnoDB depends on some MySQL internals which other plugins should not
+  need.  This is because of InnoDB's foreign key support, "safe" binlog
+  truncation, and other similar legacy features.
+
+  We define accessors for these internals unconditionally, but do not
+  expose them in mysql/plugin.h.  They are declared in ha_innodb.h for
+  InnoDB's use.
+*/
+#define INNODB_COMPATIBILITY_HOOKS
+
 #ifdef __CYGWIN__
 /* We use a Unix API, so pretend it's not Windows */
 #undef WIN

--- 1.35/include/mysql/plugin.h	2007-05-01 19:25:20 -06:00
+++ 1.36/include/mysql/plugin.h	2007-06-11 14:57:40 -06:00
@@ -24,6 +24,32 @@ class Item;
 #define MYSQL_THD void*
 #endif
 
+#ifndef _m_string_h
+/* This definition must match the one given in m_string.h */
+struct st_mysql_lex_string
+{
+  char *str;
+  unsigned int length;
+};
+#endif /* _m_string_h */
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+
+#define MYSQL_XIDDATASIZE 128
+/**
+  struct st_mysql_xid is binary compatible with the XID structure as
+  in the X/Open CAE Specification, Distributed Transaction Processing:
+  The XA Specification, X/Open Company Ltd., 1991.
+  http://www.opengroup.org/bookstore/catalog/c193.htm
+
+  @see XID in sql/handler.h
+*/
+struct st_mysql_xid {
+  long formatID;
+  long gtrid_length;
+  long bqual_length;
+  char data[MYSQL_XIDDATASIZE];  // not \0-terminated !
+};
+typedef struct st_mysql_xid MYSQL_XID;
 
 /*************************************************************************
   Plugin API. Common for all plugin types.
@@ -646,6 +672,20 @@ struct st_mysql_value
 extern "C" {
 #endif
 
+/**
+  Create a temporary file
+
+  @details
+  The temporary file is created in a location specified by the mysql
+  server configuration (--tmpdir option).  The caller does not need to
+  delete the file, it will be deleted automatically.
+
+  @param prefix  prefix for temporary file name
+  @retval -1    error
+  @retval >= 0  a file handle that can be passed to my_fdopen or my_close
+*/
+int mysql_tmpfile(const char *prefix);
+
 int thd_in_lock_tables(const MYSQL_THD thd);
 int thd_tablespace_op(const MYSQL_THD thd);
 long long thd_test_options(const MYSQL_THD thd, long long test_options);
@@ -655,6 +695,88 @@ void **thd_ha_data(const MYSQL_THD thd, 
 int thd_tx_isolation(const MYSQL_THD thd);
 char *thd_security_context(MYSQL_THD thd, char *buffer, unsigned int length,
                            unsigned int max_query_len);
+
+/**
+  Check the killed state of a connection
+
+  @details
+  In MySQL support for the KILL statement is cooperative. The KILL
+  statement only sets a "killed" flag. This function returns the value
+  of that flag.  A thread should check it often, especially inside
+  time-consuming loops, and gracefully abort the operation if it is
+  non-zero.
+
+  @param thd  user thread connection handle
+  @retval 0  the connection is active
+  @retval 1  the connection has been killed
+*/
+volatile int thd_killed(const MYSQL_THD thd);
+
+/**
+  Allocate memory in the connection's local memory pool
+  @details
+  When properly used in place of @c my_malloc(), this can significantly
+  improve concurrency. Don't use this or related functions to allocate
+  large chunks of memory. Use for temporary storage only. The memory
+  will be freed automatically at the end of the statement; no explicit
+  code is required to prevent memory leaks.
+
+  @see alloc_root()
+*/
+char *thd_alloc(MYSQL_THD thd, unsigned int size);
+
+/**
+  @see thd_alloc()
+*/
+char *thd_calloc(MYSQL_THD thd, unsigned int size);
+
+/**
+  @see thd_alloc()
+*/
+char *thd_strdup(MYSQL_THD thd, const char *str);
+
+/**
+  @see thd_alloc()
+*/
+char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size);
+
+/**
+  @see thd_alloc()
+*/
+char *thd_memdup(MYSQL_THD thd, const char* str, unsigned int size);
+
+/**
+  Create a LEX_STRING in this connection's local memory pool
+
+  @param thd      user thread connection handle
+  @param lex_str  pointer to LEX_STRING object to be initialized
+  @param str      initializer to be copied into lex_str
+  @param length   length of str, in bytes
+  @param allocate_lex_string  flag: if TRUE, allocate new LEX_STRING object,
+                              instead of using lex_str value
+  @return  NULL on failure, or pointer to the LEX_STRING object
+
+  @see thd_alloc()
+*/
+MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str,
+                                      const char *str, unsigned int size,
+                                      int allocate_lex_string);
+
+/**
+  Get the XID for this connection's transaction
+*/
+MYSQL_XID *thd_get_xid(const MYSQL_THD thd);
+
+/**
+  Invalidate the query cache for a given table.
+  @param thd         user thread connection handle
+  @param key         databasename\0tablename\0
+  @param key_length  length of key in bytes, including the NUL bytes
+  @param using_trx   flag: TRUE if using transactions, FALSE otherwise
+*/
+void mysql_query_cache_invalidate4(MYSQL_THD thd,
+                                   const char *key, unsigned int key_length,
+                                   int using_trx);
 
 
 #ifdef __cplusplus
Thread
bk commit into 5.1 tree (tsmith:1.2538)tim11 Jun