From dcb54040bcb6927e1fafe039979b816865c7c805 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Fri, 7 Jul 2017 17:52:23 +0300 Subject: [PATCH] SQL: VTQ testing iface moved to plugin [closes #224] --- mysql-test/suite/versioning/common.opt | 1 + .../suite/versioning/t/cte_recursive.opt | 1 + mysql-test/suite/versioning/t/simple.opt | 1 + mysql-test/suite/versioning/t/view.opt | 1 + plugin/versioning/versioning.cc | 196 ++++++++++++++++-- sql/item_create.cc | 169 +-------------- sql/item_create.h | 40 ++++ sql/item_func.h | 3 + sql/item_vers.cc | 63 ++---- sql/item_vers.h | 24 +-- sql/sql_plugin.cc | 14 -- sql/sql_plugin.h | 2 - sql/sql_select.cc | 27 ++- sql/vers_string.h | 4 + 14 files changed, 273 insertions(+), 273 deletions(-) diff --git a/mysql-test/suite/versioning/common.opt b/mysql-test/suite/versioning/common.opt index 5575069d6ee..132aab2d0ec 100644 --- a/mysql-test/suite/versioning/common.opt +++ b/mysql-test/suite/versioning/common.opt @@ -16,3 +16,4 @@ --innodb-sys-virtual --innodb-vtq --versioning-hide=implicit +--plugin-load=versioning diff --git a/mysql-test/suite/versioning/t/cte_recursive.opt b/mysql-test/suite/versioning/t/cte_recursive.opt index 3596fc4d3bd..993df05011e 100644 --- a/mysql-test/suite/versioning/t/cte_recursive.opt +++ b/mysql-test/suite/versioning/t/cte_recursive.opt @@ -1 +1,2 @@ --innodb --default-storage-engine=innodb +--plugin-load=versioning diff --git a/mysql-test/suite/versioning/t/simple.opt b/mysql-test/suite/versioning/t/simple.opt index 3596fc4d3bd..993df05011e 100644 --- a/mysql-test/suite/versioning/t/simple.opt +++ b/mysql-test/suite/versioning/t/simple.opt @@ -1 +1,2 @@ --innodb --default-storage-engine=innodb +--plugin-load=versioning diff --git a/mysql-test/suite/versioning/t/view.opt b/mysql-test/suite/versioning/t/view.opt index c1a585b67eb..9baff80804d 100644 --- a/mysql-test/suite/versioning/t/view.opt +++ b/mysql-test/suite/versioning/t/view.opt @@ -1 +1,2 @@ --versioning-hide=implicit +--plugin-load=versioning diff --git a/plugin/versioning/versioning.cc b/plugin/versioning/versioning.cc index 016367f89f4..fb8a8b8ee32 100644 --- a/plugin/versioning/versioning.cc +++ b/plugin/versioning/versioning.cc @@ -14,10 +14,144 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define MYSQL_SERVER 1 #include #include +#include #include "sql_plugin.h" // st_plugin_int #include "sql_class.h" +#include "item.h" +#include "vtq.h" +#include "vers_utils.h" + +plugin_ref innodb_plugin= NULL; +static handlerton* innodb_hton= NULL; + +/* System Versioning: VTQ_TRX_ID(), VTQ_COMMIT_ID(), VTQ_BEGIN_TS(), VTQ_COMMIT_TS(), VTQ_ISO_LEVEL() */ +template +class Create_func_vtq : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, LEX_STRING name, List *item_list); + + static Create_func_vtq s_singleton; + +protected: + Create_func_vtq() {} + virtual ~Create_func_vtq() {} +}; + +template +Create_func_vtq Create_func_vtq::s_singleton; + +template +Item* +Create_func_vtq::create_native(THD *thd, LEX_STRING name, + List *item_list) +{ + Item *func= NULL; + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + switch (arg_count) { + case 1: + { + Item *param_1= item_list->pop(); + switch (VTQ_FIELD) + { + case VTQ_BEGIN_TS: + case VTQ_COMMIT_TS: + func= new (thd->mem_root) Item_func_vtq_ts(thd, innodb_hton, param_1, VTQ_FIELD); + break; + case VTQ_TRX_ID: + case VTQ_COMMIT_ID: + case VTQ_ISO_LEVEL: + func= new (thd->mem_root) Item_func_vtq_id(thd, innodb_hton, param_1, VTQ_FIELD); + break; + default: + DBUG_ASSERT(0); + } + break; + } + case 2: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + switch (VTQ_FIELD) + { + case VTQ_TRX_ID: + case VTQ_COMMIT_ID: + func= new (thd->mem_root) Item_func_vtq_id(thd, innodb_hton, param_1, param_2, VTQ_FIELD); + break; + default: + goto error; + } + break; + } + error: + default: + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); + break; + } + } + + return func; +}; + +template +class Create_func_vtq_trx_sees : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, LEX_STRING name, List *item_list) + { + Item *func= NULL; + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + switch (arg_count) { + case 2: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + func= new (thd->mem_root) Item_func_vtq_trx_seesX(thd, innodb_hton, param_1, param_2); + break; + } + default: + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); + break; + } + + return func; + } + + static Create_func_vtq_trx_sees s_singleton; + +protected: + Create_func_vtq_trx_sees() {} + virtual ~Create_func_vtq_trx_sees() {} +}; + +template +Create_func_vtq_trx_sees Create_func_vtq_trx_sees::s_singleton; + +#define BUILDER(F) & F::s_singleton + +static Native_func_registry func_array[] = +{ + { { C_STRING_WITH_LEN("VTQ_BEGIN_TS") }, BUILDER(Create_func_vtq)}, + { { C_STRING_WITH_LEN("VTQ_COMMIT_ID") }, BUILDER(Create_func_vtq)}, + { { C_STRING_WITH_LEN("VTQ_COMMIT_TS") }, BUILDER(Create_func_vtq)}, + { { C_STRING_WITH_LEN("VTQ_ISO_LEVEL") }, BUILDER(Create_func_vtq)}, + { { C_STRING_WITH_LEN("VTQ_TRX_ID") }, BUILDER(Create_func_vtq)}, + { { C_STRING_WITH_LEN("VTQ_TRX_SEES") }, BUILDER(Create_func_vtq_trx_sees)}, + { { C_STRING_WITH_LEN("VTQ_TRX_SEES_EQ") }, BUILDER(Create_func_vtq_trx_sees)} +}; + /* Disable __attribute__() on non-gcc compilers. @@ -26,45 +160,61 @@ #define __attribute__(A) #endif -static int forced_versioning_init(void *p __attribute__ ((unused))) +static int versioning_plugin_init(void *p __attribute__ ((unused))) { + static LString InnoDB= "InnoDB"; + + DBUG_ENTER("versioning_plugin_init"); + // No need in locking since we so far single-threaded + int res= item_create_append(func_array); + if (res) + { + my_message(ER_PLUGIN_IS_NOT_LOADED, "Can't append function array" , MYF(0)); + DBUG_RETURN(res); + } + + innodb_plugin= ha_resolve_by_name(NULL, &InnoDB.lex_string(), false); + if (!innodb_plugin) + { + my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), InnoDB.ptr()); + DBUG_RETURN(1); + } + + innodb_hton= plugin_hton(innodb_plugin); + if (!innodb_hton || (innodb_hton->flags & HTON_NOT_USER_SELECTABLE)) + { + my_message(ER_PLUGIN_IS_NOT_LOADED, "Can't get handlerton" , MYF(0)); + DBUG_RETURN(1); + } - DBUG_ENTER("forced_versioning_init"); - mysql_mutex_lock(&LOCK_global_system_variables); - global_system_variables.vers_force= true; - global_system_variables.vers_hide= VERS_HIDE_FULL; - mysql_mutex_unlock(&LOCK_global_system_variables); DBUG_RETURN(0); } -static int forced_versioning_deinit(void *p __attribute__ ((unused))) +static int versioning_plugin_deinit(void *p __attribute__ ((unused))) { - DBUG_ENTER("forced_versioning_deinit"); - mysql_mutex_lock(&LOCK_global_system_variables); - global_system_variables.vers_force= false; - global_system_variables.vers_hide= VERS_HIDE_AUTO; - mysql_mutex_unlock(&LOCK_global_system_variables); + DBUG_ENTER("versioning_plugin_deinit"); + if (innodb_plugin) + plugin_unlock(NULL, innodb_plugin); DBUG_RETURN(0); } - -struct st_mysql_daemon forced_versioning_plugin= -{ MYSQL_DAEMON_INTERFACE_VERSION }; +struct st_mysql_daemon versioning_plugin= +{ MYSQL_REPLICATION_INTERFACE_VERSION }; /* Plugin library descriptor */ -maria_declare_plugin(forced_versioning) +maria_declare_plugin(versioning) { - MYSQL_DAEMON_PLUGIN, - &forced_versioning_plugin, - "forced_versioning", - "Natsys Lab", - "Enable System Vesioning for all newly created tables", + MYSQL_REPLICATION_PLUGIN, // initialized after MYSQL_STORAGE_ENGINE_PLUGIN + &versioning_plugin, + "versioning", + "MariaDB Corp", + "System Vesioning testing features", PLUGIN_LICENSE_GPL, - forced_versioning_init, /* Plugin Init */ - forced_versioning_deinit, /* Plugin Deinit */ + versioning_plugin_init, /* Plugin Init */ + versioning_plugin_deinit, /* Plugin Deinit */ 0x0100 /* 1.0 */, NULL, /* status variables */ NULL, /* system variables */ diff --git a/sql/item_create.cc b/sql/item_create.cc index 7e8c60591e6..140abdd074d 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -104,36 +104,6 @@ bool get_length_and_scale(ulonglong length, ulonglong decimals, ============================================================================= */ -/** - Adapter for native functions with a variable number of arguments. - The main use of this class is to discard the following calls: - foo(expr1 AS name1, expr2 AS name2, ...) - which are syntactically correct (the syntax can refer to a UDF), - but semantically invalid for native functions. -*/ - -class Create_native_func : public Create_func -{ -public: - virtual Item *create_func(THD *thd, LEX_STRING name, List *item_list); - - /** - Builder method, with no arguments. - @param thd The current thread - @param name The native function name - @param item_list The function parameters, none of which are named - @return An item representing the function call - */ - virtual Item *create_native(THD *thd, LEX_STRING name, - List *item_list) = 0; - -protected: - /** Constructor. */ - Create_native_func() {} - /** Destructor. */ - virtual ~Create_native_func() {} -}; - /** Adapter for functions that takes exactly zero arguments. @@ -6678,125 +6648,6 @@ Create_func_year_week::create_native(THD *thd, LEX_STRING name, } -/* System Versioning: VTQ_TRX_ID(), VTQ_COMMIT_ID(), VTQ_BEGIN_TS(), VTQ_COMMIT_TS(), VTQ_ISO_LEVEL() */ -template -class Create_func_vtq : public Create_native_func -{ -public: - virtual Item *create_native(THD *thd, LEX_STRING name, List *item_list); - - static Create_func_vtq s_singleton; - -protected: - Create_func_vtq() {} - virtual ~Create_func_vtq() {} -}; - -template -Create_func_vtq Create_func_vtq::s_singleton; - -template -Item* -Create_func_vtq::create_native(THD *thd, LEX_STRING name, - List *item_list) -{ - Item *func= NULL; - int arg_count= 0; - - if (item_list != NULL) - arg_count= item_list->elements; - - switch (arg_count) { - case 1: - { - Item *param_1= item_list->pop(); - switch (VTQ_FIELD) - { - case VTQ_BEGIN_TS: - case VTQ_COMMIT_TS: - func= new (thd->mem_root) Item_func_vtq_ts(thd, param_1, VTQ_FIELD); - break; - case VTQ_TRX_ID: - case VTQ_COMMIT_ID: - case VTQ_ISO_LEVEL: - func= new (thd->mem_root) Item_func_vtq_id(thd, param_1, VTQ_FIELD); - break; - default: - DBUG_ASSERT(0); - } - break; - } - case 2: - { - Item *param_1= item_list->pop(); - Item *param_2= item_list->pop(); - switch (VTQ_FIELD) - { - case VTQ_TRX_ID: - case VTQ_COMMIT_ID: - func= new (thd->mem_root) Item_func_vtq_id(thd, param_1, param_2, VTQ_FIELD); - break; - default: - goto error; - } - break; - } - error: - default: - { - my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); - break; - } - } - - return func; -}; - -template -class Create_func_vtq_trx_sees : public Create_native_func -{ -public: - virtual Item *create_native(THD *thd, LEX_STRING name, List *item_list) - { - Item *func= NULL; - int arg_count= 0; - - if (item_list != NULL) - arg_count= item_list->elements; - - switch (arg_count) { - case 2: - { - Item *param_1= item_list->pop(); - Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_vtq_trx_seesX(thd, param_1, param_2); - break; - } - default: - my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); - break; - } - - return func; - } - - static Create_func_vtq_trx_sees s_singleton; - -protected: - Create_func_vtq_trx_sees() {} - virtual ~Create_func_vtq_trx_sees() {} -}; - -template -Create_func_vtq_trx_sees Create_func_vtq_trx_sees::s_singleton; - - -struct Native_func_registry -{ - LEX_STRING name; - Create_func *builder; -}; - #define BUILDER(F) & F::s_singleton #ifdef HAVE_SPATIAL @@ -7146,13 +6997,6 @@ static Native_func_registry func_array[] = { { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)}, { { C_STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)}, { { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)}, - { { C_STRING_WITH_LEN("VTQ_BEGIN_TS") }, BUILDER(Create_func_vtq)}, - { { C_STRING_WITH_LEN("VTQ_COMMIT_ID") }, BUILDER(Create_func_vtq)}, - { { C_STRING_WITH_LEN("VTQ_COMMIT_TS") }, BUILDER(Create_func_vtq)}, - { { C_STRING_WITH_LEN("VTQ_ISO_LEVEL") }, BUILDER(Create_func_vtq)}, - { { C_STRING_WITH_LEN("VTQ_TRX_ID") }, BUILDER(Create_func_vtq)}, - { { C_STRING_WITH_LEN("VTQ_TRX_SEES") }, BUILDER(Create_func_vtq_trx_sees)}, - { { C_STRING_WITH_LEN("VTQ_TRX_SEES_EQ") }, BUILDER(Create_func_vtq_trx_sees)}, { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)}, { { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)}, { { C_STRING_WITH_LEN("WITHIN") }, GEOM_BUILDER(Create_func_within)}, @@ -7182,8 +7026,6 @@ get_native_fct_hash_key(const uchar *buff, size_t *length, int item_create_init() { - Native_func_registry *func; - DBUG_ENTER("item_create_init"); if (my_hash_init(& native_functions_hash, @@ -7196,7 +7038,16 @@ int item_create_init() MYF(0))) DBUG_RETURN(1); - for (func= func_array; func->builder != NULL; func++) + DBUG_RETURN(item_create_append(func_array)); +} + +int item_create_append(Native_func_registry array[]) +{ + Native_func_registry *func; + + DBUG_ENTER("item_create_append"); + + for (func= array; func->builder != NULL; func++) { if (my_hash_insert(& native_functions_hash, (uchar*) func)) DBUG_RETURN(1); diff --git a/sql/item_create.h b/sql/item_create.h index 05fe48f656a..b8749a4513a 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -19,6 +19,8 @@ #ifndef ITEM_CREATE_H #define ITEM_CREATE_H +#include "item_func.h" // Cast_target + typedef struct st_udf_func udf_func; /** @@ -66,6 +68,37 @@ protected: }; +/** + Adapter for native functions with a variable number of arguments. + The main use of this class is to discard the following calls: + foo(expr1 AS name1, expr2 AS name2, ...) + which are syntactically correct (the syntax can refer to a UDF), + but semantically invalid for native functions. +*/ + +class Create_native_func : public Create_func +{ +public: + virtual Item *create_func(THD *thd, LEX_STRING name, List *item_list); + + /** + Builder method, with no arguments. + @param thd The current thread + @param name The native function name + @param item_list The function parameters, none of which are named + @return An item representing the function call + */ + virtual Item *create_native(THD *thd, LEX_STRING name, + List *item_list) = 0; + +protected: + /** Constructor. */ + Create_native_func() {} + /** Destructor. */ + virtual ~Create_native_func() {} +}; + + /** Function builder for qualified functions. This builder is used with functions call using a qualified function name @@ -183,7 +216,14 @@ Item *create_temporal_literal(THD *thd, const String *str, type, send_error); } +struct Native_func_registry +{ + LEX_STRING name; + Create_func *builder; +}; + int item_create_init(); +int item_create_append(Native_func_registry array[]); void item_create_cleanup(); Item *create_func_dyncol_create(THD *thd, List &list); diff --git a/sql/item_func.h b/sql/item_func.h index 0b398adb937..b7fb5d9cdfa 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -30,6 +30,9 @@ extern "C" /* Bug in BSDI include file */ } #endif +#include "sql_udf.h" // udf_handler +#include "my_decimal.h" // string2my_decimal + class Item_func :public Item_func_or_sum { diff --git a/sql/item_vers.cc b/sql/item_vers.cc index eff4c15db6b..3562cc7fbc9 100644 --- a/sql/item_vers.cc +++ b/sql/item_vers.cc @@ -25,57 +25,27 @@ Item_func_vtq_ts::Item_func_vtq_ts( THD *thd, - Item* a, - vtq_field_t _vtq_field, - handlerton* hton) : - VTQ_common(thd, a, hton), - vtq_field(_vtq_field) -{ - decimals= 6; - null_value= true; - DBUG_ASSERT(arg_count == 1 && args[0]); -} - -Item_func_vtq_ts::Item_func_vtq_ts( - THD *thd, + handlerton* hton, Item* a, vtq_field_t _vtq_field) : - VTQ_common(thd, a), + VTQ_common(thd, hton, a), vtq_field(_vtq_field) { decimals= 6; null_value= true; DBUG_ASSERT(arg_count == 1 && args[0]); + check_hton(); } template void -VTQ_common::init_hton() +VTQ_common::check_hton() { - if (!hton) + DBUG_ASSERT(hton); + if (!(hton->flags & HTON_NATIVE_SYS_VERSIONING) && hton->db_type != DB_TYPE_HEAP) { - if (Item_func_X::args[0]->type() == Item::FIELD_ITEM) - { - Item_field *f= - static_cast(Item_func_X::args[0]); - DBUG_ASSERT( - f->field && - f->field->table && - f->field->table->s && - f->field->table->s->db_plugin); - hton= f->field->table->file->partition_ht(); - DBUG_ASSERT(hton); - } - else if (innodb_plugin) - { - hton= plugin_hton(plugin_int_to_ref(innodb_plugin)); - DBUG_ASSERT(hton); - } - if (hton && !(hton->flags & HTON_NATIVE_SYS_VERSIONING)) - { - my_error(ER_VERS_ENGINE_UNSUPPORTED, MYF(0), Item::name ? Item::name : this->func_name()); - hton= NULL; - } + my_error(ER_VERS_ENGINE_UNSUPPORTED, MYF(0), Item::name ? Item::name : this->func_name()); + hton= NULL; } } @@ -92,8 +62,6 @@ Item_func_vtq_ts::get_date(MYSQL_TIME *res, ulonglong fuzzy_date) return false; } - init_hton(); - if (!hton) return true; @@ -106,10 +74,11 @@ Item_func_vtq_ts::get_date(MYSQL_TIME *res, ulonglong fuzzy_date) Item_func_vtq_id::Item_func_vtq_id( THD *thd, + handlerton *hton, Item* a, vtq_field_t _vtq_field, bool _backwards) : - VTQ_common(thd, a), + VTQ_common(thd, hton, a), vtq_field(_vtq_field), backwards(_backwards) { @@ -118,14 +87,16 @@ Item_func_vtq_id::Item_func_vtq_id( unsigned_flag= 1; null_value= true; DBUG_ASSERT(arg_count == 1 && args[0]); + check_hton(); } Item_func_vtq_id::Item_func_vtq_id( THD *thd, + handlerton *hton, Item* a, Item* b, vtq_field_t _vtq_field) : - VTQ_common(thd, a, b), + VTQ_common(thd, hton, a, b), vtq_field(_vtq_field), backwards(false) { @@ -134,6 +105,7 @@ Item_func_vtq_id::Item_func_vtq_id( unsigned_flag= 1; null_value= true; DBUG_ASSERT(arg_count == 2 && args[0] && args[1]); + check_hton(); } longlong @@ -186,8 +158,6 @@ Item_func_vtq_id::get_by_commit_ts(MYSQL_TIME &commit_ts, bool backwards) longlong Item_func_vtq_id::val_int() { - init_hton(); - if (!hton) { null_value= true; @@ -222,9 +192,10 @@ Item_func_vtq_id::val_int() Item_func_vtq_trx_sees::Item_func_vtq_trx_sees( THD *thd, + handlerton *hton, Item* a, Item* b) : - VTQ_common(thd, a, b), + VTQ_common(thd, hton, a, b), accept_eq(false) { null_value= true; @@ -237,8 +208,6 @@ Item_func_vtq_trx_sees::val_int() THD *thd= current_thd; DBUG_ASSERT(thd); - init_hton(); - if (!hton) { null_value= true; diff --git a/sql/item_vers.h b/sql/item_vers.h index aa5575ff9b1..86e0711e5d2 100644 --- a/sql/item_vers.h +++ b/sql/item_vers.h @@ -29,15 +29,12 @@ class VTQ_common : public Item_func_X { protected: handlerton *hton; - void init_hton(); + void check_hton(); public: - VTQ_common(THD *thd, Item* a) : - Item_func_X(thd, a), - hton(NULL) {} - VTQ_common(THD *thd, Item* a, Item* b) : + VTQ_common(THD *thd, handlerton* _hton, Item* a, Item* b) : Item_func_X(thd, a, b), - hton(NULL) {} - VTQ_common(THD *thd, Item* a, handlerton* _hton) : + hton(_hton) {} + VTQ_common(THD *thd, handlerton* _hton, Item* a) : Item_func_X(thd, a), hton(_hton) {} }; @@ -47,8 +44,7 @@ class Item_func_vtq_ts : { vtq_field_t vtq_field; public: - Item_func_vtq_ts(THD *thd, Item* a, vtq_field_t _vtq_field, handlerton *hton); - Item_func_vtq_ts(THD *thd, Item* a, vtq_field_t _vtq_field); + Item_func_vtq_ts(THD *thd, handlerton *hton, Item* a, vtq_field_t _vtq_field); const char *func_name() const { if (vtq_field == VTQ_BEGIN_TS) @@ -73,8 +69,8 @@ class Item_func_vtq_id : longlong get_by_commit_ts(MYSQL_TIME &commit_ts, bool backwards); public: - Item_func_vtq_id(THD *thd, Item* a, vtq_field_t _vtq_field, bool _backwards= false); - Item_func_vtq_id(THD *thd, Item* a, Item* b, vtq_field_t _vtq_field); + Item_func_vtq_id(THD *thd, handlerton *hton, Item* a, vtq_field_t _vtq_field, bool _backwards= false); + Item_func_vtq_id(THD *thd, handlerton *hton, Item* a, Item* b, vtq_field_t _vtq_field); vtq_record_t *vtq_cached_result() { return &cached_result; } @@ -112,7 +108,7 @@ protected: bool accept_eq; public: - Item_func_vtq_trx_sees(THD *thd, Item* a, Item* b); + Item_func_vtq_trx_sees(THD *thd, handlerton *hton, Item* a, Item* b); const char *func_name() const { return "vtq_trx_sees"; @@ -126,8 +122,8 @@ class Item_func_vtq_trx_sees_eq : public Item_func_vtq_trx_sees { public: - Item_func_vtq_trx_sees_eq(THD *thd, Item* a, Item* b) : - Item_func_vtq_trx_sees(thd, a, b) + Item_func_vtq_trx_sees_eq(THD *thd, handlerton *hton, Item* a, Item* b) : + Item_func_vtq_trx_sees(thd, hton, a, b) { accept_eq= true; } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 82fbb7c62cc..c307bc4f425 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -233,8 +233,6 @@ static int plugin_array_version=0; static bool initialized= 0; ulong dlopen_count; -st_plugin_int* innodb_plugin= NULL; - /* write-lock on LOCK_system_variables_hash is required before modifying @@ -1424,18 +1422,6 @@ static int plugin_initialize(MEM_ROOT *tmp_root, struct st_plugin_int *plugin, } state= PLUGIN_IS_READY; // plugin->init() succeeded - { - static const char * INNODB= "InnoDB"; - static const uint INNODB_LEN= strlen(INNODB); - - if (!my_strnncoll(&my_charset_latin1, - (const uchar *) plugin->name.str, plugin->name.length, - (const uchar *) INNODB, INNODB_LEN)) - { - innodb_plugin= plugin; - } - } - if (plugin->plugin->status_vars) { /* diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index e399fec8339..7b89246a9f9 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -160,8 +160,6 @@ extern ulong plugin_maturity; extern TYPELIB plugin_maturity_values; extern const char *plugin_maturity_names[]; -extern st_plugin_int* innodb_plugin; - extern int plugin_init(int *argc, char **argv, int init_flags); extern void plugin_shutdown(void); void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fef673b8c33..208946c1191 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -875,15 +875,14 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, DBUG_ASSERT(hton); row_start= newx Item_func_vtq_ts( thd, + hton, row_start, - VTQ_COMMIT_TS, - // FIXME: is it needed to pass hton or it can be deduced from arg 'a'? - hton); + VTQ_COMMIT_TS); row_end= newx Item_func_vtq_ts( thd, + hton, row_end, - VTQ_COMMIT_TS, - hton); + VTQ_COMMIT_TS); } Item *cond1= 0, *cond2= 0, *curr= 0; @@ -952,17 +951,17 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, break; case FOR_SYSTEM_TIME_AS_OF: trx_id0= vers_conditions.unit == UNIT_TIMESTAMP ? - newx Item_func_vtq_id(thd, vers_conditions.start, VTQ_TRX_ID) : + newx Item_func_vtq_id(thd, hton, vers_conditions.start, VTQ_TRX_ID) : vers_conditions.start; - cond1= newx Item_func_vtq_trx_sees_eq(thd, trx_id0, row_start); - cond2= newx Item_func_vtq_trx_sees(thd, row_end, trx_id0); + cond1= newx Item_func_vtq_trx_sees_eq(thd, hton, trx_id0, row_start); + cond2= newx Item_func_vtq_trx_sees(thd, hton, row_end, trx_id0); break; case FOR_SYSTEM_TIME_FROM_TO: case FOR_SYSTEM_TIME_BETWEEN: if (vers_conditions.unit == UNIT_TIMESTAMP) { - trx_id0= newx Item_func_vtq_id(thd, vers_conditions.start, VTQ_TRX_ID, true); - trx_id1= newx Item_func_vtq_id(thd, vers_conditions.end, VTQ_TRX_ID, false); + trx_id0= newx Item_func_vtq_id(thd, hton, vers_conditions.start, VTQ_TRX_ID, true); + trx_id1= newx Item_func_vtq_id(thd, hton, vers_conditions.end, VTQ_TRX_ID, false); } else { @@ -971,13 +970,13 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr, } cond1= vers_conditions.type == FOR_SYSTEM_TIME_FROM_TO ? - newx Item_func_vtq_trx_sees(thd, trx_id1, row_start) : - newx Item_func_vtq_trx_sees_eq(thd, trx_id1, row_start); - cond2= newx Item_func_vtq_trx_sees_eq(thd, row_end, trx_id0); + newx Item_func_vtq_trx_sees(thd, hton, trx_id1, row_start) : + newx Item_func_vtq_trx_sees_eq(thd, hton, trx_id1, row_start); + cond2= newx Item_func_vtq_trx_sees_eq(thd, hton, row_end, trx_id0); break; case FOR_SYSTEM_TIME_BEFORE: trx_id0= vers_conditions.unit == UNIT_TIMESTAMP ? - newx Item_func_vtq_id(thd, vers_conditions.start, VTQ_TRX_ID) : + newx Item_func_vtq_id(thd, hton, vers_conditions.start, VTQ_TRX_ID) : vers_conditions.start; cond1= newx Item_func_lt(thd, row_end, trx_id0); break; diff --git a/sql/vers_string.h b/sql/vers_string.h index ddd691276db..9f42692791b 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -60,6 +60,10 @@ struct LEX_STRING_u : public Storage { return *this; } + const LEX_STRING& lex_string() const + { + return *(LEX_STRING *)this; + } }; template >