1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge maria-5.3-mwl248 -> 5.5 = maria-5.5-mwl248.

This commit is contained in:
Igor Babaev
2012-03-19 01:35:32 -07:00
53 changed files with 3608 additions and 21 deletions

View File

@@ -63,6 +63,7 @@ enum Derivation
#define my_charset_numeric my_charset_latin1
#define MY_REPERTOIRE_NUMERIC MY_REPERTOIRE_ASCII
class Count_distinct_field;
struct ha_field_option_struct;
struct st_cache_field;
@@ -213,6 +214,57 @@ public:
*/
bool is_created_from_null_item;
bool is_stat_field; /* TRUE in Field objects created for column min/max values */
/* Statistical data on a column */
class Column_statistics
{
public:
/*
Bitmap indicating what statistical characteristics
are available for the column
*/
uint32 column_stat_nulls;
/* Minimum value for the column */
Field *min_value;
/* Maximum value for the column */
Field *max_value;
/*
The ratio Z/N, where N is the total number of rows,
Z is the number of nulls in the column
*/
double nulls_ratio;
/*
Average number of bytes occupied by the representation of a
value of the column in memory buffers such as join buffer.
CHAR values are stripped of trailing spaces.
Flexible values are stripped of their length prefixes.
*/
double avg_length;
/*
The ratio N/D, where N is the number of rows with null value
in the column, D the number of distinct values among them
*/
double avg_frequency;
};
/*
This structure is used for statistical data on the column
that has been read from the statistical table column_stat
*/
Column_statistics read_stat;
/*
This structure is used for statistical data on the column that
is collected by the function collect_statistics_for_table
*/
Column_statistics write_stat;
/* These members are used only when collecting statistics on the column */
ha_rows nulls;
ulonglong column_total_length;
Count_distinct_field *count_distinct;
/*
This is additional data provided for any computed(virtual) field.
In particular it includes a pointer to the item by which this field
@@ -305,6 +357,26 @@ public:
virtual uint32 data_length() { return pack_length(); }
virtual uint32 sort_length() const { return pack_length(); }
/*
Get the number bytes occupied by the value in the field.
CHAR values are stripped of trailing spaces.
Flexible values are stripped of their length.
*/
virtual uint32 value_length()
{
uint len;
if (!zero_pack() &&
(type() == MYSQL_TYPE_STRING &&
(len= pack_length()) >= 4 && len < 256))
{
uchar *str, *end;
for (str= ptr, end= str+len; end > str && end[-1] == ' '; end--) {}
len=(uint) (end-str);
return len;
}
return data_length();
}
/**
Get the maximum size of the data in packed format.
@@ -346,6 +418,36 @@ public:
{ return cmp(a, b); }
virtual int key_cmp(const uchar *str, uint length)
{ return cmp(ptr,str); }
/*
Update the value m of the 'min_val' field with the current value v
of this field if force_update is set to TRUE or if v < m.
Return TRUE if the value has been updated.
*/
virtual bool update_min(Field *min_val, bool force_update)
{
bool update_fl= force_update || cmp(ptr, min_val->ptr) < 0;
if (update_fl)
{
min_val->set_notnull();
memcpy(min_val->ptr, ptr, pack_length());
}
return update_fl;
}
/*
Update the value m of the 'max_val' field with the current value v
of this field if force_update is set to TRUE or if v > m.
Return TRUE if the value has been updated.
*/
virtual bool update_max(Field *max_val, bool force_update)
{
bool update_fl= force_update || cmp(ptr, max_val->ptr) > 0;
if (update_fl)
{
max_val->set_notnull();
memcpy(max_val->ptr, ptr, pack_length());
}
return update_fl;
}
virtual uint decimals() const { return 0; }
/*
Caller beware: sql_type can change str.Ptr, so check
@@ -417,6 +519,8 @@ public:
uchar *new_ptr, uchar *new_null_ptr,
uint new_null_bit);
Field *clone(MEM_ROOT *mem_root, TABLE *new_table);
Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff,
bool stat_flag= FALSE);
inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
{
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
@@ -1808,6 +1912,10 @@ public:
int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
int key_cmp(const uchar *,const uchar*);
int key_cmp(const uchar *str, uint length);
/* Never update the value of min_val for a blob field */
bool update_min(Field *min_val, bool force_update) { return FALSE; }
/* Never update the value of max_val for a blob field */
bool update_max(Field *max_val, bool force_update) { return FALSE; }
uint32 key_length() const { return 0; }
void sort_string(uchar *buff,uint length);
uint32 pack_length() const
@@ -1825,6 +1933,7 @@ public:
{ return (uint32) (packlength); }
uint row_pack_length() { return pack_length_no_ptr(); }
uint32 sort_length() const;
uint32 value_length() { return get_length(); }
virtual uint32 max_data_length() const
{
return (uint32) (((ulonglong) 1 << (packlength*8)) -1);
@@ -2092,6 +2201,28 @@ public:
{ return cmp_binary((uchar *) a, (uchar *) b); }
int key_cmp(const uchar *str, uint length);
int cmp_offset(uint row_offset);
bool update_min(Field *min_val, bool force_update)
{
longlong val= val_int();
bool update_fl= force_update || val < min_val->val_int();
if (update_fl)
{
min_val->set_notnull();
min_val->store(val, FALSE);
}
return update_fl;
}
bool update_max(Field *max_val, bool force_update)
{
longlong val= val_int();
bool update_fl= force_update || val > max_val->val_int();
if (update_fl)
{
max_val->set_notnull();
max_val->store(val, FALSE);
}
return update_fl;
}
void get_image(uchar *buff, uint length, CHARSET_INFO *cs)
{ get_key_image(buff, length, itRAW); }
void set_image(const uchar *buff,uint length, CHARSET_INFO *cs)