Commit fd683162 authored by calvin's avatar calvin

branches/zip: implement the delayloading of externals for the plugin

on Windows, which includes:

 * Load mysqld.map and insert all symbol/address pairs into hash for
   quick access
 * Resolves all external data variables. The delayloading mechanism
   in MSVC does not support automatic imports of data variables.
   A workaround is to explicitly handle the data import using the delay
   loader during the initialization of the plugin.
 * Resolves all external functions during run-time, by implementing
   the delayed loading helper function delayLoadHelper2, which is
   called by run-time as well as HrLoadAllImportsForDll. 

The delay loader reuses the hash implementation in InnoDB. The normal
hash_create (in hash0hash.c) creates hash tables in buffer pool. But
the delay loader is invoked before the engine is initialized, and 
buffer pools are not ready yet. Instead, the delay loader has its own
implementation of hash_create() and hash_table_free(), called
wdl_hash_create() and wdl_hash_table_free().

This patch should be used with other two patches in order to build
a dynamically linked plugin on Windows:
 * patch for tmpfile functions (r2886)
 * patch for "build" files (to be committed)
 
The list of file changed:

handler/handler0vars.h: new file, defines a list of external data
variables (no external functions).

handler/win_delay_loader.cc: new file, the implementation of the delay
loader for Windows plugin.

handler/ha_innodb.cc: add a header file, and changes for copying the
system variables.

handler/handler0alter.cc: add a header file

handler/i_s.cc: add a header file

rb://27

Reviewed by:	Sunny, Marko
Approved by:	Sunny
parent ed35fc58
......@@ -69,6 +69,7 @@ extern "C" {
#include "ha_innodb.h"
#include "i_s.h"
#include "handler0vars.h"
#ifndef MYSQL_SERVER
/* This is needed because of Bug #3596. Let us hope that pthread_mutex_t
......@@ -107,7 +108,11 @@ undefined. Map it to NULL. */
#ifdef MYSQL_DYNAMIC_PLUGIN
/* These must be weak global variables in the dynamic plugin. */
struct handlerton* innodb_hton_ptr;
#ifdef __WIN__
struct st_mysql_plugin* builtin_innobase_plugin_ptr;
#else
int builtin_innobase_plugin;
#endif /* __WIN__ */
/********************************************************************
Copy InnoDB system variables from the static InnoDB to the dynamic
plugin. */
......@@ -9662,6 +9667,20 @@ innodb_plugin_init(void)
#error "MYSQL_STORAGE_ENGINE_PLUGIN must be nonzero."
#endif
/* Copy the system variables. */
struct st_mysql_plugin* builtin;
struct st_mysql_sys_var** sta; /* static parameters */
struct st_mysql_sys_var** dyn; /* dynamic parameters */
#ifdef __WIN__
if (!builtin_innobase_plugin_ptr) {
return(true);
}
builtin = builtin_innobase_plugin_ptr;
#else
switch (builtin_innobase_plugin) {
case 0:
return(true);
......@@ -9671,13 +9690,8 @@ innodb_plugin_init(void)
return(false);
}
/* Copy the system variables. */
struct st_mysql_plugin* builtin;
struct st_mysql_sys_var** sta; /* static parameters */
struct st_mysql_sys_var** dyn; /* dynamic parameters */
builtin = (struct st_mysql_plugin*) &builtin_innobase_plugin;
#endif
for (sta = builtin->system_vars; *sta != NULL; sta++) {
......
......@@ -18,6 +18,7 @@ extern "C" {
}
#include "ha_innodb.h"
#include "handler0vars.h"
/*****************************************************************
Copies an InnoDB column to a MySQL field. This function is
......
/***********************************************************************
This file contains accessor functions for dynamic plugin on Windows.
(c) 2008 Innobase Oy
***********************************************************************/
#if defined __WIN__ && defined MYSQL_DYNAMIC_PLUGIN
/***********************************************************************
This is a list of externals that can not be resolved by delay loading.
They have to be resolved indirectly via their addresses in the .map file.
All of them are external variables. */
extern CHARSET_INFO* wdl_my_charset_bin;
extern CHARSET_INFO* wdl_my_charset_latin1;
extern CHARSET_INFO* wdl_my_charset_filename;
extern CHARSET_INFO** wdl_system_charset_info;
extern CHARSET_INFO** wdl_default_charset_info;
extern CHARSET_INFO** wdl_all_charsets;
extern system_variables* wdl_global_system_variables;
extern char* wdl_mysql_real_data_home;
extern char** wdl_mysql_data_home;
extern char** wdl_tx_isolation_names;
extern char** wdl_binlog_format_names;
extern char* wdl_reg_ext;
extern pthread_mutex_t* wdl_LOCK_thread_count;
extern key_map* wdl_key_map_full;
extern MY_TMPDIR* wdl_mysql_tmpdir_list;
extern bool* wdl_mysqld_embedded;
extern uint* wdl_lower_case_table_names;
extern ulong* wdl_specialflag;
extern int* wdl_my_umask;
#define my_charset_bin (*wdl_my_charset_bin)
#define my_charset_latin1 (*wdl_my_charset_latin1)
#define my_charset_filename (*wdl_my_charset_filename)
#define system_charset_info (*wdl_system_charset_info)
#define default_charset_info (*wdl_default_charset_info)
#define all_charsets (wdl_all_charsets)
#define global_system_variables (*wdl_global_system_variables)
#define mysql_real_data_home (wdl_mysql_real_data_home)
#define mysql_data_home (*wdl_mysql_data_home)
#define tx_isolation_names (*wdl_tx_isolation_names)
#define binlog_format_names (*wdl_binlog_format_names)
#define reg_ext (wdl_reg_ext)
#define LOCK_thread_count (*wdl_LOCK_thread_count)
#define key_map_full (*wdl_key_map_full)
#define mysql_tmpdir_list (*wdl_mysql_tmpdir_list)
#define mysqld_embedded (*wdl_mysqld_embedded)
#define lower_case_table_names (*wdl_lower_case_table_names)
#define specialflag (*wdl_specialflag)
#define my_umask (*wdl_my_umask)
#endif
......@@ -25,6 +25,7 @@ extern "C" {
#include "ha_prototypes.h" /* for innobase_convert_name() */
#include "srv0start.h" /* for srv_was_started */
}
#include "handler0vars.h"
static const char plugin_author[] = "Innobase Oy";
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment