mariadb/sql/item_vers.h

117 lines
3 KiB
C
Raw Normal View History

2017-03-09 06:16:53 +01:00
#ifndef ITEM_VERS_INCLUDED
#define ITEM_VERS_INCLUDED
/* Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
/* System Versioning items */
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
2018-04-17 08:53:44 +02:00
class Item_func_trt_ts: public Item_datetimefunc
2017-03-09 06:16:53 +01:00
{
2018-04-17 08:53:44 +02:00
TR_table::field_id_t trt_field;
2017-03-09 06:16:53 +01:00
public:
2018-04-17 08:53:44 +02:00
Item_func_trt_ts(THD *thd, Item* a, TR_table::field_id_t _trt_field);
2017-03-09 06:16:53 +01:00
const char *func_name() const
{
2018-04-17 08:53:44 +02:00
if (trt_field == TR_table::FLD_BEGIN_TS)
2017-03-09 06:16:53 +01:00
{
2018-04-17 08:53:44 +02:00
return "trt_begin_ts";
2017-03-09 06:16:53 +01:00
}
2018-04-17 08:53:44 +02:00
return "trt_commit_ts";
2017-03-09 06:16:53 +01:00
}
bool get_date(THD *thd, MYSQL_TIME *res, date_mode_t fuzzydate);
Item *get_copy(THD *thd)
2018-04-17 08:53:44 +02:00
{ return get_item_copy<Item_func_trt_ts>(thd, this); }
bool fix_length_and_dec()
{ fix_attributes_datetime(decimals); return FALSE; }
2017-03-09 06:16:53 +01:00
};
2018-04-17 08:53:44 +02:00
class Item_func_trt_id : public Item_longlong_func
2017-03-09 06:16:53 +01:00
{
2018-04-17 08:53:44 +02:00
TR_table::field_id_t trt_field;
2017-03-09 06:16:53 +01:00
bool backwards;
longlong get_by_trx_id(ulonglong trx_id);
longlong get_by_commit_ts(MYSQL_TIME &commit_ts, bool backwards);
public:
2018-04-17 08:53:44 +02:00
Item_func_trt_id(THD *thd, Item* a, TR_table::field_id_t _trt_field, bool _backwards= false);
Item_func_trt_id(THD *thd, Item* a, Item* b, TR_table::field_id_t _trt_field);
2017-03-09 06:16:53 +01:00
const char *func_name() const
{
2018-04-17 08:53:44 +02:00
switch (trt_field)
2017-03-09 06:16:53 +01:00
{
case TR_table::FLD_TRX_ID:
2018-04-17 08:53:44 +02:00
return "trt_trx_id";
case TR_table::FLD_COMMIT_ID:
2018-04-17 08:53:44 +02:00
return "trt_commit_id";
case TR_table::FLD_ISO_LEVEL:
2018-04-17 08:53:44 +02:00
return "trt_iso_level";
2017-03-09 06:16:53 +01:00
default:
DBUG_ASSERT(0);
}
return NULL;
}
bool fix_length_and_dec()
2017-03-09 06:16:53 +01:00
{
bool res= Item_int_func::fix_length_and_dec();
2017-03-09 06:16:53 +01:00
max_length= 20;
return res;
2017-03-09 06:16:53 +01:00
}
longlong val_int();
Item *get_copy(THD *thd)
2018-04-17 08:53:44 +02:00
{ return get_item_copy<Item_func_trt_id>(thd, this); }
2017-03-09 06:16:53 +01:00
};
2018-04-17 08:53:44 +02:00
class Item_func_trt_trx_sees : public Item_bool_func
2017-03-09 06:16:53 +01:00
{
protected:
bool accept_eq;
public:
2018-04-17 08:53:44 +02:00
Item_func_trt_trx_sees(THD *thd, Item* a, Item* b);
2017-03-09 06:16:53 +01:00
const char *func_name() const
{
2018-04-17 08:53:44 +02:00
return "trt_trx_sees";
2017-03-09 06:16:53 +01:00
}
longlong val_int();
Item *get_copy(THD *thd)
2018-04-17 08:53:44 +02:00
{ return get_item_copy<Item_func_trt_trx_sees>(thd, this); }
2017-03-09 06:16:53 +01:00
};
2018-04-17 08:53:44 +02:00
class Item_func_trt_trx_sees_eq :
public Item_func_trt_trx_sees
2017-03-09 06:16:53 +01:00
{
public:
2018-04-17 08:53:44 +02:00
Item_func_trt_trx_sees_eq(THD *thd, Item* a, Item* b) :
Item_func_trt_trx_sees(thd, a, b)
2017-03-09 06:16:53 +01:00
{
accept_eq= true;
}
const char *func_name() const
{
2018-04-17 08:53:44 +02:00
return "trt_trx_sees_eq";
2017-03-09 06:16:53 +01:00
}
};
#endif /* ITEM_VERS_INCLUDED */