1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-16144 Default TIMESTAMP clause for SELECT from versioned

1. Removed TIMESTAMP/TRANSACTION unit auto-detection in favor of default TIMESTAMP.

Reasons:

1.1. rare practical use and doubtful advantage of such auto-detection;
1.2. it conflicts with MDEV-16226 (TRX_ID-based versioned tables performance improvement).

Needless check_unit membership removed.

2. SQL: versioning type handling refactoring

Vers_type_handler hierarchy stores versioning properties of type.

virtual Type_handler::vers() accesses specialization of
Vers_type_handler for specific type.

virtual Vers_type_handler::kind() returns versioning kind
(timestamp/trx_id).

Removed Type_handler::Vers_history_point_check_unit() in favor of
Type_handler::vers().

Renames:

require_timestamp() -> require_timestamp_error()
require_trx_id() -> require_trx_id_error()

EDIT by Alexander Barkov (@abarkov):

check_sys_fields() moved to Vers_type_handler::check_sys_fields()
This commit is contained in:
Aleksey Midenkov
2018-08-28 19:45:34 +03:00
parent f610529d23
commit 58fdf5b2fa
17 changed files with 238 additions and 290 deletions

View File

@ -3238,6 +3238,59 @@ public:
};
enum vers_sys_type_t
{
VERS_UNDEFINED= 0,
VERS_TIMESTAMP,
VERS_TRX_ID
};
class Vers_type_handler
{
protected:
Vers_type_handler() {}
public:
virtual ~Vers_type_handler() {}
virtual vers_sys_type_t kind() const
{
DBUG_ASSERT(0);
return VERS_UNDEFINED;
}
virtual bool check_sys_fields(const LEX_CSTRING &table_name,
const Column_definition *row_start,
const Column_definition *row_end) const= 0;
};
class Vers_type_timestamp: public Vers_type_handler
{
public:
virtual vers_sys_type_t kind() const
{
return VERS_TIMESTAMP;
}
bool check_sys_fields(const LEX_CSTRING &table_name,
const Column_definition *row_start,
const Column_definition *row_end) const;
};
extern MYSQL_PLUGIN_IMPORT Vers_type_timestamp vers_type_timestamp;
class Vers_type_trx: public Vers_type_handler
{
public:
virtual vers_sys_type_t kind() const
{
return VERS_TRX_ID;
}
bool check_sys_fields(const LEX_CSTRING &table_name,
const Column_definition *row_start,
const Column_definition *row_end) const;
};
extern MYSQL_PLUGIN_IMPORT Vers_type_trx vers_type_trx;
class Type_handler
{
protected:
@ -3419,10 +3472,6 @@ public:
{
return this;
}
virtual const Type_handler *type_handler_for_system_time() const
{
return this;
}
virtual const Type_handler *type_handler_unsigned() const
{
return this;
@ -3908,8 +3957,7 @@ public:
virtual bool
Item_func_mod_fix_length_and_dec(Item_func_mod *func) const= 0;
virtual bool
Vers_history_point_resolve_unit(THD *thd, Vers_history_point *point) const;
virtual const Vers_type_handler *vers() const { return NULL; }
};
@ -4750,6 +4798,7 @@ public:
bool Item_func_div_fix_length_and_dec(Item_func_div *) const;
bool Item_func_mod_fix_length_and_dec(Item_func_mod *) const;
const Vers_type_handler *vers() const override { return &vers_type_trx; }
};
@ -4762,8 +4811,7 @@ public:
{
return type_limits_int()->char_length();
}
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p)
const override;
const Vers_type_handler *vers() const override { return &vers_type_trx; }
};
@ -4836,8 +4884,7 @@ public:
bool Item_func_mul_fix_length_and_dec(Item_func_mul *) const override;
bool Item_func_div_fix_length_and_dec(Item_func_div *) const override;
bool Item_func_mod_fix_length_and_dec(Item_func_mod *) const override;
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p)
const override;
const Vers_type_handler *vers() const override { return &vers_type_timestamp; }
};
@ -4990,6 +5037,7 @@ public:
bool Item_func_mul_fix_length_and_dec(Item_func_mul *) const override;
bool Item_func_div_fix_length_and_dec(Item_func_div *) const override;
bool Item_func_mod_fix_length_and_dec(Item_func_mod *) const override;
const Vers_type_handler *vers() const override { return &vers_type_timestamp; }
};
@ -4997,8 +5045,6 @@ class Type_handler_general_purpose_string: public Type_handler_string_result
{
public:
bool is_general_purpose_string_type() const override { return true; }
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p)
const override;
};
@ -5390,6 +5436,7 @@ public:
MYSQL_TIME *to,
date_mode_t fuzzydate)
const override;
const Vers_type_handler *vers() const override { return NULL; }
};
@ -5447,8 +5494,6 @@ public:
const Bit_addr &bit,
const Column_definition_attributes *attr,
uint32 flags) const override;
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p)
const override;
};
@ -6456,7 +6501,6 @@ public:
virtual ~Type_handler_hex_hybrid() {}
const Name name() const override;
const Type_handler *cast_to_int_type_handler() const override;
const Type_handler *type_handler_for_system_time() const override;
};
@ -6545,6 +6589,7 @@ public:
const Bit_addr &bit,
const Column_definition_attributes *attr,
uint32 flags) const override;
const Vers_type_handler *vers() const override { return &vers_type_timestamp; }
};
@ -6675,8 +6720,7 @@ public:
const override;
void Item_param_set_param_func(Item_param *param,
uchar **pos, ulong len) const override;
bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *p)
const override;
const Vers_type_handler *vers() const override { return NULL; }
};