summaryrefslogtreecommitdiff
path: root/sql/item_vers.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2017-11-10 17:54:46 +0300
committerAleksey Midenkov <midenok@gmail.com>2017-11-15 00:22:10 +0300
commit33085349e97a5b5c768c38c6f8bed11c666c0643 (patch)
tree83382bd488d28cf114b211a255247cb07cb1d9be /sql/item_vers.cc
parentfa79f6ac86c700c23041dd0f314a71bbfb1f4bdf (diff)
downloadmariadb-git-33085349e97a5b5c768c38c6f8bed11c666c0643.tar.gz
IB, SQL: removed VTQ, added TRT on SQL layer [closes #305]
Diffstat (limited to 'sql/item_vers.cc')
-rw-r--r--sql/item_vers.cc143
1 files changed, 31 insertions, 112 deletions
diff --git a/sql/item_vers.cc b/sql/item_vers.cc
index 82577a767ea..bae515a6ede 100644
--- a/sql/item_vers.cc
+++ b/sql/item_vers.cc
@@ -23,32 +23,15 @@
#include "tztime.h"
#include "item.h"
-Item_func_vtq_ts::Item_func_vtq_ts(
- THD *thd,
- handlerton* hton,
- Item* a,
- vtq_field_t _vtq_field) :
- VTQ_common<Item_datetimefunc>(thd, hton, a),
+Item_func_vtq_ts::Item_func_vtq_ts(THD *thd, Item* a, TR_table::field_id_t _vtq_field) :
+ Item_datetimefunc(thd, a),
vtq_field(_vtq_field)
{
decimals= 6;
null_value= true;
DBUG_ASSERT(arg_count == 1 && args[0]);
- check_hton();
}
-template <class Item_func_X>
-void
-VTQ_common<Item_func_X>::check_hton()
-{
- DBUG_ASSERT(hton);
- if (!(hton->flags & HTON_NATIVE_SYS_VERSIONING) && hton->db_type != DB_TYPE_HEAP)
- {
- my_error(ER_VERS_ENGINE_UNSUPPORTED, MYF(0), this->Item::name.str ?
- this->Item::name.str : this->func_name());
- hton= NULL;
- }
-}
bool
Item_func_vtq_ts::get_date(MYSQL_TIME *res, ulonglong fuzzy_date)
@@ -72,58 +55,46 @@ Item_func_vtq_ts::get_date(MYSQL_TIME *res, ulonglong fuzzy_date)
return false;
}
- DBUG_ASSERT(hton && hton->vers_query_trx_id);
- null_value= !hton->vers_query_trx_id(thd, res, trx_id, vtq_field);
+ TR_table trt(thd);
+
+ null_value= !trt.query(trx_id);
if (null_value)
{
my_error(ER_VERS_NO_TRX_ID, MYF(0), trx_id);
+ return true;
}
- return null_value;
+ return trt[vtq_field]->get_date(res, 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<Item_longlong_func>(thd, hton, a),
+Item_func_vtq_id::Item_func_vtq_id(THD *thd, Item* a, TR_table::field_id_t _vtq_field,
+ bool _backwards) :
+ Item_longlong_func(thd, a),
vtq_field(_vtq_field),
backwards(_backwards)
{
- memset(&cached_result, 0, sizeof(cached_result));
decimals= 0;
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<Item_longlong_func>(thd, hton, a, b),
+Item_func_vtq_id::Item_func_vtq_id(THD *thd, Item* a, Item* b, TR_table::field_id_t _vtq_field) :
+ Item_longlong_func(thd, a, b),
vtq_field(_vtq_field),
backwards(false)
{
- memset(&cached_result, 0, sizeof(cached_result));
decimals= 0;
unsigned_flag= 1;
null_value= true;
DBUG_ASSERT(arg_count == 2 && args[0] && args[1]);
- check_hton();
}
longlong
Item_func_vtq_id::get_by_trx_id(ulonglong trx_id)
{
- ulonglong res;
- THD *thd= current_thd; // can it differ from constructor's?
+ THD *thd= current_thd;
DBUG_ASSERT(thd);
if (trx_id == ULONGLONG_MAX)
@@ -132,52 +103,34 @@ Item_func_vtq_id::get_by_trx_id(ulonglong trx_id)
return 0;
}
- DBUG_ASSERT(hton->vers_query_trx_id);
- null_value= !hton->vers_query_trx_id(thd, &res, trx_id, vtq_field);
- return res;
+ TR_table trt(thd);
+ null_value= !trt.query(trx_id);
+ if (null_value)
+ return 0;
+
+ return trt[vtq_field]->val_int();
}
longlong
Item_func_vtq_id::get_by_commit_ts(MYSQL_TIME &commit_ts, bool backwards)
{
- THD *thd= current_thd; // can it differ from constructor's?
+ THD *thd= current_thd;
DBUG_ASSERT(thd);
- DBUG_ASSERT(hton->vers_query_commit_ts);
- null_value= !hton->vers_query_commit_ts(thd, &cached_result, commit_ts, VTQ_ALL, backwards);
+ TR_table trt(thd);
+ null_value= !trt.query(commit_ts, backwards);
if (null_value)
- {
return 0;
- }
-
- switch (vtq_field)
- {
- case VTQ_COMMIT_ID:
- return cached_result.commit_id;
- case VTQ_ISO_LEVEL:
- return cached_result.iso_level;
- case VTQ_TRX_ID:
- return cached_result.trx_id;
- default:
- DBUG_ASSERT(0);
- null_value= true;
- }
- return 0;
+ return trt[vtq_field]->val_int();
}
longlong
Item_func_vtq_id::val_int()
{
- if (!hton)
- {
- null_value= true;
- return 0;
- }
-
if (args[0]->is_null())
{
- if (arg_count < 2 || vtq_field == VTQ_TRX_ID)
+ if (arg_count < 2 || vtq_field == TR_table::FLD_TRX_ID)
{
null_value= true;
return 0;
@@ -201,12 +154,8 @@ 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<Item_bool_func>(thd, hton, a, b),
+Item_func_vtq_trx_sees::Item_func_vtq_trx_sees(THD *thd, Item* a, Item* b) :
+ Item_bool_func(thd, a, b),
accept_eq(false)
{
null_value= true;
@@ -219,42 +168,12 @@ Item_func_vtq_trx_sees::val_int()
THD *thd= current_thd;
DBUG_ASSERT(thd);
- if (!hton)
- {
- null_value= true;
- return 0;
- }
-
- ulonglong trx_id1, trx_id0;
- ulonglong commit_id1= 0;
- ulonglong commit_id0= 0;
- uchar iso_level1= 0;
-
DBUG_ASSERT(arg_count > 1);
- trx_id1= args[0]->val_uint();
- trx_id0= args[1]->val_uint();
-
- vtq_record_t *cached= args[0]->vtq_cached_result();
- if (cached && cached->commit_id)
- {
- commit_id1= cached->commit_id;
- iso_level1= cached->iso_level;
- }
-
- cached= args[1]->vtq_cached_result();
- if (cached && cached->commit_id)
- {
- commit_id0= cached->commit_id;
- }
-
- if (accept_eq && trx_id1 && trx_id1 == trx_id0)
- {
- null_value= false;
- return true;
- }
+ ulonglong trx_id1= args[0]->val_uint();
+ ulonglong trx_id0= args[1]->val_uint();
+ bool result= accept_eq;
- DBUG_ASSERT(hton->vers_trx_sees);
- bool result= false;
- null_value= !hton->vers_trx_sees(thd, result, trx_id1, trx_id0, commit_id1, iso_level1, commit_id0);
+ TR_table trt(thd);
+ null_value= trt.query_sees(result, trx_id1, trx_id0);
return result;
}