Commit bd7120f9 authored by unknown's avatar unknown

Fix the tree: plugin-related changes, necessary for

CSV storage engine to be statically compiled.
Derived from antony's patch.


config/ac-macros/storage.m4:
  don't add objects to the object list if
  we don't have them
configure.in:
  compile CSV statically
sql/ha_myisam.cc:
  fix prototype to get rid of THD
sql/ha_myisam.h:
  fix prototype to get rid of THD
sql/handler.cc:
  new function for plugins
sql/handler.h:
  fix prototype to get rid of THD
  declare functions used by plugins
sql/item.h:
  Don't include all the types and files when not building mysqld
sql/lock.cc:
  don's assume that handler knows about THD
sql/mysql_priv.h:
  Don't include all the types and files when not building mysqld
  declare new plugin functions
sql/sql_class.cc:
  New plugin functions
sql/sql_class.h:
  Don't include all the types and files when not building mysqld
sql/sql_lex.h:
  Don't include all the types and files when not building mysqld
storage/csv/Makefile.am:
  compile CSV into a static lib to be
  linked into mysqld
storage/csv/ha_tina.cc:
  fix ha_tina to be able to build it static
storage/csv/ha_tina.h:
  fix prototype to get rid of THD
parent 7dbb63fe
...@@ -39,7 +39,10 @@ then ...@@ -39,7 +39,10 @@ then
AC_DEFINE([$5]) AC_DEFINE([$5])
mysql_se_decls="${mysql_se_decls},$6" mysql_se_decls="${mysql_se_decls},$6"
mysql_se_htons="${mysql_se_htons},&$6" mysql_se_htons="${mysql_se_htons},&$6"
if test "$8" != "no"
then
mysql_se_objs="$mysql_se_objs $8" mysql_se_objs="$mysql_se_objs $8"
fi
mysql_se_dirs="$mysql_se_dirs $7" mysql_se_dirs="$mysql_se_dirs $7"
mysql_se_libs="$mysql_se_libs $9" mysql_se_libs="$mysql_se_libs $9"
else else
......
...@@ -2437,8 +2437,8 @@ MYSQL_STORAGE_ENGINE(archive,,,,,,storage/archive,, ...@@ -2437,8 +2437,8 @@ MYSQL_STORAGE_ENGINE(archive,,,,,,storage/archive,,
\$(top_builddir)/storage/archive/libarchive.a, [ \$(top_builddir)/storage/archive/libarchive.a, [
AC_CONFIG_FILES(storage/archive/Makefile) AC_CONFIG_FILES(storage/archive/Makefile)
]) ])
MYSQL_STORAGE_ENGINE(csv,,,"yes",,tina_hton,storage/csv, MYSQL_STORAGE_ENGINE(csv,,,"yes",,tina_hton,storage/csv,no,
../storage/csv/ha_tina.o,,[ \$(top_builddir)/storage/csv/libcsv.a,[
AC_CONFIG_FILES(storage/csv/Makefile) AC_CONFIG_FILES(storage/csv/Makefile)
]) ])
MYSQL_STORAGE_ENGINE(blackhole) MYSQL_STORAGE_ENGINE(blackhole)
......
...@@ -296,7 +296,10 @@ int ha_myisam::dump(THD* thd, int fd) ...@@ -296,7 +296,10 @@ int ha_myisam::dump(THD* thd, int fd)
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
bool ha_myisam::check_if_locking_is_allowed(THD *thd, TABLE *table, uint count) bool ha_myisam::check_if_locking_is_allowed(uint sql_command,
ulong type, TABLE *table,
uint count,
bool called_by_logger_thread)
{ {
/* /*
To be able to open and lock for reading system tables like 'mysql.proc', To be able to open and lock for reading system tables like 'mysql.proc',
......
...@@ -60,7 +60,10 @@ class ha_myisam: public handler ...@@ -60,7 +60,10 @@ class ha_myisam: public handler
uint max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH; } uint max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH; }
uint checksum() const; uint checksum() const;
virtual bool check_if_locking_is_allowed(THD *thd, TABLE *table, uint count); virtual bool check_if_locking_is_allowed(uint sql_command,
ulong type, TABLE *table,
uint count,
bool called_by_logger_thread);
int open(const char *name, int mode, uint test_if_locked); int open(const char *name, int mode, uint test_if_locked);
int close(void); int close(void);
int write_row(byte * buf); int write_row(byte * buf);
......
...@@ -1425,6 +1425,12 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, ...@@ -1425,6 +1425,12 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
** General handler functions ** 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. Open database-handler.
......
...@@ -1006,6 +1006,8 @@ typedef struct st_handler_buffer ...@@ -1006,6 +1006,8 @@ typedef struct st_handler_buffer
byte *end_of_used_area; /* End of area that was used by handler */ byte *end_of_used_area; /* End of area that was used by handler */
} HANDLER_BUFFER; } HANDLER_BUFFER;
typedef struct system_status_var SSV;
class handler :public Sql_alloc class handler :public Sql_alloc
{ {
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
...@@ -1027,6 +1029,9 @@ class handler :public Sql_alloc ...@@ -1027,6 +1029,9 @@ class handler :public Sql_alloc
virtual int rnd_init(bool scan) =0; virtual int rnd_init(bool scan) =0;
virtual int rnd_end() { return 0; } virtual int rnd_end() { return 0; }
void ha_statistic_increment(ulong SSV::*offset) const;
private: private:
virtual int reset() { return extra(HA_EXTRA_RESET); } virtual int reset() { return extra(HA_EXTRA_RESET); }
public: public:
...@@ -1109,7 +1114,10 @@ class handler :public Sql_alloc ...@@ -1109,7 +1114,10 @@ class handler :public Sql_alloc
TRUE Locking is allowed TRUE Locking is allowed
FALSE Locking is not allowed. The error was thrown. FALSE Locking is not allowed. The error was thrown.
*/ */
virtual bool check_if_locking_is_allowed(THD *thd, TABLE *table, uint count) virtual bool check_if_locking_is_allowed(uint sql_command,
ulong type, TABLE *table,
uint count,
bool called_by_logger_thread)
{ {
return TRUE; return TRUE;
} }
......
...@@ -1932,7 +1932,7 @@ class Item_int_with_ref :public Item_int ...@@ -1932,7 +1932,7 @@ class Item_int_with_ref :public Item_int
virtual Item *real_item() { return ref; } virtual Item *real_item() { return ref; }
}; };
#ifdef MYSQL_SERVER
#include "gstream.h" #include "gstream.h"
#include "spatial.h" #include "spatial.h"
#include "item_sum.h" #include "item_sum.h"
...@@ -1945,6 +1945,7 @@ class Item_int_with_ref :public Item_int ...@@ -1945,6 +1945,7 @@ class Item_int_with_ref :public Item_int
#include "item_uniq.h" #include "item_uniq.h"
#include "item_subselect.h" #include "item_subselect.h"
#include "item_xmlfunc.h" #include "item_xmlfunc.h"
#endif
class Item_copy_string :public Item class Item_copy_string :public Item
{ {
......
...@@ -617,8 +617,11 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, ...@@ -617,8 +617,11 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
Check if we can lock the table. For some tables we cannot do that Check if we can lock the table. For some tables we cannot do that
beacause of handler-specific locking issues. beacause of handler-specific locking issues.
*/ */
if (!table_ptr[i]->file->check_if_locking_is_allowed(thd, table_ptr[i], if (!table_ptr[i]-> file->
count)) check_if_locking_is_allowed(thd->lex->sql_command, thd->lex->type,
table_ptr[i], count,
(thd == logger.get_general_log_thd()) ||
(thd == logger.get_slow_log_thd())))
return 0; return 0;
} }
......
...@@ -477,6 +477,11 @@ inline THD *_current_thd(void) ...@@ -477,6 +477,11 @@ inline THD *_current_thd(void)
} }
#define current_thd _current_thd() #define current_thd _current_thd()
/* below functions are required for plugins as THD class is opaque */
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 External variables
*/ */
...@@ -507,7 +512,9 @@ enum enum_var_type ...@@ -507,7 +512,9 @@ enum enum_var_type
class sys_var; class sys_var;
#include "item.h" #include "item.h"
extern my_decimal decimal_zero; extern my_decimal decimal_zero;
#ifdef MYSQL_SERVER
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert); typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
#endif
/* sql_parse.cc */ /* sql_parse.cc */
void free_items(Item *item); void free_items(Item *item);
void cleanup_items(Item *item); void cleanup_items(Item *item);
...@@ -545,6 +552,7 @@ Item *negate_expression(THD *thd, Item *expr); ...@@ -545,6 +552,7 @@ Item *negate_expression(THD *thd, Item *expr);
#include "sql_class.h" #include "sql_class.h"
#include "sql_acl.h" #include "sql_acl.h"
#include "tztime.h" #include "tztime.h"
#ifdef MYSQL_SERVER
#include "opt_range.h" #include "opt_range.h"
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
...@@ -841,6 +849,8 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length, ...@@ -841,6 +849,8 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
Field * Field *
find_field_in_table_sef(TABLE *table, const char *name); find_field_in_table_sef(TABLE *table, const char *name);
#endif /* MYSQL_SERVER */
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
#include <openssl/des.h> #include <openssl/des.h>
struct st_des_keyblock struct st_des_keyblock
...@@ -858,6 +868,7 @@ extern pthread_mutex_t LOCK_des_key_file; ...@@ -858,6 +868,7 @@ extern pthread_mutex_t LOCK_des_key_file;
bool load_des_key_file(const char *file_name); bool load_des_key_file(const char *file_name);
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
#ifdef MYSQL_SERVER
/* sql_do.cc */ /* sql_do.cc */
bool mysql_do(THD *thd, List<Item> &values); bool mysql_do(THD *thd, List<Item> &values);
...@@ -1169,6 +1180,7 @@ int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length); ...@@ -1169,6 +1180,7 @@ int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length);
int key_rec_cmp(void *key_info, byte *a, byte *b); int key_rec_cmp(void *key_info, byte *a, byte *b);
bool init_errmessage(void); bool init_errmessage(void);
#endif /* MYSQL_SERVER */
void sql_perror(const char *message); void sql_perror(const char *message);
int vprint_msg_to_log(enum loglevel level, const char *format, va_list args); int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
...@@ -1191,6 +1203,7 @@ bool general_log_print(THD *thd, enum enum_server_command command, ...@@ -1191,6 +1203,7 @@ bool general_log_print(THD *thd, enum enum_server_command command,
bool fn_format_relative_to_data_home(my_string to, const char *name, bool fn_format_relative_to_data_home(my_string to, const char *name,
const char *dir, const char *extension); const char *dir, const char *extension);
#ifdef MYSQL_SERVER
File open_binlog(IO_CACHE *log, const char *log_file_name, File open_binlog(IO_CACHE *log, const char *log_file_name,
const char **errmsg); const char **errmsg);
...@@ -1739,4 +1752,5 @@ inline void kill_delayed_threads(void) {} ...@@ -1739,4 +1752,5 @@ inline void kill_delayed_threads(void) {}
#define check_stack_overrun(A, B, C) 0 #define check_stack_overrun(A, B, C) 0
#endif #endif
#endif /* MYSQL_SERVER */
#endif /* MYSQL_CLIENT */ #endif /* MYSQL_CLIENT */
...@@ -167,6 +167,25 @@ Open_tables_state::Open_tables_state(ulong version_arg) ...@@ -167,6 +167,25 @@ Open_tables_state::Open_tables_state(ulong version_arg)
reset_open_tables_state(); reset_open_tables_state();
} }
my_bool thd_in_lock_tables(const THD *thd)
{
return thd->in_lock_tables;
}
my_bool thd_tablespace_op(const THD *thd)
{
return thd->tablespace_op;
}
const char *thd_proc_info(THD *thd, const char *info)
{
const char *old_info= thd->proc_info;
thd->proc_info= info;
return old_info;
}
/* /*
Pass nominal parameters to Statement constructor only to ensure that Pass nominal parameters to Statement constructor only to ensure that
......
...@@ -171,6 +171,7 @@ class LEX_COLUMN : public Sql_alloc ...@@ -171,6 +171,7 @@ class LEX_COLUMN : public Sql_alloc
class delayed_insert; class delayed_insert;
class select_result; class select_result;
class Time_zone;
#define THD_SENTRY_MAGIC 0xfeedd1ff #define THD_SENTRY_MAGIC 0xfeedd1ff
#define THD_SENTRY_GONE 0xdeadbeef #define THD_SENTRY_GONE 0xdeadbeef
...@@ -344,6 +345,8 @@ typedef struct system_status_var ...@@ -344,6 +345,8 @@ typedef struct system_status_var
#define last_system_status_var com_stmt_close #define last_system_status_var com_stmt_close
#ifdef MYSQL_SERVER
void free_tmp_table(THD *thd, TABLE *entry); void free_tmp_table(THD *thd, TABLE *entry);
...@@ -354,7 +357,6 @@ void free_tmp_table(THD *thd, TABLE *entry); ...@@ -354,7 +357,6 @@ void free_tmp_table(THD *thd, TABLE *entry);
#define INIT_ARENA_DBUG_INFO #define INIT_ARENA_DBUG_INFO
#endif #endif
class Query_arena class Query_arena
{ {
public: public:
...@@ -1905,3 +1907,5 @@ class select_dumpvar :public select_result_interceptor { ...@@ -1905,3 +1907,5 @@ class select_dumpvar :public select_result_interceptor {
/* Functions in sql_class.cc */ /* Functions in sql_class.cc */
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var); void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
#endif /* MYSQL_SERVER */
...@@ -29,6 +29,7 @@ class st_alter_tablespace; ...@@ -29,6 +29,7 @@ class st_alter_tablespace;
class partition_info; class partition_info;
class event_timed; class event_timed;
#ifdef MYSQL_SERVER
/* /*
The following hack is needed because mysql_yacc.cc does not define The following hack is needed because mysql_yacc.cc does not define
YYSTYPE before including this file YYSTYPE before including this file
...@@ -43,6 +44,7 @@ class event_timed; ...@@ -43,6 +44,7 @@ class event_timed;
#include "sql_yacc.h" #include "sql_yacc.h"
#define LEX_YYSTYPE YYSTYPE * #define LEX_YYSTYPE YYSTYPE *
#endif #endif
#endif
/* /*
When a command is added here, be sure it's also added in mysqld.cc When a command is added here, be sure it's also added in mysqld.cc
...@@ -115,6 +117,8 @@ enum enum_sql_command { ...@@ -115,6 +117,8 @@ enum enum_sql_command {
*/ */
#define DESCRIBE_PARTITIONS 4 #define DESCRIBE_PARTITIONS 4
#ifdef MYSQL_SERVER
enum enum_sp_suid_behaviour enum enum_sp_suid_behaviour
{ {
SP_IS_DEFAULT_SUID= 0, SP_IS_DEFAULT_SUID= 0,
...@@ -1109,3 +1113,5 @@ extern int yylex(void *arg, void *yythd); ...@@ -1109,3 +1113,5 @@ extern int yylex(void *arg, void *yythd);
extern pthread_key(LEX*,THR_LEX); extern pthread_key(LEX*,THR_LEX);
#define current_lex (current_thd->lex) #define current_lex (current_thd->lex)
#endif
...@@ -24,17 +24,16 @@ INCLUDES = -I$(top_srcdir)/include \ ...@@ -24,17 +24,16 @@ INCLUDES = -I$(top_srcdir)/include \
-I$(top_srcdir)/regex \ -I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \ -I$(top_srcdir)/sql \
-I$(srcdir) -I$(srcdir)
WRAPLIBS=
pkglib_LTLIBRARIES = ha_csv.la pkglib_LIBRARIES = libcsv.a
ha_csv_la_LDFLAGS = -module
noinst_HEADERS = ha_tina.h
ha_csv_la_SOURCES = ha_tina.cc
LDADD = LDADD =
DEFS = -DMYSQL_SERVER @DEFS@ DEFS = @DEFS@
libcsv_a_CXXFLAGS = $(AM_CFLAGS)
noinst_HEADERS = ha_tina.h
libcsv_a_SOURCES = ha_tina.cc
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
...@@ -590,7 +590,10 @@ void ha_tina::update_status() ...@@ -590,7 +590,10 @@ void ha_tina::update_status()
} }
bool ha_tina::check_if_locking_is_allowed(THD *thd, TABLE *table, uint count) bool ha_tina::check_if_locking_is_allowed(uint sql_command,
ulong type, TABLE *table,
uint count,
bool called_by_logger_thread)
{ {
/* /*
Deny locking of the log tables, which is incompatible with Deny locking of the log tables, which is incompatible with
...@@ -598,11 +601,10 @@ bool ha_tina::check_if_locking_is_allowed(THD *thd, TABLE *table, uint count) ...@@ -598,11 +601,10 @@ bool ha_tina::check_if_locking_is_allowed(THD *thd, TABLE *table, uint count)
general_log_thd or slow_log_thd. general_log_thd or slow_log_thd.
*/ */
if (table->s->log_table && if (table->s->log_table &&
thd->lex->sql_command != SQLCOM_TRUNCATE && sql_command != SQLCOM_TRUNCATE &&
!(thd->lex->sql_command == SQLCOM_FLUSH && !(sql_command == SQLCOM_FLUSH &&
thd->lex->type & REFRESH_LOG) && type & REFRESH_LOG) &&
(thd != logger.get_general_log_thd()) && !called_by_logger_thread &&
(thd != logger.get_slow_log_thd()) &&
(table->reginfo.lock_type >= TL_READ_NO_INSERT)) (table->reginfo.lock_type >= TL_READ_NO_INSERT))
{ {
/* /*
...@@ -665,7 +667,7 @@ int ha_tina::write_row(byte * buf) ...@@ -665,7 +667,7 @@ int ha_tina::write_row(byte * buf)
int size; int size;
DBUG_ENTER("ha_tina::write_row"); DBUG_ENTER("ha_tina::write_row");
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) if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
table->timestamp_field->set_time(); table->timestamp_field->set_time();
...@@ -714,9 +716,7 @@ int ha_tina::update_row(const byte * old_data, byte * new_data) ...@@ -714,9 +716,7 @@ int ha_tina::update_row(const byte * old_data, byte * new_data)
int size; int size;
DBUG_ENTER("ha_tina::update_row"); DBUG_ENTER("ha_tina::update_row");
ha_statistic_increment(&SSV::ha_read_rnd_next_count);
statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
&LOCK_status);
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
table->timestamp_field->set_time(); table->timestamp_field->set_time();
...@@ -751,8 +751,7 @@ int ha_tina::update_row(const byte * old_data, byte * new_data) ...@@ -751,8 +751,7 @@ int ha_tina::update_row(const byte * old_data, byte * new_data)
int ha_tina::delete_row(const byte * buf) int ha_tina::delete_row(const byte * buf)
{ {
DBUG_ENTER("ha_tina::delete_row"); DBUG_ENTER("ha_tina::delete_row");
statistic_increment(table->in_use->status_var.ha_delete_count, ha_statistic_increment(&SSV::ha_delete_count);
&LOCK_status);
if (chain_append()) if (chain_append())
DBUG_RETURN(-1); DBUG_RETURN(-1);
...@@ -903,8 +902,7 @@ int ha_tina::rnd_next(byte *buf) ...@@ -903,8 +902,7 @@ int ha_tina::rnd_next(byte *buf)
{ {
DBUG_ENTER("ha_tina::rnd_next"); DBUG_ENTER("ha_tina::rnd_next");
statistic_increment(table->in_use->status_var.ha_read_rnd_next_count, ha_statistic_increment(&SSV::ha_read_rnd_next_count);
&LOCK_status);
current_position= next_position; current_position= next_position;
if (!share->mapped_file) if (!share->mapped_file)
...@@ -941,8 +939,7 @@ void ha_tina::position(const byte *record) ...@@ -941,8 +939,7 @@ void ha_tina::position(const byte *record)
int ha_tina::rnd_pos(byte * buf, byte *pos) int ha_tina::rnd_pos(byte * buf, byte *pos)
{ {
DBUG_ENTER("ha_tina::rnd_pos"); DBUG_ENTER("ha_tina::rnd_pos");
statistic_increment(table->in_use->status_var.ha_read_rnd_next_count, ha_statistic_increment(&SSV::ha_read_rnd_next_count);
&LOCK_status);
current_position= my_get_ptr(pos,ref_length); current_position= my_get_ptr(pos,ref_length);
DBUG_RETURN(find_current_row(buf)); DBUG_RETURN(find_current_row(buf));
} }
......
...@@ -104,7 +104,10 @@ class ha_tina: public handler ...@@ -104,7 +104,10 @@ class ha_tina: public handler
*/ */
ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; } ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; }
virtual bool check_if_locking_is_allowed(THD *thd, TABLE *table, uint count); virtual bool check_if_locking_is_allowed(uint sql_command,
ulong type, TABLE *table,
uint count,
bool called_by_logger_thread);
int open(const char *name, int mode, uint test_if_locked); int open(const char *name, int mode, uint test_if_locked);
int close(void); int close(void);
int write_row(byte * buf); int write_row(byte * buf);
......
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