diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2016-11-14 06:14:28 +0000 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2017-05-05 20:36:17 +0300 |
commit | d54d36c45e1eb14bb549dd225a28bea1d168754a (patch) | |
tree | 3630e2672aa5cd5a94e767dea7691c742ee84675 /sql/item_create.cc | |
parent | 07cc46acea56e7fdaab6ac3555ebc4cff078f1f0 (diff) | |
download | mariadb-git-d54d36c45e1eb14bb549dd225a28bea1d168754a.tar.gz |
IB, SQL: (0.4) COMMIT_ID-based ordering of transactions
IB:
* removed CONCURR_TRX from VTQ;
* new fields in VTQ: COMMIT_ID, ISO_LEVEL.
SQL:
* renamed BEGIN_TS, COMMIT_TS to VTQ_BEGIN_TS, VTQ_COMMIT_TS;
* new functions: VTQ_COMMIT_ID, VTQ_ISO_LEVEL, VTQ_TRX_ID, VTQ_TRX_SEES, VTQ_TRX_SEES_EQ;
* versioned SELECT for IB uses VTQ_TRX_SEES, VTQ_TRX_SEES_EQ.
Closes #71
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 122 |
1 files changed, 77 insertions, 45 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 48055ccb11e..7e8c60591e6 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -6678,24 +6678,26 @@ Create_func_year_week::create_native(THD *thd, LEX_STRING name, } -/* System Versioning: BEGIN_TS(), COMMIT_TS() */ - -class Create_func_begin_ts : public Create_native_func +/* System Versioning: VTQ_TRX_ID(), VTQ_COMMIT_ID(), VTQ_BEGIN_TS(), VTQ_COMMIT_TS(), VTQ_ISO_LEVEL() */ +template <vtq_field_t VTQ_FIELD> +class Create_func_vtq : public Create_native_func { public: virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list); - static Create_func_begin_ts s_singleton; + static Create_func_vtq<VTQ_FIELD> s_singleton; protected: - Create_func_begin_ts() {} - virtual ~Create_func_begin_ts() {} + Create_func_vtq<VTQ_FIELD>() {} + virtual ~Create_func_vtq<VTQ_FIELD>() {} }; -Create_func_begin_ts Create_func_begin_ts::s_singleton; +template<vtq_field_t VTQ_FIELD> +Create_func_vtq<VTQ_FIELD> Create_func_vtq<VTQ_FIELD>::s_singleton; +template <vtq_field_t VTQ_FIELD> Item* -Create_func_begin_ts::create_native(THD *thd, LEX_STRING name, +Create_func_vtq<VTQ_FIELD>::create_native(THD *thd, LEX_STRING name, List<Item> *item_list) { Item *func= NULL; @@ -6708,9 +6710,38 @@ Create_func_begin_ts::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_vtq_ts(thd, param_1, VTQ_BEGIN_TS); + 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); @@ -6719,49 +6750,45 @@ Create_func_begin_ts::create_native(THD *thd, LEX_STRING name, } return func; -} +}; -class Create_func_commit_ts : public Create_native_func +template <class Item_func_vtq_trx_seesX> +class Create_func_vtq_trx_sees : public Create_native_func { public: - virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list); - - static Create_func_commit_ts s_singleton; - -protected: - Create_func_commit_ts() {} - virtual ~Create_func_commit_ts() {} -}; - -Create_func_commit_ts Create_func_commit_ts::s_singleton; + virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list) + { + Item *func= NULL; + int arg_count= 0; -Item* -Create_func_commit_ts::create_native(THD *thd, LEX_STRING name, - List<Item> *item_list) -{ - Item *func= NULL; - int arg_count= 0; + if (item_list != NULL) + arg_count= item_list->elements; - 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; + } - switch (arg_count) { - case 1: - { - Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_vtq_ts(thd, param_1, VTQ_COMMIT_TS); - break; - } - default: - { - my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); - break; - } + return func; } - return func; -} + static Create_func_vtq_trx_sees<Item_func_vtq_trx_seesX> s_singleton; + +protected: + Create_func_vtq_trx_sees<Item_func_vtq_trx_seesX>() {} + virtual ~Create_func_vtq_trx_sees<Item_func_vtq_trx_seesX>() {} +}; +template<class X> +Create_func_vtq_trx_sees<X> Create_func_vtq_trx_sees<X>::s_singleton; struct Native_func_registry @@ -6804,7 +6831,6 @@ static Native_func_registry func_array[] = { { C_STRING_WITH_LEN("ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)}, { { C_STRING_WITH_LEN("ATAN") }, BUILDER(Create_func_atan)}, { { C_STRING_WITH_LEN("ATAN2") }, BUILDER(Create_func_atan)}, - { { C_STRING_WITH_LEN("BEGIN_TS") }, BUILDER(Create_func_begin_ts)}, { { C_STRING_WITH_LEN("BENCHMARK") }, BUILDER(Create_func_benchmark)}, { { C_STRING_WITH_LEN("BIN") }, BUILDER(Create_func_bin)}, { { C_STRING_WITH_LEN("BINLOG_GTID_POS") }, BUILDER(Create_func_binlog_gtid_pos)}, @@ -6822,7 +6848,6 @@ static Native_func_registry func_array[] = { { C_STRING_WITH_LEN("COLUMN_EXISTS") }, BUILDER(Create_func_dyncol_exists)}, { { C_STRING_WITH_LEN("COLUMN_LIST") }, BUILDER(Create_func_dyncol_list)}, { { C_STRING_WITH_LEN("COLUMN_JSON") }, BUILDER(Create_func_dyncol_json)}, - { { C_STRING_WITH_LEN("COMMIT_TS") }, BUILDER(Create_func_commit_ts)}, { { C_STRING_WITH_LEN("COMPRESS") }, BUILDER(Create_func_compress)}, { { C_STRING_WITH_LEN("CONCAT") }, BUILDER(Create_func_concat)}, { { C_STRING_WITH_LEN("CONCAT_WS") }, BUILDER(Create_func_concat_ws)}, @@ -7121,6 +7146,13 @@ 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<VTQ_BEGIN_TS>)}, + { { C_STRING_WITH_LEN("VTQ_COMMIT_ID") }, BUILDER(Create_func_vtq<VTQ_COMMIT_ID>)}, + { { C_STRING_WITH_LEN("VTQ_COMMIT_TS") }, BUILDER(Create_func_vtq<VTQ_COMMIT_TS>)}, + { { C_STRING_WITH_LEN("VTQ_ISO_LEVEL") }, BUILDER(Create_func_vtq<VTQ_ISO_LEVEL>)}, + { { C_STRING_WITH_LEN("VTQ_TRX_ID") }, BUILDER(Create_func_vtq<VTQ_TRX_ID>)}, + { { C_STRING_WITH_LEN("VTQ_TRX_SEES") }, BUILDER(Create_func_vtq_trx_sees<Item_func_vtq_trx_sees>)}, + { { C_STRING_WITH_LEN("VTQ_TRX_SEES_EQ") }, BUILDER(Create_func_vtq_trx_sees<Item_func_vtq_trx_sees_eq>)}, { { 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)}, |