cleanup: versioning style fixes
rename LString/XString classes, remove unused ones
This commit is contained in:
parent
531acda484
commit
b1a6d2826a
@ -4514,7 +4514,7 @@ int ha_partition::delete_row(const uchar *buf)
|
||||
or last historical partition, but DELETE HISTORY can delete from any
|
||||
historical partition. So, skip the check in this case.
|
||||
*/
|
||||
if (!thd->lex->vers_conditions) // if not DELETE HISTORY
|
||||
if (!thd->lex->vers_conditions.is_set()) // if not DELETE HISTORY
|
||||
{
|
||||
uint32 part_id;
|
||||
error= get_part_for_buf(buf, m_rec0, m_part_info, &part_id);
|
||||
|
@ -4767,7 +4767,8 @@ void handler::update_global_table_stats()
|
||||
if (rows_read + rows_changed == 0)
|
||||
return; // Nothing to update.
|
||||
|
||||
DBUG_ASSERT(table->s && table->s->table_cache_key.str);
|
||||
DBUG_ASSERT(table->s);
|
||||
DBUG_ASSERT(table->s->table_cache_key.str);
|
||||
|
||||
mysql_mutex_lock(&LOCK_global_table_stats);
|
||||
/* Gets the global table stats, creating one if necessary. */
|
||||
@ -6371,7 +6372,8 @@ void handler::use_hidden_primary_key()
|
||||
Handler_share *handler::get_ha_share_ptr()
|
||||
{
|
||||
DBUG_ENTER("handler::get_ha_share_ptr");
|
||||
DBUG_ASSERT(ha_share && table_share);
|
||||
DBUG_ASSERT(ha_share);
|
||||
DBUG_ASSERT(table_share);
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
if (table_share->tmp_table == NO_TMP_TABLE)
|
||||
@ -6882,8 +6884,8 @@ static bool vers_create_sys_field(THD *thd, const char *field_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
const LString_i Vers_parse_info::default_start= "row_start";
|
||||
const LString_i Vers_parse_info::default_end= "row_end";
|
||||
const Lex_ident Vers_parse_info::default_start= "row_start";
|
||||
const Lex_ident Vers_parse_info::default_end= "row_end";
|
||||
|
||||
bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info)
|
||||
{
|
||||
@ -7077,10 +7079,12 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
|
||||
// copy info from existing table
|
||||
create_info->options|= HA_VERSIONED_TABLE;
|
||||
|
||||
DBUG_ASSERT(share->vers_start_field() && share->vers_end_field());
|
||||
LString_i start(share->vers_start_field()->field_name);
|
||||
LString_i end(share->vers_end_field()->field_name);
|
||||
DBUG_ASSERT(start.ptr() && end.ptr());
|
||||
DBUG_ASSERT(share->vers_start_field());
|
||||
DBUG_ASSERT(share->vers_end_field());
|
||||
Lex_ident start(share->vers_start_field()->field_name);
|
||||
Lex_ident end(share->vers_end_field()->field_name);
|
||||
DBUG_ASSERT(start.str);
|
||||
DBUG_ASSERT(end.str);
|
||||
|
||||
as_row= start_end_t(start, end);
|
||||
system_time= as_row;
|
||||
@ -7184,8 +7188,8 @@ bool Vers_parse_info::need_check(const Alter_info *alter_info) const
|
||||
alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING || *this;
|
||||
}
|
||||
|
||||
bool Vers_parse_info::check_conditions(const LString &table_name,
|
||||
const LString &db) const
|
||||
bool Vers_parse_info::check_conditions(const Lex_table_name &table_name,
|
||||
const Lex_table_name &db) const
|
||||
{
|
||||
if (!as_row.start || !as_row.end)
|
||||
{
|
||||
@ -7215,7 +7219,8 @@ bool Vers_parse_info::check_conditions(const LString &table_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Vers_parse_info::check_sys_fields(const LString &table_name, const LString &db,
|
||||
bool Vers_parse_info::check_sys_fields(const Lex_table_name &table_name,
|
||||
const Lex_table_name &db,
|
||||
Alter_info *alter_info, bool native)
|
||||
{
|
||||
if (check_conditions(table_name, db))
|
||||
|
@ -1922,15 +1922,15 @@ struct Vers_parse_info
|
||||
start_end_t(LEX_CSTRING _start, LEX_CSTRING _end) :
|
||||
start(_start),
|
||||
end(_end) {}
|
||||
LString_i start;
|
||||
LString_i end;
|
||||
Lex_ident start;
|
||||
Lex_ident end;
|
||||
};
|
||||
|
||||
start_end_t system_time;
|
||||
start_end_t as_row;
|
||||
vers_sys_type_t check_unit;
|
||||
|
||||
void set_system_time(LString start, LString end)
|
||||
void set_system_time(Lex_ident start, Lex_ident end)
|
||||
{
|
||||
system_time.start= start;
|
||||
system_time.end= end;
|
||||
@ -1958,16 +1958,18 @@ protected:
|
||||
return as_row.start || as_row.end || system_time.start || system_time.end;
|
||||
}
|
||||
bool need_check(const Alter_info *alter_info) const;
|
||||
bool check_conditions(const LString &table_name, const LString &db) const;
|
||||
bool check_conditions(const Lex_table_name &table_name,
|
||||
const Lex_table_name &db) const;
|
||||
public:
|
||||
static const LString_i default_start;
|
||||
static const LString_i default_end;
|
||||
static const Lex_ident default_start;
|
||||
static const Lex_ident default_end;
|
||||
|
||||
bool fix_alter_info(THD *thd, Alter_info *alter_info,
|
||||
HA_CREATE_INFO *create_info, TABLE *table);
|
||||
bool fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_info,
|
||||
TABLE_LIST &src_table, TABLE_LIST &table);
|
||||
bool check_sys_fields(const LString &table_name, const LString &db,
|
||||
bool check_sys_fields(const Lex_table_name &table_name,
|
||||
const Lex_table_name &db,
|
||||
Alter_info *alter_info, bool native);
|
||||
|
||||
/**
|
||||
|
@ -199,8 +199,8 @@ uint get_table_def_key(const TABLE_LIST *table_list, const char **key)
|
||||
from key used by MDL subsystem.
|
||||
*/
|
||||
DBUG_ASSERT(!strcmp(table_list->get_db_name(),
|
||||
table_list->mdl_request.key.db_name()) &&
|
||||
!strcmp(table_list->get_table_name(),
|
||||
table_list->mdl_request.key.db_name()));
|
||||
DBUG_ASSERT(!strcmp(table_list->get_table_name(),
|
||||
table_list->mdl_request.key.name()));
|
||||
|
||||
*key= (const char*)table_list->mdl_request.key.ptr() + 1;
|
||||
|
@ -305,7 +305,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
|
||||
THD_STAGE_INFO(thd, stage_init_update);
|
||||
|
||||
bool truncate_history= table_list->vers_conditions;
|
||||
bool truncate_history= table_list->vers_conditions.is_set();
|
||||
if (truncate_history)
|
||||
{
|
||||
if (table_list->is_view_or_derived())
|
||||
@ -941,7 +941,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list,
|
||||
select_lex->leaf_tables, FALSE,
|
||||
DELETE_ACL, SELECT_ACL, TRUE))
|
||||
DBUG_RETURN(TRUE);
|
||||
if (table_list->vers_conditions)
|
||||
if (table_list->vers_conditions.is_set())
|
||||
{
|
||||
if (table_list->is_view())
|
||||
{
|
||||
|
@ -9419,7 +9419,7 @@ bool update_precheck(THD *thd, TABLE_LIST *tables)
|
||||
bool delete_precheck(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
DBUG_ENTER("delete_precheck");
|
||||
if (tables->vers_conditions)
|
||||
if (tables->vers_conditions.is_set())
|
||||
{
|
||||
if (check_one_table_access(thd, DELETE_HISTORY_ACL, tables))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
@ -693,7 +693,7 @@ bool vers_select_conds_t::init_from_sysvar(THD *thd)
|
||||
return false;
|
||||
}
|
||||
|
||||
void vers_select_conds_t::print(String *str, enum_query_type query_type)
|
||||
void vers_select_conds_t::print(String *str, enum_query_type query_type) const
|
||||
{
|
||||
switch (type) {
|
||||
case SYSTEM_TIME_UNSPECIFIED:
|
||||
@ -765,14 +765,14 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
TABLE_LIST* derived= master_unit()->derived;
|
||||
// inner SELECT may not be a derived table (derived == NULL)
|
||||
while (derived && outer_slex && !derived->vers_conditions)
|
||||
while (derived && outer_slex && !derived->vers_conditions.is_set())
|
||||
{
|
||||
derived= outer_slex->master_unit()->derived;
|
||||
outer_slex= outer_slex->outer_select();
|
||||
}
|
||||
if (derived && outer_slex)
|
||||
{
|
||||
DBUG_ASSERT(derived->vers_conditions);
|
||||
DBUG_ASSERT(derived->vers_conditions.is_set());
|
||||
outer_table= derived;
|
||||
}
|
||||
}
|
||||
@ -791,7 +791,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
*/
|
||||
if (table->partition_names && table->table->part_info->vers_info)
|
||||
{
|
||||
if (vers_conditions)
|
||||
if (vers_conditions.is_set())
|
||||
{
|
||||
#define PART_VERS_ERR_MSG "%s PARTITION (%s)"
|
||||
char buf[NAME_LEN*2 + sizeof(PART_VERS_ERR_MSG)];
|
||||
@ -805,7 +805,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (outer_table && !vers_conditions)
|
||||
if (outer_table && !vers_conditions.is_set())
|
||||
{
|
||||
// propagate system_time from nearest outer SELECT_LEX
|
||||
vers_conditions= outer_table->vers_conditions;
|
||||
@ -813,15 +813,15 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
}
|
||||
|
||||
// propagate system_time from sysvar
|
||||
if (!vers_conditions)
|
||||
if (!vers_conditions.is_set())
|
||||
{
|
||||
if (vers_conditions.init_from_sysvar(thd))
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
if (vers_conditions)
|
||||
if (vers_conditions.is_set())
|
||||
{
|
||||
if (vers_conditions == SYSTEM_TIME_ALL)
|
||||
if (vers_conditions.type == SYSTEM_TIME_ALL)
|
||||
continue;
|
||||
|
||||
lock_type= TL_READ; // ignore TL_WRITE, history is immutable anyway
|
||||
@ -837,7 +837,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
|
||||
bool timestamps_only= table->table->versioned(VERS_TIMESTAMP);
|
||||
|
||||
if (vers_conditions)
|
||||
if (vers_conditions.is_set())
|
||||
{
|
||||
/* TODO: do resolve fix_length_and_dec(), fix_fields(). This requires
|
||||
storing vers_conditions as Item and make some magic related to
|
||||
|
@ -990,9 +990,9 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg,
|
||||
{
|
||||
if (!with_element->is_anchor(sl))
|
||||
sl->uncacheable|= UNCACHEABLE_UNITED;
|
||||
if(!is_rec_result_table_created &&
|
||||
(!sl->next_select() ||
|
||||
sl->next_select() == with_element->first_recursive))
|
||||
if (!is_rec_result_table_created &&
|
||||
(!sl->next_select() ||
|
||||
sl->next_select() == with_element->first_recursive))
|
||||
{
|
||||
ulonglong create_options;
|
||||
create_options= (first_sl->options | thd->variables.option_bits |
|
||||
|
@ -609,7 +609,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
|
||||
if (!fld)
|
||||
continue;
|
||||
TABLE_SHARE *s= fld->field->table->s;
|
||||
const LString_i field_name= fld->field->field_name;
|
||||
const Lex_ident field_name= fld->field->field_name;
|
||||
if (s->tmp_table ||
|
||||
(s->versioned &&
|
||||
(field_name.streq(s->vers_start_field()->field_name) ||
|
||||
@ -2040,7 +2040,7 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view)
|
||||
if ((fld= entry->item->field_for_view_update()))
|
||||
{
|
||||
TABLE_SHARE *s= fld->context->table_list->table->s;
|
||||
LString_i field_name= fld->field_name;
|
||||
Lex_ident field_name= fld->field_name;
|
||||
if (s->versioned &&
|
||||
(field_name.streq(s->vers_start_field()->field_name) ||
|
||||
field_name.streq(s->vers_end_field()->field_name)))
|
||||
|
@ -6628,7 +6628,7 @@ field_def:
|
||||
Vers_parse_info &info= lex->vers_get_info();
|
||||
const LEX_CSTRING &field_name= lex->last_field->field_name;
|
||||
|
||||
LString_i *p;
|
||||
Lex_ident *p;
|
||||
switch ($4)
|
||||
{
|
||||
case 1:
|
||||
|
@ -8881,7 +8881,7 @@ void vers_select_conds_t::resolve_units(bool timestamps_only)
|
||||
end.resolve_unit(timestamps_only);
|
||||
}
|
||||
|
||||
bool vers_select_conds_t::eq(const vers_select_conds_t &conds)
|
||||
bool vers_select_conds_t::eq(const vers_select_conds_t &conds) const
|
||||
{
|
||||
if (type != conds.type)
|
||||
return false;
|
||||
@ -8923,13 +8923,13 @@ void Vers_history_point::fix_item()
|
||||
}
|
||||
|
||||
|
||||
bool Vers_history_point::eq(const vers_history_point_t &point)
|
||||
bool Vers_history_point::eq(const vers_history_point_t &point) const
|
||||
{
|
||||
return unit == point.unit && item->eq(point.item, false);
|
||||
}
|
||||
|
||||
void Vers_history_point::print(String *str, enum_query_type query_type,
|
||||
const char *prefix, size_t plen)
|
||||
const char *prefix, size_t plen) const
|
||||
{
|
||||
const static LEX_CSTRING unit_type[]=
|
||||
{
|
||||
|
18
sql/table.h
18
sql/table.h
@ -1827,9 +1827,9 @@ public:
|
||||
fix_item();
|
||||
}
|
||||
void empty() { unit= VERS_UNDEFINED; item= NULL; }
|
||||
void print(String *str, enum_query_type, const char *prefix, size_t plen);
|
||||
void print(String *str, enum_query_type, const char *prefix, size_t plen) const;
|
||||
void resolve_unit(bool timestamps_only);
|
||||
bool eq(const vers_history_point_t &point);
|
||||
bool eq(const vers_history_point_t &point) const;
|
||||
};
|
||||
|
||||
struct vers_select_conds_t
|
||||
@ -1858,19 +1858,11 @@ struct vers_select_conds_t
|
||||
end= _end;
|
||||
}
|
||||
|
||||
void print(String *str, enum_query_type query_type);
|
||||
void print(String *str, enum_query_type query_type) const;
|
||||
|
||||
bool init_from_sysvar(THD *thd);
|
||||
|
||||
bool operator== (vers_system_time_t b)
|
||||
{
|
||||
return type == b;
|
||||
}
|
||||
bool operator!= (vers_system_time_t b)
|
||||
{
|
||||
return type != b;
|
||||
}
|
||||
operator bool() const
|
||||
bool is_set() const
|
||||
{
|
||||
return type != SYSTEM_TIME_UNSPECIFIED;
|
||||
}
|
||||
@ -1879,7 +1871,7 @@ struct vers_select_conds_t
|
||||
{
|
||||
return !from_query && type != SYSTEM_TIME_UNSPECIFIED;
|
||||
}
|
||||
bool eq(const vers_select_conds_t &conds);
|
||||
bool eq(const vers_select_conds_t &conds) const;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -118,7 +118,7 @@ vers_get_field(HA_CREATE_INFO *create_info, List<Create_field> &create_fields, b
|
||||
List_iterator<Create_field> it(create_fields);
|
||||
Create_field *sql_field = NULL;
|
||||
|
||||
const LString_i row_field= row_start ? create_info->vers_info.as_row.start
|
||||
const Lex_ident row_field= row_start ? create_info->vers_info.as_row.start
|
||||
: create_info->vers_info.as_row.end;
|
||||
DBUG_ASSERT(row_field);
|
||||
|
||||
|
@ -17,125 +17,85 @@
|
||||
#ifndef VERS_STRING_INCLUDED
|
||||
#define VERS_STRING_INCLUDED
|
||||
|
||||
struct Compare_strncmp
|
||||
/*
|
||||
LEX_CSTRING with comparison semantics.
|
||||
*/
|
||||
|
||||
// db and table names: case sensitive (or insensitive) in table_alias_charset
|
||||
struct Compare_table_names
|
||||
{
|
||||
int operator()(const LEX_CSTRING& a, const LEX_CSTRING& b) const
|
||||
{
|
||||
return strncmp(a.str, b.str, a.length);
|
||||
}
|
||||
static CHARSET_INFO* charset()
|
||||
{
|
||||
return system_charset_info;
|
||||
DBUG_ASSERT(a.str[a.length] == 0);
|
||||
DBUG_ASSERT(b.str[b.length] == 0);
|
||||
return my_strnncoll(table_alias_charset,
|
||||
(uchar*)a.str, a.length,
|
||||
(uchar*)b.str, b.length);
|
||||
}
|
||||
};
|
||||
|
||||
template <CHARSET_INFO* &CS= system_charset_info>
|
||||
struct Compare_my_strcasecmp
|
||||
// column names and other identifiers: case insensitive in system_charset_info
|
||||
struct Compare_identifiers
|
||||
{
|
||||
int operator()(const LEX_CSTRING& a, const LEX_CSTRING& b) const
|
||||
{
|
||||
DBUG_ASSERT(a.str[a.length] == 0 && b.str[b.length] == 0);
|
||||
return my_strcasecmp(CS, a.str, b.str);
|
||||
}
|
||||
static CHARSET_INFO* charset()
|
||||
{
|
||||
return CS;
|
||||
DBUG_ASSERT(a.str[a.length] == 0);
|
||||
DBUG_ASSERT(b.str[b.length] == 0);
|
||||
return my_strcasecmp(system_charset_info, a.str, b.str);
|
||||
}
|
||||
};
|
||||
|
||||
typedef Compare_my_strcasecmp<files_charset_info> Compare_fs;
|
||||
typedef Compare_my_strcasecmp<table_alias_charset> Compare_t;
|
||||
|
||||
template <class Storage= LEX_CSTRING>
|
||||
struct LEX_STRING_u : public Storage
|
||||
class Lex_cstring : public LEX_CSTRING
|
||||
{
|
||||
LEX_STRING_u()
|
||||
public:
|
||||
Lex_cstring()
|
||||
{
|
||||
Storage::str= NULL;
|
||||
Storage::length= 0;
|
||||
str= NULL;
|
||||
length= 0;
|
||||
}
|
||||
LEX_STRING_u(const char *_str, size_t _len, CHARSET_INFO *)
|
||||
Lex_cstring(const char *_str, size_t _len)
|
||||
{
|
||||
Storage::str= _str;
|
||||
Storage::length= _len;
|
||||
str= _str;
|
||||
length= _len;
|
||||
}
|
||||
uint32 length() const
|
||||
void set(const char *_str, size_t _len)
|
||||
{
|
||||
return (uint32)Storage::length;
|
||||
}
|
||||
const char *ptr() const
|
||||
{
|
||||
return Storage::str;
|
||||
}
|
||||
void set(const char *_str, size_t _len, CHARSET_INFO *)
|
||||
{
|
||||
Storage::str= _str;
|
||||
Storage::length= _len;
|
||||
}
|
||||
const LEX_CSTRING& lex_cstring() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
const LEX_STRING& lex_string() const
|
||||
{
|
||||
return *(LEX_STRING *)this;
|
||||
str= _str;
|
||||
length= _len;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Compare= Compare_strncmp, class Storage= LEX_STRING_u<> >
|
||||
struct XString : public Storage
|
||||
template <class Compare>
|
||||
struct Lex_cstring_with_compare : public Lex_cstring
|
||||
{
|
||||
public:
|
||||
XString() {}
|
||||
XString(const char *_str, size_t _len) :
|
||||
Storage(_str, _len, Compare::charset())
|
||||
Lex_cstring_with_compare() {}
|
||||
Lex_cstring_with_compare(const char *_str, size_t _len) :
|
||||
Lex_cstring(_str, _len)
|
||||
{ }
|
||||
Lex_cstring_with_compare(const LEX_STRING src) :
|
||||
Lex_cstring(src.str, src.length)
|
||||
{ }
|
||||
Lex_cstring_with_compare(const LEX_CSTRING src) : Lex_cstring(src.str, src.length)
|
||||
{ }
|
||||
Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str))
|
||||
{ }
|
||||
bool streq(const Lex_cstring_with_compare& b) const
|
||||
{
|
||||
}
|
||||
XString(const LEX_STRING src) :
|
||||
Storage(src.str, src.length, Compare::charset())
|
||||
{
|
||||
}
|
||||
XString(const LEX_CSTRING src) :
|
||||
Storage(src.str, src.length, Compare::charset())
|
||||
{
|
||||
}
|
||||
XString(const char *_str) :
|
||||
Storage(_str, strlen(_str), Compare::charset())
|
||||
{
|
||||
}
|
||||
bool streq(const XString& b) const
|
||||
{
|
||||
return Storage::length() == b.length() && 0 == Compare()(this->lex_cstring(), b.lex_cstring());
|
||||
return Lex_cstring::length == b.length && 0 == Compare()(*this, b);
|
||||
}
|
||||
operator const char* () const
|
||||
{
|
||||
return Storage::ptr();
|
||||
}
|
||||
operator LEX_CSTRING& () const
|
||||
{
|
||||
return this->lex_cstring();
|
||||
}
|
||||
operator LEX_STRING () const
|
||||
{
|
||||
LEX_STRING res;
|
||||
res.str= const_cast<char *>(this->ptr());
|
||||
res.length= this->length();
|
||||
return res;
|
||||
return str;
|
||||
}
|
||||
operator bool () const
|
||||
{
|
||||
return Storage::ptr() != NULL;
|
||||
return str != NULL;
|
||||
}
|
||||
};
|
||||
|
||||
typedef XString<> LString;
|
||||
typedef XString<Compare_fs> LString_fs;
|
||||
typedef XString<Compare_my_strcasecmp<> > LString_i;
|
||||
|
||||
typedef XString<Compare_strncmp, String> SString;
|
||||
typedef XString<Compare_fs, String> SString_fs;
|
||||
typedef XString<Compare_t, String> SString_t;
|
||||
|
||||
typedef Lex_cstring_with_compare<Compare_identifiers> Lex_ident;
|
||||
typedef Lex_cstring_with_compare<Compare_table_names> Lex_table_name;
|
||||
|
||||
#define XSTRING_WITH_LEN(X) (X).ptr(), (X).length()
|
||||
#define DB_WITH_LEN(X) (X).db.str, (X).db.length
|
||||
|
Loading…
x
Reference in New Issue
Block a user