Improved storage size for Item, Field and some other classes
- Changed order of class fields to remove dead alignment space. - Changed bool fields in Item to bit fields. - Used packed enum's for some fields in common classes - Removed not used Item::rsize. - Changed some class variables from uint/int to smaller type int's. - Ensured that field_index is uint16 in all classes and functions. Fixed also that we proparly compare with NO_CACHED_FIELD_INDEX when checking if variable is not set. - Removed checking of highest bit of unireg_check (has not been used in a long time) - Fixed wrong arguments to make_cond_for_table() for join_tab_idx_arg from false to 0. One of the result was reducing the size if class Item with ~24 bytes
This commit is contained in:
parent
8e8bda7fd3
commit
c76eabfb5e
16
sql/field.cc
16
sql/field.cc
@ -1836,12 +1836,12 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val)
|
|||||||
Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
|
Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
|
||||||
uchar null_bit_arg,
|
uchar null_bit_arg,
|
||||||
utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
|
utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
|
||||||
:ptr(ptr_arg), invisible(VISIBLE),
|
:ptr(ptr_arg),
|
||||||
null_ptr(null_ptr_arg), table(0), orig_table(0),
|
null_ptr(null_ptr_arg), table(0), orig_table(0),
|
||||||
table_name(0), field_name(*field_name_arg), option_list(0),
|
table_name(0), field_name(*field_name_arg), option_list(0),
|
||||||
option_struct(0), key_start(0), part_of_key(0),
|
option_struct(0), key_start(0), part_of_key(0),
|
||||||
part_of_key_not_clustered(0), part_of_sortkey(0),
|
part_of_key_not_clustered(0), part_of_sortkey(0),
|
||||||
unireg_check(unireg_check_arg), field_length(length_arg),
|
unireg_check(unireg_check_arg), invisible(VISIBLE), field_length(length_arg),
|
||||||
null_bit(null_bit_arg), is_created_from_null_item(FALSE),
|
null_bit(null_bit_arg), is_created_from_null_item(FALSE),
|
||||||
read_stats(NULL), collected_stats(0), vcol_info(0), check_constraint(0),
|
read_stats(NULL), collected_stats(0), vcol_info(0), check_constraint(0),
|
||||||
default_value(0)
|
default_value(0)
|
||||||
@ -10740,24 +10740,24 @@ bool Field_vers_trx_id::test_if_equality_guarantees_uniqueness(const Item* item)
|
|||||||
|
|
||||||
Column_definition_attributes::Column_definition_attributes(const Field *field)
|
Column_definition_attributes::Column_definition_attributes(const Field *field)
|
||||||
:length(field->character_octet_length() / field->charset()->mbmaxlen),
|
:length(field->character_octet_length() / field->charset()->mbmaxlen),
|
||||||
decimals(field->decimals()),
|
|
||||||
unireg_check(field->unireg_check),
|
|
||||||
interval(NULL),
|
interval(NULL),
|
||||||
charset(field->charset()), // May be NULL ptr
|
charset(field->charset()), // May be NULL ptr
|
||||||
srid(0),
|
srid(0),
|
||||||
pack_flag(0)
|
pack_flag(0),
|
||||||
|
decimals(field->decimals()),
|
||||||
|
unireg_check(field->unireg_check)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Column_definition_attributes::
|
Column_definition_attributes::
|
||||||
Column_definition_attributes(const Type_all_attributes &attr)
|
Column_definition_attributes(const Type_all_attributes &attr)
|
||||||
:length(attr.max_length),
|
:length(attr.max_length),
|
||||||
decimals(attr.decimals),
|
|
||||||
unireg_check(Field::NONE),
|
|
||||||
interval(attr.get_typelib()),
|
interval(attr.get_typelib()),
|
||||||
charset(attr.collation.collation),
|
charset(attr.collation.collation),
|
||||||
srid(0),
|
srid(0),
|
||||||
pack_flag(attr.unsigned_flag ? 0 : FIELDFLAG_DECIMAL)
|
pack_flag(attr.unsigned_flag ? 0 : FIELDFLAG_DECIMAL),
|
||||||
|
decimals(attr.decimals),
|
||||||
|
unireg_check(Field::NONE)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
93
sql/field.h
93
sql/field.h
@ -648,76 +648,76 @@ public:
|
|||||||
SIGN_UNSIGNED,
|
SIGN_UNSIGNED,
|
||||||
SIGN_NOT_APPLICABLE // for non-numeric types
|
SIGN_NOT_APPLICABLE // for non-numeric types
|
||||||
};
|
};
|
||||||
uchar m_type_code; // according to Field::binlog_type()
|
|
||||||
/**
|
/**
|
||||||
Retrieve the field metadata for fields.
|
Retrieve the field metadata for fields.
|
||||||
*/
|
*/
|
||||||
uint16 m_metadata;
|
|
||||||
uint8 m_metadata_size;
|
|
||||||
binlog_sign_t m_signedness;
|
|
||||||
CHARSET_INFO *m_cs; // NULL if not relevant
|
CHARSET_INFO *m_cs; // NULL if not relevant
|
||||||
TYPELIB *m_enum_typelib; // NULL if not relevant
|
TYPELIB *m_enum_typelib; // NULL if not relevant
|
||||||
TYPELIB *m_set_typelib; // NULL if not relevant
|
TYPELIB *m_set_typelib; // NULL if not relevant
|
||||||
|
binlog_sign_t m_signedness;
|
||||||
|
uint16 m_metadata;
|
||||||
|
uint8 m_metadata_size;
|
||||||
|
uchar m_type_code; // according to Field::binlog_type()
|
||||||
uchar m_geom_type; // Non-geometry fields can return 0
|
uchar m_geom_type; // Non-geometry fields can return 0
|
||||||
|
|
||||||
Binlog_type_info(uchar type_code,
|
Binlog_type_info(uchar type_code,
|
||||||
uint16 metadata,
|
uint16 metadata,
|
||||||
uint8 metadata_size)
|
uint8 metadata_size)
|
||||||
:m_type_code(type_code),
|
:m_cs(NULL),
|
||||||
m_metadata(metadata),
|
|
||||||
m_metadata_size(metadata_size),
|
|
||||||
m_signedness(SIGN_NOT_APPLICABLE),
|
|
||||||
m_cs(NULL),
|
|
||||||
m_enum_typelib(NULL),
|
m_enum_typelib(NULL),
|
||||||
m_set_typelib(NULL),
|
m_set_typelib(NULL),
|
||||||
|
m_signedness(SIGN_NOT_APPLICABLE),
|
||||||
|
m_metadata(metadata),
|
||||||
|
m_metadata_size(metadata_size),
|
||||||
|
m_type_code(type_code),
|
||||||
m_geom_type(0)
|
m_geom_type(0)
|
||||||
{};
|
{};
|
||||||
Binlog_type_info(uchar type_code, uint16 metadata,
|
Binlog_type_info(uchar type_code, uint16 metadata,
|
||||||
uint8 metadata_size,
|
uint8 metadata_size,
|
||||||
binlog_sign_t signedness)
|
binlog_sign_t signedness)
|
||||||
:m_type_code(type_code),
|
: m_cs(NULL),
|
||||||
m_metadata(metadata),
|
|
||||||
m_metadata_size(metadata_size),
|
|
||||||
m_signedness(signedness),
|
|
||||||
m_cs(NULL),
|
|
||||||
m_enum_typelib(NULL),
|
m_enum_typelib(NULL),
|
||||||
m_set_typelib(NULL),
|
m_set_typelib(NULL),
|
||||||
|
m_signedness(signedness),
|
||||||
|
m_metadata(metadata),
|
||||||
|
m_metadata_size(metadata_size),
|
||||||
|
m_type_code(type_code),
|
||||||
m_geom_type(0)
|
m_geom_type(0)
|
||||||
{};
|
{};
|
||||||
Binlog_type_info(uchar type_code, uint16 metadata,
|
Binlog_type_info(uchar type_code, uint16 metadata,
|
||||||
uint8 metadata_size,
|
uint8 metadata_size, CHARSET_INFO *cs)
|
||||||
CHARSET_INFO *cs)
|
:m_cs(cs),
|
||||||
:m_type_code(type_code),
|
|
||||||
m_metadata(metadata),
|
|
||||||
m_metadata_size(metadata_size),
|
|
||||||
m_signedness(SIGN_NOT_APPLICABLE),
|
|
||||||
m_cs(cs),
|
|
||||||
m_enum_typelib(NULL),
|
m_enum_typelib(NULL),
|
||||||
m_set_typelib(NULL),
|
m_set_typelib(NULL),
|
||||||
|
m_signedness(SIGN_NOT_APPLICABLE),
|
||||||
|
m_metadata(metadata),
|
||||||
|
m_metadata_size(metadata_size),
|
||||||
|
m_type_code(type_code),
|
||||||
m_geom_type(0)
|
m_geom_type(0)
|
||||||
{};
|
{};
|
||||||
Binlog_type_info(uchar type_code, uint16 metadata,
|
Binlog_type_info(uchar type_code, uint16 metadata,
|
||||||
uint8 metadata_size,
|
uint8 metadata_size,
|
||||||
CHARSET_INFO *cs,
|
CHARSET_INFO *cs,
|
||||||
TYPELIB *t_enum, TYPELIB *t_set)
|
TYPELIB *t_enum, TYPELIB *t_set)
|
||||||
:m_type_code(type_code),
|
:m_cs(cs),
|
||||||
m_metadata(metadata),
|
|
||||||
m_metadata_size(metadata_size),
|
|
||||||
m_signedness(SIGN_NOT_APPLICABLE),
|
|
||||||
m_cs(cs),
|
|
||||||
m_enum_typelib(t_enum),
|
m_enum_typelib(t_enum),
|
||||||
m_set_typelib(t_set),
|
m_set_typelib(t_set),
|
||||||
|
m_signedness(SIGN_NOT_APPLICABLE),
|
||||||
|
m_metadata(metadata),
|
||||||
|
m_metadata_size(metadata_size),
|
||||||
|
m_type_code(type_code),
|
||||||
m_geom_type(0)
|
m_geom_type(0)
|
||||||
{};
|
{};
|
||||||
Binlog_type_info(uchar type_code, uint16 metadata,
|
Binlog_type_info(uchar type_code, uint16 metadata,
|
||||||
uint8 metadata_size, CHARSET_INFO *cs,
|
uint8 metadata_size, CHARSET_INFO *cs,
|
||||||
uchar geom_type)
|
uchar geom_type)
|
||||||
:m_type_code(type_code),
|
:m_cs(cs),
|
||||||
m_metadata(metadata),
|
|
||||||
m_metadata_size(metadata_size),
|
|
||||||
m_signedness(SIGN_NOT_APPLICABLE),
|
|
||||||
m_cs(cs),
|
|
||||||
m_enum_typelib(NULL),
|
m_enum_typelib(NULL),
|
||||||
m_set_typelib(NULL),
|
m_set_typelib(NULL),
|
||||||
|
m_signedness(SIGN_NOT_APPLICABLE),
|
||||||
|
m_metadata(metadata),
|
||||||
|
m_metadata_size(metadata_size),
|
||||||
|
m_type_code(type_code),
|
||||||
m_geom_type(geom_type)
|
m_geom_type(geom_type)
|
||||||
{};
|
{};
|
||||||
static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
|
static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
|
||||||
@ -781,7 +781,6 @@ public:
|
|||||||
|
|
||||||
uchar *ptr; // Position to field in record
|
uchar *ptr; // Position to field in record
|
||||||
|
|
||||||
field_visibility_t invisible;
|
|
||||||
/**
|
/**
|
||||||
Byte where the @c NULL bit is stored inside a record. If this Field is a
|
Byte where the @c NULL bit is stored inside a record. If this Field is a
|
||||||
@c NOT @c NULL field, this member is @c NULL.
|
@c NOT @c NULL field, this member is @c NULL.
|
||||||
@ -816,7 +815,7 @@ public:
|
|||||||
in more clean way with transition to new text based .frm format.
|
in more clean way with transition to new text based .frm format.
|
||||||
See also comment for Field_timestamp::Field_timestamp().
|
See also comment for Field_timestamp::Field_timestamp().
|
||||||
*/
|
*/
|
||||||
enum utype {
|
enum __attribute__((packed)) utype {
|
||||||
NONE=0,
|
NONE=0,
|
||||||
NEXT_NUMBER=15, // AUTO_INCREMENT
|
NEXT_NUMBER=15, // AUTO_INCREMENT
|
||||||
TIMESTAMP_OLD_FIELD=18, // TIMESTAMP created before 4.1.3
|
TIMESTAMP_OLD_FIELD=18, // TIMESTAMP created before 4.1.3
|
||||||
@ -827,11 +826,13 @@ public:
|
|||||||
};
|
};
|
||||||
enum imagetype { itRAW, itMBR};
|
enum imagetype { itRAW, itMBR};
|
||||||
|
|
||||||
utype unireg_check;
|
utype unireg_check;
|
||||||
uint32 field_length; // Length of field
|
field_visibility_t invisible;
|
||||||
|
uint32 field_length; // Length of field
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
uint16 field_index; // field number in fields array
|
uint16 field_index; // field number in fields array
|
||||||
uchar null_bit; // Bit used to test null bit
|
uchar null_bit; // Bit used to test null bit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
If true, this field was created in create_tmp_field_from_item from a NULL
|
If true, this field was created in create_tmp_field_from_item from a NULL
|
||||||
value. This means that the type of the field is just a guess, and the type
|
value. This means that the type of the field is just a guess, and the type
|
||||||
@ -2336,7 +2337,7 @@ class Field_new_decimal final :public Field_num {
|
|||||||
public:
|
public:
|
||||||
/* The maximum number of decimal digits can be stored */
|
/* The maximum number of decimal digits can be stored */
|
||||||
decimal_digits_t precision;
|
decimal_digits_t precision;
|
||||||
uint bin_size;
|
uint32 bin_size;
|
||||||
/*
|
/*
|
||||||
Constructors take max_length of the field as a parameter - not the
|
Constructors take max_length of the field as a parameter - not the
|
||||||
precision as the number of decimal digits allowed.
|
precision as the number of decimal digits allowed.
|
||||||
@ -2422,7 +2423,7 @@ public:
|
|||||||
return Information_schema_numeric_attributes(precision, dec);
|
return Information_schema_numeric_attributes(precision, dec);
|
||||||
}
|
}
|
||||||
uint size_of() const override { return sizeof *this; }
|
uint size_of() const override { return sizeof *this; }
|
||||||
uint32 pack_length() const override { return (uint32) bin_size; }
|
uint32 pack_length() const override { return bin_size; }
|
||||||
uint pack_length_from_metadata(uint field_metadata) const override;
|
uint pack_length_from_metadata(uint field_metadata) const override;
|
||||||
uint row_pack_length() const override { return pack_length(); }
|
uint row_pack_length() const override { return pack_length(); }
|
||||||
bool compatible_field_size(uint field_metadata, const Relay_log_info *rli,
|
bool compatible_field_size(uint field_metadata, const Relay_log_info *rli,
|
||||||
@ -5107,20 +5108,20 @@ public:
|
|||||||
max number of characters.
|
max number of characters.
|
||||||
*/
|
*/
|
||||||
ulonglong length;
|
ulonglong length;
|
||||||
decimal_digits_t decimals;
|
const TYPELIB *interval;
|
||||||
Field::utype unireg_check;
|
|
||||||
const TYPELIB *interval; // Which interval to use
|
|
||||||
CHARSET_INFO *charset;
|
CHARSET_INFO *charset;
|
||||||
uint32 srid;
|
uint32 srid;
|
||||||
uint pack_flag;
|
uint32 pack_flag;
|
||||||
|
decimal_digits_t decimals;
|
||||||
|
Field::utype unireg_check;
|
||||||
Column_definition_attributes()
|
Column_definition_attributes()
|
||||||
:length(0),
|
:length(0),
|
||||||
decimals(0),
|
|
||||||
unireg_check(Field::NONE),
|
|
||||||
interval(NULL),
|
interval(NULL),
|
||||||
charset(&my_charset_bin),
|
charset(&my_charset_bin),
|
||||||
srid(0),
|
srid(0),
|
||||||
pack_flag(0)
|
pack_flag(0),
|
||||||
|
decimals(0),
|
||||||
|
unireg_check(Field::NONE)
|
||||||
{ }
|
{ }
|
||||||
Column_definition_attributes(const Field *field);
|
Column_definition_attributes(const Field *field);
|
||||||
Column_definition_attributes(const Type_all_attributes &attr);
|
Column_definition_attributes(const Type_all_attributes &attr);
|
||||||
|
54
sql/item.cc
54
sql/item.cc
@ -410,14 +410,14 @@ int Item::save_str_value_in_field(Field *field, String *result)
|
|||||||
|
|
||||||
|
|
||||||
Item::Item(THD *thd):
|
Item::Item(THD *thd):
|
||||||
is_expensive_cache(-1), rsize(0), name(null_clex_str), orig_name(0),
|
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
|
||||||
common_flags(IS_AUTO_GENERATED_NAME)
|
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(thd);
|
DBUG_ASSERT(thd);
|
||||||
|
common_flags= IS_AUTO_GENERATED_NAME;
|
||||||
marker= 0;
|
marker= 0;
|
||||||
maybe_null= null_value= with_window_func= with_field= false;
|
maybe_null= with_window_func= with_field= in_rollup= with_param= 0;
|
||||||
in_rollup= 0;
|
fixed= 1; // Simple Item's doesn't have to be fixed
|
||||||
with_param= 0;
|
null_value= 0;
|
||||||
|
|
||||||
/* Initially this item is not attached to any JOIN_TAB. */
|
/* Initially this item is not attached to any JOIN_TAB. */
|
||||||
join_tab_idx= MAX_TABLES;
|
join_tab_idx= MAX_TABLES;
|
||||||
@ -444,13 +444,13 @@ Item::Item(THD *thd):
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Item::Item():
|
Item::Item():
|
||||||
is_expensive_cache(-1), name(null_clex_str), orig_name(0)
|
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(my_progname == NULL); // before main()
|
DBUG_ASSERT(my_progname == NULL); // before main()
|
||||||
marker= 0;
|
marker= 0;
|
||||||
maybe_null= null_value= with_window_func= with_field= false;
|
maybe_null= with_window_func= with_field= in_rollup= with_param= 0;
|
||||||
in_rollup= 0;
|
fixed= 1;
|
||||||
with_param= 0;
|
null_value= 0;
|
||||||
join_tab_idx= MAX_TABLES;
|
join_tab_idx= MAX_TABLES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,20 +473,19 @@ const TABLE_SHARE *Item::field_table_or_null()
|
|||||||
*/
|
*/
|
||||||
Item::Item(THD *thd, Item *item):
|
Item::Item(THD *thd, Item *item):
|
||||||
Type_all_attributes(*item),
|
Type_all_attributes(*item),
|
||||||
join_tab_idx(item->join_tab_idx),
|
|
||||||
is_expensive_cache(-1),
|
|
||||||
rsize(0),
|
|
||||||
str_value(item->str_value),
|
str_value(item->str_value),
|
||||||
name(item->name),
|
name(item->name),
|
||||||
orig_name(item->orig_name),
|
orig_name(item->orig_name),
|
||||||
marker(item->marker),
|
|
||||||
maybe_null(item->maybe_null),
|
maybe_null(item->maybe_null),
|
||||||
in_rollup(item->in_rollup),
|
in_rollup(item->in_rollup),
|
||||||
null_value(item->null_value),
|
|
||||||
with_param(item->with_param),
|
with_param(item->with_param),
|
||||||
with_window_func(item->with_window_func),
|
with_window_func(item->with_window_func),
|
||||||
with_field(item->with_field),
|
with_field(item->with_field),
|
||||||
common_flags(item->common_flags)
|
marker(item->marker),
|
||||||
|
null_value(item->null_value),
|
||||||
|
is_expensive_cache(-1),
|
||||||
|
common_flags(item->common_flags),
|
||||||
|
join_tab_idx(item->join_tab_idx)
|
||||||
{
|
{
|
||||||
next= thd->free_list; // Put in free list
|
next= thd->free_list; // Put in free list
|
||||||
thd->free_list= this;
|
thd->free_list= this;
|
||||||
@ -655,8 +654,9 @@ Item_ident::Item_ident(THD *thd, Name_resolution_context *context_arg,
|
|||||||
orig_field_name(field_name_arg), context(context_arg),
|
orig_field_name(field_name_arg), context(context_arg),
|
||||||
db_name(db_name_arg), table_name(table_name_arg),
|
db_name(db_name_arg), table_name(table_name_arg),
|
||||||
field_name(field_name_arg),
|
field_name(field_name_arg),
|
||||||
alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
|
cached_table(NULL), depended_from(NULL),
|
||||||
cached_table(0), depended_from(0), can_be_depended(TRUE)
|
cached_field_index(NO_CACHED_FIELD_INDEX),
|
||||||
|
can_be_depended(TRUE), alias_name_used(FALSE)
|
||||||
{
|
{
|
||||||
name= field_name_arg;
|
name= field_name_arg;
|
||||||
}
|
}
|
||||||
@ -671,8 +671,9 @@ Item_ident::Item_ident(THD *thd, TABLE_LIST *view_arg,
|
|||||||
context(&view_arg->view->first_select_lex()->context),
|
context(&view_arg->view->first_select_lex()->context),
|
||||||
db_name(null_clex_str), table_name(view_arg->alias),
|
db_name(null_clex_str), table_name(view_arg->alias),
|
||||||
field_name(field_name_arg),
|
field_name(field_name_arg),
|
||||||
alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
|
cached_table(NULL), depended_from(NULL),
|
||||||
cached_table(NULL), depended_from(NULL), can_be_depended(TRUE)
|
cached_field_index(NO_CACHED_FIELD_INDEX),
|
||||||
|
can_be_depended(TRUE), alias_name_used(FALSE)
|
||||||
{
|
{
|
||||||
name= field_name_arg;
|
name= field_name_arg;
|
||||||
}
|
}
|
||||||
@ -691,11 +692,11 @@ Item_ident::Item_ident(THD *thd, Item_ident *item)
|
|||||||
db_name(item->db_name),
|
db_name(item->db_name),
|
||||||
table_name(item->table_name),
|
table_name(item->table_name),
|
||||||
field_name(item->field_name),
|
field_name(item->field_name),
|
||||||
alias_name_used(item->alias_name_used),
|
|
||||||
cached_field_index(item->cached_field_index),
|
|
||||||
cached_table(item->cached_table),
|
cached_table(item->cached_table),
|
||||||
depended_from(item->depended_from),
|
depended_from(item->depended_from),
|
||||||
can_be_depended(item->can_be_depended)
|
cached_field_index(item->cached_field_index),
|
||||||
|
can_be_depended(item->can_be_depended),
|
||||||
|
alias_name_used(item->alias_name_used)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Item_ident::cleanup()
|
void Item_ident::cleanup()
|
||||||
@ -6532,19 +6533,16 @@ static int save_field_in_field(Field *from, bool *null_value,
|
|||||||
DBUG_RETURN(set_field_to_null_with_conversions(to, no_conversions));
|
DBUG_RETURN(set_field_to_null_with_conversions(to, no_conversions));
|
||||||
}
|
}
|
||||||
to->set_notnull();
|
to->set_notnull();
|
||||||
|
(*null_value)= 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If we're setting the same field as the one we're reading from there's
|
If we're setting the same field as the one we're reading from there's
|
||||||
nothing to do. This can happen in 'SET x = x' type of scenarios.
|
nothing to do. This can happen in 'SET x = x' type of scenarios.
|
||||||
*/
|
*/
|
||||||
if (to == from)
|
if (to == from)
|
||||||
{
|
|
||||||
(*null_value)= 0;
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
|
||||||
|
|
||||||
res= field_conv(to, from);
|
res= field_conv(to, from);
|
||||||
(*null_value)= 0;
|
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9764,7 +9762,7 @@ bool Item_trigger_field::fix_fields(THD *thd, Item **items)
|
|||||||
|
|
||||||
/* Set field. */
|
/* Set field. */
|
||||||
|
|
||||||
if (likely(field_idx != (uint)-1))
|
if (likely(field_idx != NO_CACHED_FIELD_INDEX))
|
||||||
{
|
{
|
||||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
/*
|
/*
|
||||||
@ -10122,7 +10120,7 @@ bool Item_cache_timestamp::val_native(THD *thd, Native *to)
|
|||||||
null_value= true;
|
null_value= true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return null_value= to->copy(m_native);
|
return (null_value= to->copy(m_native));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
194
sql/item.h
194
sql/item.h
@ -734,20 +734,9 @@ public:
|
|||||||
|
|
||||||
#define STOP_PTR ((void *) 1)
|
#define STOP_PTR ((void *) 1)
|
||||||
|
|
||||||
class Item: public Value_source,
|
class Item :public Value_source,
|
||||||
public Type_all_attributes
|
public Type_all_attributes
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached
|
|
||||||
to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the
|
|
||||||
make_cond_for_table procedure. During query execution, this item is
|
|
||||||
evaluated when the join loop reaches the corresponding JOIN_TAB.
|
|
||||||
|
|
||||||
If the value of join_tab_idx >= MAX_TABLES, this means that there is no
|
|
||||||
corresponding JOIN_TAB.
|
|
||||||
*/
|
|
||||||
uint join_tab_idx;
|
|
||||||
|
|
||||||
static void *operator new(size_t size);
|
static void *operator new(size_t size);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -780,22 +769,9 @@ public:
|
|||||||
EXPR_CACHE_ITEM};
|
EXPR_CACHE_ITEM};
|
||||||
|
|
||||||
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
|
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
|
||||||
|
|
||||||
enum traverse_order { POSTFIX, PREFIX };
|
enum traverse_order { POSTFIX, PREFIX };
|
||||||
|
|
||||||
/* Cache of the result of is_expensive(). */
|
|
||||||
int8 is_expensive_cache;
|
|
||||||
|
|
||||||
/* Reuse size, only used by SP local variable assignment, otherwise 0 */
|
|
||||||
uint rsize;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*
|
|
||||||
str_values's main purpose is to be used to cache the value in
|
|
||||||
save_in_field
|
|
||||||
*/
|
|
||||||
String str_value;
|
|
||||||
|
|
||||||
SEL_TREE *get_mm_tree_for_const(RANGE_OPT_PARAM *param);
|
SEL_TREE *get_mm_tree_for_const(RANGE_OPT_PARAM *param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -899,7 +875,7 @@ protected:
|
|||||||
const Type_handler *handler)
|
const Type_handler *handler)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(is_fixed());
|
DBUG_ASSERT(is_fixed());
|
||||||
return null_value= item->val_native_with_conversion(thd, to, handler);
|
return (null_value= item->val_native_with_conversion(thd, to, handler));
|
||||||
}
|
}
|
||||||
my_decimal *val_decimal_from_item(Item *item, my_decimal *decimal_value)
|
my_decimal *val_decimal_from_item(Item *item, my_decimal *decimal_value)
|
||||||
{
|
{
|
||||||
@ -927,9 +903,8 @@ public:
|
|||||||
|
|
||||||
const MY_LOCALE *locale_from_val_str();
|
const MY_LOCALE *locale_from_val_str();
|
||||||
|
|
||||||
LEX_CSTRING name; /* Name of item */
|
/* All variables for the Item class */
|
||||||
/* Original item name (if it was renamed)*/
|
|
||||||
const char *orig_name;
|
|
||||||
/**
|
/**
|
||||||
Intrusive list pointer for free list. If not null, points to the next
|
Intrusive list pointer for free list. If not null, points to the next
|
||||||
Item on some Query_arena's free list. For instance, stored procedures
|
Item on some Query_arena's free list. For instance, stored procedures
|
||||||
@ -938,18 +913,48 @@ public:
|
|||||||
@see Query_arena::free_list
|
@see Query_arena::free_list
|
||||||
*/
|
*/
|
||||||
Item *next;
|
Item *next;
|
||||||
int marker;
|
|
||||||
bool maybe_null; /* If item may be null */
|
/*
|
||||||
bool in_rollup; /* If used in GROUP BY list
|
str_values's main purpose is to be used to cache the value in
|
||||||
of a query with ROLLUP */
|
save_in_field
|
||||||
bool null_value; /* if item is null */
|
|
||||||
bool with_param; /* True if contains an SP parameter */
|
|
||||||
bool with_window_func; /* True if item contains a window func */
|
|
||||||
/**
|
|
||||||
True if any item except Item_sum contains a field. Set during parsing.
|
|
||||||
*/
|
*/
|
||||||
bool with_field;
|
String str_value;
|
||||||
uint8 common_flags;
|
|
||||||
|
LEX_CSTRING name; /* Name of item */
|
||||||
|
/* Original item name (if it was renamed)*/
|
||||||
|
const char *orig_name;
|
||||||
|
|
||||||
|
uint32 /* All common bool variables for Item stored here */
|
||||||
|
maybe_null:1, /* If item may be null */
|
||||||
|
in_rollup:1, /* If used in GROUP BY list of a query with ROLLUP */
|
||||||
|
with_param:1, /* True if Item contains an SP parameter */
|
||||||
|
with_window_func:1, /* True if item contains a window func */
|
||||||
|
with_field:1, /* True if any item except Item_sum contains a field.
|
||||||
|
Set during parsing. */
|
||||||
|
fixed:1; /* If item was fixed with fix_fields */
|
||||||
|
|
||||||
|
int16 marker;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Tells is the val() value of the item is/was null.
|
||||||
|
This should not be part of the bit flags as it's changed a lot and also we use
|
||||||
|
pointers to it
|
||||||
|
*/
|
||||||
|
bool null_value;
|
||||||
|
/* Cache of the result of is_expensive(). */
|
||||||
|
int8 is_expensive_cache;
|
||||||
|
uint8 common_flags; /* To be integrated into above flags soon... */
|
||||||
|
/**
|
||||||
|
The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached
|
||||||
|
to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the
|
||||||
|
make_cond_for_table procedure. During query execution, this item is
|
||||||
|
evaluated when the join loop reaches the corresponding JOIN_TAB.
|
||||||
|
|
||||||
|
If the value of join_tab_idx >= MAX_TABLES, this means that there is no
|
||||||
|
corresponding JOIN_TAB.
|
||||||
|
*/
|
||||||
|
uint8 join_tab_idx;
|
||||||
|
|
||||||
bool is_autogenerated_name()
|
bool is_autogenerated_name()
|
||||||
{ return (common_flags & IS_AUTO_GENERATED_NAME); }
|
{ return (common_flags & IS_AUTO_GENERATED_NAME); }
|
||||||
// alloc & destruct is done as start of select on THD::mem_root
|
// alloc & destruct is done as start of select on THD::mem_root
|
||||||
@ -1380,7 +1385,7 @@ public:
|
|||||||
* Item_func_rollup_const
|
* Item_func_rollup_const
|
||||||
*/
|
*/
|
||||||
DBUG_ASSERT(0);
|
DBUG_ASSERT(0);
|
||||||
return null_value= true;
|
return (null_value= 1);
|
||||||
}
|
}
|
||||||
virtual bool val_native_result(THD *thd, Native *to)
|
virtual bool val_native_result(THD *thd, Native *to)
|
||||||
{
|
{
|
||||||
@ -2424,7 +2429,7 @@ public:
|
|||||||
Item is attached. The number is an index is depth_first_tab() traversal
|
Item is attached. The number is an index is depth_first_tab() traversal
|
||||||
order.
|
order.
|
||||||
*/
|
*/
|
||||||
virtual void set_join_tab_idx(uint join_tab_idx_arg)
|
virtual void set_join_tab_idx(uint8 join_tab_idx_arg)
|
||||||
{
|
{
|
||||||
if (join_tab_idx_arg < join_tab_idx)
|
if (join_tab_idx_arg < join_tab_idx)
|
||||||
join_tab_idx= join_tab_idx_arg;
|
join_tab_idx= join_tab_idx_arg;
|
||||||
@ -2472,7 +2477,7 @@ public:
|
|||||||
{ return marker & FULL_EXTRACTION_FL; }
|
{ return marker & FULL_EXTRACTION_FL; }
|
||||||
int get_extraction_flag()
|
int get_extraction_flag()
|
||||||
{ return marker & EXTRACTION_MASK; }
|
{ return marker & EXTRACTION_MASK; }
|
||||||
void set_extraction_flag(int flags)
|
void set_extraction_flag(int16 flags)
|
||||||
{
|
{
|
||||||
marker &= ~EXTRACTION_MASK;
|
marker &= ~EXTRACTION_MASK;
|
||||||
marker|= flags;
|
marker|= flags;
|
||||||
@ -2769,13 +2774,15 @@ class Item_string;
|
|||||||
class Item_fixed_hybrid: public Item
|
class Item_fixed_hybrid: public Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool fixed; // If item was fixed with fix_fields
|
Item_fixed_hybrid(THD *thd): Item(thd)
|
||||||
public:
|
{
|
||||||
Item_fixed_hybrid(THD *thd): Item(thd), fixed(false)
|
fixed= false;
|
||||||
{ }
|
}
|
||||||
Item_fixed_hybrid(THD *thd, Item_fixed_hybrid *item)
|
Item_fixed_hybrid(THD *thd, Item_fixed_hybrid *item)
|
||||||
:Item(thd, item), fixed(item->fixed)
|
:Item(thd, item)
|
||||||
{ }
|
{
|
||||||
|
fixed= item->fixed;
|
||||||
|
}
|
||||||
bool fix_fields(THD *thd, Item **ref)
|
bool fix_fields(THD *thd, Item **ref)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(!fixed);
|
DBUG_ASSERT(!fixed);
|
||||||
@ -3273,7 +3280,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
|
#define NO_CACHED_FIELD_INDEX ((uint16) ~0)
|
||||||
|
|
||||||
class st_select_lex;
|
class st_select_lex;
|
||||||
|
|
||||||
@ -3338,13 +3345,6 @@ public:
|
|||||||
LEX_CSTRING db_name;
|
LEX_CSTRING db_name;
|
||||||
LEX_CSTRING table_name;
|
LEX_CSTRING table_name;
|
||||||
LEX_CSTRING field_name;
|
LEX_CSTRING field_name;
|
||||||
bool alias_name_used; /* true if item was resolved against alias */
|
|
||||||
/*
|
|
||||||
Cached value of index for this field in table->field array, used by prep.
|
|
||||||
stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
|
|
||||||
if index value is not known.
|
|
||||||
*/
|
|
||||||
uint cached_field_index;
|
|
||||||
/*
|
/*
|
||||||
Cached pointer to table which contains this field, used for the same reason
|
Cached pointer to table which contains this field, used for the same reason
|
||||||
by prep. stmt. too in case then we have not-fully qualified field.
|
by prep. stmt. too in case then we have not-fully qualified field.
|
||||||
@ -3352,6 +3352,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
TABLE_LIST *cached_table;
|
TABLE_LIST *cached_table;
|
||||||
st_select_lex *depended_from;
|
st_select_lex *depended_from;
|
||||||
|
/*
|
||||||
|
Cached value of index for this field in table->field array, used by prepared
|
||||||
|
stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
|
||||||
|
if index value is not known.
|
||||||
|
*/
|
||||||
|
uint16 cached_field_index;
|
||||||
/*
|
/*
|
||||||
Some Items resolved in another select should not be marked as dependency
|
Some Items resolved in another select should not be marked as dependency
|
||||||
of the subquery where they are. During normal name resolution, we check
|
of the subquery where they are. During normal name resolution, we check
|
||||||
@ -3365,6 +3371,8 @@ public:
|
|||||||
this variable.
|
this variable.
|
||||||
*/
|
*/
|
||||||
bool can_be_depended;
|
bool can_be_depended;
|
||||||
|
bool alias_name_used; /* true if item was resolved against alias */
|
||||||
|
|
||||||
Item_ident(THD *thd, Name_resolution_context *context_arg,
|
Item_ident(THD *thd, Name_resolution_context *context_arg,
|
||||||
const LEX_CSTRING &db_name_arg, const LEX_CSTRING &table_name_arg,
|
const LEX_CSTRING &db_name_arg, const LEX_CSTRING &table_name_arg,
|
||||||
const LEX_CSTRING &field_name_arg);
|
const LEX_CSTRING &field_name_arg);
|
||||||
@ -3712,7 +3720,8 @@ public:
|
|||||||
Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
|
Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
|
||||||
Item_basic_constant(thd)
|
Item_basic_constant(thd)
|
||||||
{
|
{
|
||||||
maybe_null= null_value= TRUE;
|
maybe_null= TRUE;
|
||||||
|
null_value= TRUE;
|
||||||
max_length= 0;
|
max_length= 0;
|
||||||
name.str= name_par ? name_par : "NULL";
|
name.str= name_par ? name_par : "NULL";
|
||||||
name.length= strlen(name.str);
|
name.length= strlen(name.str);
|
||||||
@ -4309,7 +4318,7 @@ public:
|
|||||||
Item_bool_static(const char *str_arg, longlong i):
|
Item_bool_static(const char *str_arg, longlong i):
|
||||||
Item_bool(str_arg, i) {};
|
Item_bool(str_arg, i) {};
|
||||||
|
|
||||||
void set_join_tab_idx(uint join_tab_idx_arg) override
|
void set_join_tab_idx(uint8 join_tab_idx_arg) override
|
||||||
{ DBUG_ASSERT(0); }
|
{ DBUG_ASSERT(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -6227,7 +6236,8 @@ protected:
|
|||||||
{
|
{
|
||||||
DBUG_ASSERT(i->is_fixed());
|
DBUG_ASSERT(i->is_fixed());
|
||||||
item= i;
|
item= i;
|
||||||
null_value=maybe_null=item->maybe_null;
|
null_value= item->maybe_null;
|
||||||
|
maybe_null= item->maybe_null;
|
||||||
Type_std_attributes::set(item);
|
Type_std_attributes::set(item);
|
||||||
name= item->name;
|
name= item->name;
|
||||||
set_handler(item->type_handler());
|
set_handler(item->type_handler());
|
||||||
@ -6594,7 +6604,7 @@ public:
|
|||||||
bool get_date(THD *, MYSQL_TIME *, date_mode_t) override
|
bool get_date(THD *, MYSQL_TIME *, date_mode_t) override
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(0); // never should be called
|
DBUG_ASSERT(0); // never should be called
|
||||||
return null_value= true;
|
return (null_value= true);
|
||||||
}
|
}
|
||||||
bool send(Protocol *, st_value *) override
|
bool send(Protocol *, st_value *) override
|
||||||
{
|
{
|
||||||
@ -6734,25 +6744,50 @@ class Table_triggers_list;
|
|||||||
class Item_trigger_field : public Item_field,
|
class Item_trigger_field : public Item_field,
|
||||||
private Settable_routine_parameter
|
private Settable_routine_parameter
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
GRANT_INFO *table_grants;
|
||||||
public:
|
public:
|
||||||
/* Is this item represents row from NEW or OLD row ? */
|
|
||||||
enum row_version_type {OLD_ROW, NEW_ROW};
|
|
||||||
row_version_type row_version;
|
|
||||||
/* Next in list of all Item_trigger_field's in trigger */
|
/* Next in list of all Item_trigger_field's in trigger */
|
||||||
Item_trigger_field *next_trg_field;
|
Item_trigger_field *next_trg_field;
|
||||||
/* Index of the field in the TABLE::field array */
|
|
||||||
uint field_idx;
|
|
||||||
/* Pointer to Table_trigger_list object for table of this trigger */
|
/* Pointer to Table_trigger_list object for table of this trigger */
|
||||||
Table_triggers_list *triggers;
|
Table_triggers_list *triggers;
|
||||||
|
/* Is this item represents row from NEW or OLD row ? */
|
||||||
|
enum __attribute__((packed)) row_version_type {OLD_ROW, NEW_ROW};
|
||||||
|
row_version_type row_version;
|
||||||
|
/* Index of the field in the TABLE::field array */
|
||||||
|
uint16 field_idx;
|
||||||
|
|
||||||
Item_trigger_field(THD *thd, Name_resolution_context *context_arg,
|
private:
|
||||||
|
/*
|
||||||
|
Trigger field is read-only unless it belongs to the NEW row in a
|
||||||
|
BEFORE INSERT of BEFORE UPDATE trigger.
|
||||||
|
*/
|
||||||
|
bool read_only;
|
||||||
|
|
||||||
|
/*
|
||||||
|
'want_privilege' holds privileges required to perform operation on
|
||||||
|
this trigger field (SELECT_ACL if we are going to read it and
|
||||||
|
UPDATE_ACL if we are going to update it). It is initialized at
|
||||||
|
parse time but can be updated later if this trigger field is used
|
||||||
|
as OUT or INOUT parameter of stored routine (in this case
|
||||||
|
set_required_privilege() is called to appropriately update
|
||||||
|
want_privilege and cleanup() is responsible for restoring of
|
||||||
|
original want_privilege once parameter's value is updated).
|
||||||
|
*/
|
||||||
|
privilege_t original_privilege;
|
||||||
|
privilege_t want_privilege;
|
||||||
|
public:
|
||||||
|
|
||||||
|
Item_trigger_field(THD *thd, Name_resolution_context *context_arg,
|
||||||
row_version_type row_ver_arg,
|
row_version_type row_ver_arg,
|
||||||
const LEX_CSTRING &field_name_arg,
|
const LEX_CSTRING &field_name_arg,
|
||||||
privilege_t priv, const bool ro)
|
privilege_t priv, const bool ro)
|
||||||
:Item_field(thd, context_arg, field_name_arg),
|
:Item_field(thd, context_arg, field_name_arg),
|
||||||
row_version(row_ver_arg), field_idx((uint)-1), original_privilege(priv),
|
table_grants(NULL), next_trg_field(NULL), triggers(NULL),
|
||||||
want_privilege(priv), table_grants(NULL), read_only (ro)
|
row_version(row_ver_arg), field_idx(NO_CACHED_FIELD_INDEX),
|
||||||
{}
|
read_only (ro), original_privilege(priv), want_privilege(priv)
|
||||||
|
{
|
||||||
|
}
|
||||||
void setup_field(THD *thd, TABLE *table, GRANT_INFO *table_grant_info);
|
void setup_field(THD *thd, TABLE *table, GRANT_INFO *table_grant_info);
|
||||||
Type type() const override { return TRIGGER_FIELD_ITEM; }
|
Type type() const override { return TRIGGER_FIELD_ITEM; }
|
||||||
bool eq(const Item *item, bool binary_cmp) const override;
|
bool eq(const Item *item, bool binary_cmp) const override;
|
||||||
@ -6779,25 +6814,6 @@ public:
|
|||||||
return set_value(thd, NULL, it);
|
return set_value(thd, NULL, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
/*
|
|
||||||
'want_privilege' holds privileges required to perform operation on
|
|
||||||
this trigger field (SELECT_ACL if we are going to read it and
|
|
||||||
UPDATE_ACL if we are going to update it). It is initialized at
|
|
||||||
parse time but can be updated later if this trigger field is used
|
|
||||||
as OUT or INOUT parameter of stored routine (in this case
|
|
||||||
set_required_privilege() is called to appropriately update
|
|
||||||
want_privilege and cleanup() is responsible for restoring of
|
|
||||||
original want_privilege once parameter's value is updated).
|
|
||||||
*/
|
|
||||||
privilege_t original_privilege;
|
|
||||||
privilege_t want_privilege;
|
|
||||||
GRANT_INFO *table_grants;
|
|
||||||
/*
|
|
||||||
Trigger field is read-only unless it belongs to the NEW row in a
|
|
||||||
BEFORE INSERT of BEFORE UPDATE trigger.
|
|
||||||
*/
|
|
||||||
bool read_only;
|
|
||||||
public:
|
public:
|
||||||
bool unknown_splocal_processor(void *) override { return false; }
|
bool unknown_splocal_processor(void *) override { return false; }
|
||||||
bool check_vcol_func_processor(void *arg) override;
|
bool check_vcol_func_processor(void *arg) override;
|
||||||
|
@ -381,7 +381,7 @@ public:
|
|||||||
Item *expr_cache_insert_transformer(THD *thd, uchar *unused) override;
|
Item *expr_cache_insert_transformer(THD *thd, uchar *unused) override;
|
||||||
bool is_expensive_processor(void *arg) override;
|
bool is_expensive_processor(void *arg) override;
|
||||||
bool is_expensive() override;
|
bool is_expensive() override;
|
||||||
void set_join_tab_idx(uint join_tab_idx_arg) override
|
void set_join_tab_idx(uint8 join_tab_idx_arg) override
|
||||||
{ args[1]->set_join_tab_idx(join_tab_idx_arg); }
|
{ args[1]->set_join_tab_idx(join_tab_idx_arg); }
|
||||||
void get_cache_parameters(List<Item> ¶meters) override;
|
void get_cache_parameters(List<Item> ¶meters) override;
|
||||||
bool is_top_level_item() const override;
|
bool is_top_level_item() const override;
|
||||||
|
@ -3533,7 +3533,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (execute())
|
if (execute())
|
||||||
return true;
|
return true;
|
||||||
return null_value= sp_result_field->val_native(to);
|
return (null_value= sp_result_field->val_native(to));
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_null_value()
|
void update_null_value()
|
||||||
|
@ -2474,10 +2474,12 @@ bool Item_func_current_role::fix_fields(THD *thd, Item **ref)
|
|||||||
system_charset_info))
|
system_charset_info))
|
||||||
return 1;
|
return 1;
|
||||||
str_value.mark_as_const();
|
str_value.mark_as_const();
|
||||||
null_value= maybe_null= 0;
|
null_value= 0;
|
||||||
|
maybe_null= 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
null_value= maybe_null= 1;
|
null_value= 1;
|
||||||
|
maybe_null= 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,7 +879,8 @@ public:
|
|||||||
bool fix_length_and_dec()
|
bool fix_length_and_dec()
|
||||||
{
|
{
|
||||||
max_length= 512 * system_charset_info->mbmaxlen;
|
max_length= 512 * system_charset_info->mbmaxlen;
|
||||||
null_value= maybe_null= false;
|
null_value= false;
|
||||||
|
maybe_null= false;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
Item *get_copy(THD *thd)
|
Item *get_copy(THD *thd)
|
||||||
|
@ -890,7 +890,8 @@ bool Aggregator_distinct::setup(THD *thd)
|
|||||||
mem_root.
|
mem_root.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
item_sum->null_value= item_sum->maybe_null= 1;
|
item_sum->null_value= 1;
|
||||||
|
item_sum->maybe_null= 1;
|
||||||
item_sum->quick_group= 0;
|
item_sum->quick_group= 0;
|
||||||
|
|
||||||
DBUG_ASSERT(item_sum->get_arg(0)->is_fixed());
|
DBUG_ASSERT(item_sum->get_arg(0)->is_fixed());
|
||||||
|
@ -1412,7 +1412,7 @@ public:
|
|||||||
|
|
||||||
bool val_native(THD *thd, Native *to)
|
bool val_native(THD *thd, Native *to)
|
||||||
{
|
{
|
||||||
return null_value= execute() || sp_result_field->val_native(to);
|
return (null_value= execute()) || sp_result_field->val_native(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
String *val_str(String *str)
|
String *val_str(String *str)
|
||||||
|
@ -1221,10 +1221,11 @@ public:
|
|||||||
{
|
{
|
||||||
Datetime dt(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd));
|
Datetime dt(thd, args[0], Datetime::Options(TIME_CONV_NONE, thd));
|
||||||
if (!dt.is_valid_datetime())
|
if (!dt.is_valid_datetime())
|
||||||
return null_value= true;
|
return (null_value= 1);
|
||||||
|
|
||||||
Interval_DDhhmmssff it(thd, args[1]);
|
Interval_DDhhmmssff it(thd, args[1]);
|
||||||
if (!it.is_valid_interval_DDhhmmssff())
|
if (!it.is_valid_interval_DDhhmmssff())
|
||||||
return null_value= true;
|
return (null_value= true);
|
||||||
return (null_value= Sec6_add(dt.get_mysql_time(), it.get_mysql_time(), 1).
|
return (null_value= Sec6_add(dt.get_mysql_time(), it.get_mysql_time(), 1).
|
||||||
to_datetime(ltime));
|
to_datetime(ltime));
|
||||||
}
|
}
|
||||||
@ -1594,13 +1595,13 @@ public:
|
|||||||
Datetime::Options opt(TIME_CONV_NONE, thd);
|
Datetime::Options opt(TIME_CONV_NONE, thd);
|
||||||
Datetime dt(thd, item->arguments()[0], opt);
|
Datetime dt(thd, item->arguments()[0], opt);
|
||||||
if (!dt.is_valid_datetime())
|
if (!dt.is_valid_datetime())
|
||||||
return item->null_value= true;
|
return (item->null_value= true);
|
||||||
Interval_DDhhmmssff it(thd, item->arguments()[1]);
|
Interval_DDhhmmssff it(thd, item->arguments()[1]);
|
||||||
if (!it.is_valid_interval_DDhhmmssff())
|
if (!it.is_valid_interval_DDhhmmssff())
|
||||||
return item->null_value= true;
|
return (item->null_value= true);
|
||||||
return (item->null_value= (Sec6_add(dt.get_mysql_time(),
|
return (item->null_value= (Sec6_add(dt.get_mysql_time(),
|
||||||
it.get_mysql_time(), m_sign).
|
it.get_mysql_time(), m_sign).
|
||||||
to_datetime(to)));
|
to_datetime(to)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1627,10 +1628,10 @@ public:
|
|||||||
DBUG_ASSERT(item->is_fixed());
|
DBUG_ASSERT(item->is_fixed());
|
||||||
Time t(thd, item->arguments()[0]);
|
Time t(thd, item->arguments()[0]);
|
||||||
if (!t.is_valid_time())
|
if (!t.is_valid_time())
|
||||||
return item->null_value= true;
|
return (item->null_value= true);
|
||||||
Interval_DDhhmmssff i(thd, item->arguments()[1]);
|
Interval_DDhhmmssff i(thd, item->arguments()[1]);
|
||||||
if (!i.is_valid_interval_DDhhmmssff())
|
if (!i.is_valid_interval_DDhhmmssff())
|
||||||
return item->null_value= true;
|
return (item->null_value= true);
|
||||||
return (item->null_value= (Sec6_add(t.get_mysql_time(),
|
return (item->null_value= (Sec6_add(t.get_mysql_time(),
|
||||||
i.get_mysql_time(), m_sign).
|
i.get_mysql_time(), m_sign).
|
||||||
to_time(thd, to, item->decimals)));
|
to_time(thd, to, item->decimals)));
|
||||||
|
@ -6982,7 +6982,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
|
|||||||
|
|
||||||
while ((column = column_iter++))
|
while ((column = column_iter++))
|
||||||
{
|
{
|
||||||
uint unused_field_idx= NO_CACHED_FIELD_INDEX;
|
uint16 unused_field_idx= NO_CACHED_FIELD_INDEX;
|
||||||
TABLE_LIST *dummy;
|
TABLE_LIST *dummy;
|
||||||
Field *f=find_field_in_table_ref(thd, table_list, column->column.ptr(),
|
Field *f=find_field_in_table_ref(thd, table_list, column->column.ptr(),
|
||||||
column->column.length(),
|
column->column.length(),
|
||||||
|
@ -6014,10 +6014,10 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, si
|
|||||||
|
|
||||||
Field *
|
Field *
|
||||||
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
|
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
|
||||||
bool allow_rowid, uint *cached_field_index_ptr)
|
bool allow_rowid, uint16 *cached_field_index_ptr)
|
||||||
{
|
{
|
||||||
Field *field;
|
Field *field;
|
||||||
uint cached_field_index= *cached_field_index_ptr;
|
uint16 cached_field_index= *cached_field_index_ptr;
|
||||||
DBUG_ENTER("find_field_in_table");
|
DBUG_ENTER("find_field_in_table");
|
||||||
DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias.c_ptr(),
|
DBUG_PRINT("enter", ("table: '%s', field name: '%s'", table->alias.c_ptr(),
|
||||||
name));
|
name));
|
||||||
@ -6113,7 +6113,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
|
|||||||
ignored_tables_list_t ignored_tables,
|
ignored_tables_list_t ignored_tables,
|
||||||
Item **ref,
|
Item **ref,
|
||||||
bool check_privileges, bool allow_rowid,
|
bool check_privileges, bool allow_rowid,
|
||||||
uint *cached_field_index_ptr,
|
uint16 *cached_field_index_ptr,
|
||||||
bool register_tree_change, TABLE_LIST **actual_table)
|
bool register_tree_change, TABLE_LIST **actual_table)
|
||||||
{
|
{
|
||||||
Field *fld;
|
Field *fld;
|
||||||
|
@ -205,11 +205,11 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
|
|||||||
const char *table_name,
|
const char *table_name,
|
||||||
ignored_tables_list_t ignored_tables,
|
ignored_tables_list_t ignored_tables,
|
||||||
Item **ref, bool check_privileges, bool allow_rowid,
|
Item **ref, bool check_privileges, bool allow_rowid,
|
||||||
uint *cached_field_index_ptr,
|
uint16 *cached_field_index_ptr,
|
||||||
bool register_tree_change, TABLE_LIST **actual_table);
|
bool register_tree_change, TABLE_LIST **actual_table);
|
||||||
Field *
|
Field *
|
||||||
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
|
find_field_in_table(THD *thd, TABLE *table, const char *name, size_t length,
|
||||||
bool allow_rowid, uint *cached_field_index_ptr);
|
bool allow_rowid, uint16 *cached_field_index_ptr);
|
||||||
Field *
|
Field *
|
||||||
find_field_in_table_sef(TABLE *table, const char *name);
|
find_field_in_table_sef(TABLE *table, const char *name);
|
||||||
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
|
Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter,
|
||||||
|
@ -3182,8 +3182,7 @@ bool JOIN::add_having_as_table_cond(JOIN_TAB *tab)
|
|||||||
DBUG_ENTER("JOIN::add_having_as_table_cond");
|
DBUG_ENTER("JOIN::add_having_as_table_cond");
|
||||||
|
|
||||||
Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables,
|
Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables,
|
||||||
(table_map) 0, false,
|
(table_map) 0, 0, false, false);
|
||||||
false, false);
|
|
||||||
if (sort_table_cond)
|
if (sort_table_cond)
|
||||||
{
|
{
|
||||||
if (!tab->select)
|
if (!tab->select)
|
||||||
@ -3224,7 +3223,7 @@ bool JOIN::add_having_as_table_cond(JOIN_TAB *tab)
|
|||||||
QT_ORDINARY););
|
QT_ORDINARY););
|
||||||
|
|
||||||
having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0,
|
having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0,
|
||||||
~used_tables, false, false, false);
|
~used_tables, 0, false, false);
|
||||||
DBUG_EXECUTE("where",
|
DBUG_EXECUTE("where",
|
||||||
print_where(having, "having after sort", QT_ORDINARY););
|
print_where(having, "having after sort", QT_ORDINARY););
|
||||||
}
|
}
|
||||||
@ -22876,7 +22875,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
|
|||||||
|
|
||||||
if (cond->marker == 2 || cond->eq_cmp_result() == Item::COND_OK)
|
if (cond->marker == 2 || cond->eq_cmp_result() == Item::COND_OK)
|
||||||
{
|
{
|
||||||
cond->set_join_tab_idx(join_tab_idx_arg);
|
cond->set_join_tab_idx((uint8) join_tab_idx_arg);
|
||||||
return cond; // Not boolean op
|
return cond; // Not boolean op
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22914,7 +22913,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cond->marker=2;
|
cond->marker=2;
|
||||||
cond->set_join_tab_idx(join_tab_idx_arg);
|
cond->set_join_tab_idx((uint8) join_tab_idx_arg);
|
||||||
return cond;
|
return cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2356,9 +2356,9 @@ void Table_triggers_list::mark_fields_used(trg_event_type event)
|
|||||||
trg_field= trg_field->next_trg_field)
|
trg_field= trg_field->next_trg_field)
|
||||||
{
|
{
|
||||||
/* We cannot mark fields which does not present in table. */
|
/* We cannot mark fields which does not present in table. */
|
||||||
if (trg_field->field_idx != (uint)-1)
|
if (trg_field->field_idx != NO_CACHED_FIELD_INDEX)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("marking field: %d", trg_field->field_idx));
|
DBUG_PRINT("info", ("marking field: %u", (uint) trg_field->field_idx));
|
||||||
if (trg_field->get_settable_routine_parameter())
|
if (trg_field->get_settable_routine_parameter())
|
||||||
bitmap_set_bit(trigger_table->write_set, trg_field->field_idx);
|
bitmap_set_bit(trigger_table->write_set, trg_field->field_idx);
|
||||||
trigger_table->mark_column_with_deps(
|
trigger_table->mark_column_with_deps(
|
||||||
|
@ -366,7 +366,7 @@ enum enum_vcol_update_mode
|
|||||||
|
|
||||||
/* Field visibility enums */
|
/* Field visibility enums */
|
||||||
|
|
||||||
enum field_visibility_t {
|
enum __attribute__((packed)) field_visibility_t {
|
||||||
VISIBLE= 0,
|
VISIBLE= 0,
|
||||||
INVISIBLE_USER,
|
INVISIBLE_USER,
|
||||||
/* automatically added by the server. Can be queried explicitly
|
/* automatically added by the server. Can be queried explicitly
|
||||||
|
@ -869,7 +869,7 @@ static bool pack_header(THD *thd, uchar *forminfo,
|
|||||||
as auto-update field.
|
as auto-update field.
|
||||||
*/
|
*/
|
||||||
if (field->real_field_type() == MYSQL_TYPE_TIMESTAMP &&
|
if (field->real_field_type() == MYSQL_TYPE_TIMESTAMP &&
|
||||||
MTYP_TYPENR(field->unireg_check) != Field::NONE &&
|
field->unireg_check != Field::NONE &&
|
||||||
!time_stamp_pos)
|
!time_stamp_pos)
|
||||||
time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1;
|
time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1;
|
||||||
length=field->pack_length;
|
length=field->pack_length;
|
||||||
|
@ -2274,7 +2274,7 @@ innodb_instant_alter_column_allowed_reason:
|
|||||||
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
|
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBUG_ASSERT((MTYP_TYPENR(key_part->field->unireg_check)
|
DBUG_ASSERT((key_part->field->unireg_check
|
||||||
== Field::NEXT_NUMBER)
|
== Field::NEXT_NUMBER)
|
||||||
== !!(key_part->field->flags
|
== !!(key_part->field->flags
|
||||||
& AUTO_INCREMENT_FLAG));
|
& AUTO_INCREMENT_FLAG));
|
||||||
@ -2409,9 +2409,9 @@ innodb_instant_alter_column_allowed_reason:
|
|||||||
(An AUTO_INCREMENT attribute cannot
|
(An AUTO_INCREMENT attribute cannot
|
||||||
be introduced to a column with
|
be introduced to a column with
|
||||||
ALGORITHM=INPLACE.) */
|
ALGORITHM=INPLACE.) */
|
||||||
ut_ad((MTYP_TYPENR((*af)->unireg_check)
|
ut_ad(((*af)->unireg_check
|
||||||
== Field::NEXT_NUMBER)
|
== Field::NEXT_NUMBER)
|
||||||
== (MTYP_TYPENR(f->unireg_check)
|
== (f->unireg_check
|
||||||
== Field::NEXT_NUMBER));
|
== Field::NEXT_NUMBER));
|
||||||
goto next_column;
|
goto next_column;
|
||||||
}
|
}
|
||||||
@ -8172,7 +8172,7 @@ err_exit:
|
|||||||
|
|
||||||
field = altered_table->field[i];
|
field = altered_table->field[i];
|
||||||
|
|
||||||
DBUG_ASSERT((MTYP_TYPENR(field->unireg_check)
|
DBUG_ASSERT((field->unireg_check
|
||||||
== Field::NEXT_NUMBER)
|
== Field::NEXT_NUMBER)
|
||||||
== !!(field->flags & AUTO_INCREMENT_FLAG));
|
== !!(field->flags & AUTO_INCREMENT_FLAG));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user