| 1 | #ifndef ITEM_VERS_INCLUDED |
| 2 | #define ITEM_VERS_INCLUDED |
| 3 | /* Copyright (c) 2017, MariaDB Corporation. |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ |
| 17 | |
| 18 | |
| 19 | /* System Versioning items */ |
| 20 | |
| 21 | #ifdef USE_PRAGMA_INTERFACE |
| 22 | #pragma interface /* gcc class implementation */ |
| 23 | #endif |
| 24 | |
| 25 | class Item_func_trt_ts: public Item_datetimefunc |
| 26 | { |
| 27 | TR_table::field_id_t trt_field; |
| 28 | public: |
| 29 | Item_func_trt_ts(THD *thd, Item* a, TR_table::field_id_t _trt_field); |
| 30 | const char *func_name() const |
| 31 | { |
| 32 | if (trt_field == TR_table::FLD_BEGIN_TS) |
| 33 | { |
| 34 | return "trt_begin_ts" ; |
| 35 | } |
| 36 | return "trt_commit_ts" ; |
| 37 | } |
| 38 | bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); |
| 39 | Item *get_copy(THD *thd) |
| 40 | { return get_item_copy<Item_func_trt_ts>(thd, this); } |
| 41 | void fix_length_and_dec() { fix_attributes_datetime(decimals); } |
| 42 | }; |
| 43 | |
| 44 | class Item_func_trt_id : public Item_longlong_func |
| 45 | { |
| 46 | TR_table::field_id_t trt_field; |
| 47 | bool backwards; |
| 48 | |
| 49 | longlong get_by_trx_id(ulonglong trx_id); |
| 50 | longlong get_by_commit_ts(MYSQL_TIME &commit_ts, bool backwards); |
| 51 | |
| 52 | public: |
| 53 | Item_func_trt_id(THD *thd, Item* a, TR_table::field_id_t _trt_field, bool _backwards= false); |
| 54 | Item_func_trt_id(THD *thd, Item* a, Item* b, TR_table::field_id_t _trt_field); |
| 55 | |
| 56 | const char *func_name() const |
| 57 | { |
| 58 | switch (trt_field) |
| 59 | { |
| 60 | case TR_table::FLD_TRX_ID: |
| 61 | return "trt_trx_id" ; |
| 62 | case TR_table::FLD_COMMIT_ID: |
| 63 | return "trt_commit_id" ; |
| 64 | case TR_table::FLD_ISO_LEVEL: |
| 65 | return "trt_iso_level" ; |
| 66 | default: |
| 67 | DBUG_ASSERT(0); |
| 68 | } |
| 69 | return NULL; |
| 70 | } |
| 71 | |
| 72 | void fix_length_and_dec() |
| 73 | { |
| 74 | Item_int_func::fix_length_and_dec(); |
| 75 | max_length= 20; |
| 76 | } |
| 77 | |
| 78 | longlong val_int(); |
| 79 | Item *get_copy(THD *thd) |
| 80 | { return get_item_copy<Item_func_trt_id>(thd, this); } |
| 81 | }; |
| 82 | |
| 83 | class Item_func_trt_trx_sees : public Item_bool_func |
| 84 | { |
| 85 | protected: |
| 86 | bool accept_eq; |
| 87 | |
| 88 | public: |
| 89 | Item_func_trt_trx_sees(THD *thd, Item* a, Item* b); |
| 90 | const char *func_name() const |
| 91 | { |
| 92 | return "trt_trx_sees" ; |
| 93 | } |
| 94 | longlong val_int(); |
| 95 | Item *get_copy(THD *thd) |
| 96 | { return get_item_copy<Item_func_trt_trx_sees>(thd, this); } |
| 97 | }; |
| 98 | |
| 99 | class Item_func_trt_trx_sees_eq : |
| 100 | public Item_func_trt_trx_sees |
| 101 | { |
| 102 | public: |
| 103 | Item_func_trt_trx_sees_eq(THD *thd, Item* a, Item* b) : |
| 104 | Item_func_trt_trx_sees(thd, a, b) |
| 105 | { |
| 106 | accept_eq= true; |
| 107 | } |
| 108 | const char *func_name() const |
| 109 | { |
| 110 | return "trt_trx_sees_eq" ; |
| 111 | } |
| 112 | }; |
| 113 | |
| 114 | #endif /* ITEM_VERS_INCLUDED */ |
| 115 | |