Skip to content

Commit

Permalink
various cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
montywi authored and vuvova committed Jun 30, 2016
1 parent db7edfe commit 2fe8dd0
Show file tree
Hide file tree
Showing 22 changed files with 148 additions and 159 deletions.
2 changes: 1 addition & 1 deletion client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ static void init_connection_thd(struct st_connection *cn)
cn->has_thread=TRUE;
}

#else /*EMBEDDED_LIBRARY*/
#else /* ! EMBEDDED_LIBRARY*/

#define init_connection_thd(X) do { } while(0)
#define do_send_query(cn,q,q_len) mysql_send_query(cn->mysql, q, q_len)
Expand Down
2 changes: 1 addition & 1 deletion extra/innochecksum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ parse_page(
}
if (per_page_details) {
printf("index %lu page %lu leaf %u n_recs %lu data_bytes %lu"
"\n", (ulong) id, page_no, is_leaf, n_recs, data_bytes);
"\n", (ulong) id, (ulong) page_no, is_leaf, n_recs, data_bytes);
}
/* update per-index statistics */
{
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/lib/v1/mysql-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ ()
if (! -f $glob_scriptname)
{
mtr_error("Can't find the location for the mysql-test-run script\n" .
"Go to to the mysql-test directory and execute the script " .
"Go to the mysql-test directory and execute the script " .
"as follows:\n./$glob_scriptname");
}

Expand Down
2 changes: 1 addition & 1 deletion sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9793,7 +9793,7 @@ bool Column_definition::check(THD *thd)
const uint conditional_type_modifiers= AUTO_INCREMENT_FLAG;
uint sign_len, allowed_type_modifier= 0;
ulong max_field_charlength= MAX_FIELD_CHARLENGTH;
DBUG_ENTER("Create_field::check");
DBUG_ENTER("Column_definition::check");

/* Initialize data for a computed field */
if (vcol_info)
Expand Down
1 change: 0 additions & 1 deletion sql/filesort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,6 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select,
sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set,
&sort_form->tmp_set);


if (quick_select)
{
if (select->quick->reset())
Expand Down
15 changes: 11 additions & 4 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ int Item::save_time_in_field(Field *field)
int Item::save_date_in_field(Field *field)
{
MYSQL_TIME ltime;
if (get_date(&ltime, sql_mode_for_dates(current_thd)))
if (get_date(&ltime, sql_mode_for_dates(field->table->in_use)))
return set_field_to_null_with_conversions(field, 0);
field->set_notnull();
return field->store_time_dec(&ltime, decimals);
Expand Down Expand Up @@ -889,17 +889,22 @@ bool Item_field::find_item_in_field_list_processor(uchar *arg)
NOTES
This is used by filesort to register used fields in a a temporary
column read set or to register used fields in a view
column read set or to register used fields in a view or check constraint
*/

bool Item_field::register_field_in_read_map(uchar *arg)
{
TABLE *table= (TABLE *) arg;
if (field->table == table || !table)
bitmap_set_bit(field->table->read_set, field->field_index);
if (field->vcol_info && field->vcol_info->expr_item)
return field->vcol_info->expr_item->walk(&Item::register_field_in_read_map,
if (field->vcol_info && field->vcol_info->expr_item &&
!bitmap_is_set(field->table->vcol_set, field->field_index))
{
/* Ensure that the virtual fields is updated on read or write */
bitmap_set_bit(field->table->vcol_set, field->field_index);
return field->vcol_info->expr_item->walk(&Item::register_field_in_read_map,
1, arg);
}
return 0;
}

Expand Down Expand Up @@ -1123,6 +1128,7 @@ Item *Item::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
TODO: we should eventually check all other use cases of change_item_tree().
Perhaps some more potentially dangerous substitution examples exist.
*/

Item *Item_cache::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
{
if (!example)
Expand Down Expand Up @@ -1150,6 +1156,7 @@ Item *Item_cache::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
the latter returns a non-fixed Item, so val_str() crashes afterwards.
Override Item_num method, to return a fixed item.
*/

Item *Item_num::safe_charset_converter(THD *thd, CHARSET_INFO *tocs)
{
/*
Expand Down
4 changes: 1 addition & 3 deletions sql/item_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ class Item_num_op :public Item_func_numhybrid
{
print_op(str, query_type);
}

void fix_length_and_dec();
};

Expand Down Expand Up @@ -1409,7 +1408,7 @@ class Item_udf_func :public Item_func
return res;
}
void fix_num_length_and_dec();
void update_used_tables()
void update_used_tables()
{
/*
TODO: Make a member in UDF_INIT and return if a UDF is deterministic or
Expand Down Expand Up @@ -2019,7 +2018,6 @@ class Item_func_match :public Item_real_func

return false;
}

};


Expand Down
2 changes: 1 addition & 1 deletion sql/item_strfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ class Item_func_char :public Item_str_func
Item_str_func(thd, list)
{ collation.set(cs); }
String *val_str(String *);
void fix_length_and_dec()
void fix_length_and_dec()
{
max_length= arg_count * 4;
}
Expand Down
8 changes: 4 additions & 4 deletions sql/item_sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Aggregator : public Sql_alloc
Aggregator (Item_sum *arg): item_sum(arg) {}
virtual ~Aggregator () {} /* Keep gcc happy */

enum Aggregator_type { SIMPLE_AGGREGATOR, DISTINCT_AGGREGATOR };
enum Aggregator_type { SIMPLE_AGGREGATOR, DISTINCT_AGGREGATOR };
virtual Aggregator_type Aggrtype() = 0;

/**
Expand Down Expand Up @@ -411,8 +411,8 @@ class Item_sum :public Item_func_or_sum
*/
inline bool reset_and_add()
{
aggregator_clear();
return aggregator_add();
aggregator_clear();
return aggregator_add();
};

/*
Expand Down Expand Up @@ -458,7 +458,7 @@ class Item_sum :public Item_func_or_sum
*/
void make_const ()
{
used_tables_cache= 0;
used_tables_cache= 0;
const_item_cache= true;
}
virtual bool const_during_execution() const { return false; }
Expand Down
18 changes: 9 additions & 9 deletions sql/item_timefunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Item_func_period_add :public Item_int_func
Item_func_period_add(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {}
longlong val_int();
const char *func_name() const { return "period_add"; }
void fix_length_and_dec()
void fix_length_and_dec()
{
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
}
Expand All @@ -76,7 +76,7 @@ class Item_func_to_days :public Item_int_func
Item_func_to_days(THD *thd, Item *a): Item_int_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "to_days"; }
void fix_length_and_dec()
void fix_length_and_dec()
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
Expand All @@ -99,7 +99,7 @@ class Item_func_to_seconds :public Item_int_func
Item_func_to_seconds(THD *thd, Item *a): Item_int_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "to_seconds"; }
void fix_length_and_dec()
void fix_length_and_dec()
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
Expand Down Expand Up @@ -132,7 +132,7 @@ class Item_func_dayofmonth :public Item_int_func
Item_func_dayofmonth(THD *thd, Item *a): Item_int_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "dayofmonth"; }
void fix_length_and_dec()
void fix_length_and_dec()
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
Expand All @@ -155,7 +155,7 @@ class Item_func_month :public Item_func
longlong val_int();
double val_real()
{ DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
String *val_str(String *str)
String *val_str(String *str)
{
longlong nr= val_int();
if (null_value)
Expand All @@ -166,7 +166,7 @@ class Item_func_month :public Item_func
const char *func_name() const { return "month"; }
enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
void fix_length_and_dec()
void fix_length_and_dec()
{
decimals= 0;
fix_char_length(2);
Expand Down Expand Up @@ -207,7 +207,7 @@ class Item_func_dayofyear :public Item_int_func
Item_func_dayofyear(THD *thd, Item *a): Item_int_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "dayofyear"; }
void fix_length_and_dec()
void fix_length_and_dec()
{
decimals= 0;
fix_char_length(3);
Expand Down Expand Up @@ -291,7 +291,7 @@ class Item_func_second :public Item_int_func
Item_func_second(THD *thd, Item *a): Item_int_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "second"; }
void fix_length_and_dec()
void fix_length_and_dec()
{
decimals=0;
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
Expand Down Expand Up @@ -1045,7 +1045,7 @@ class Item_func_microsecond :public Item_int_func
Item_func_microsecond(THD *thd, Item *a): Item_int_func(thd, a) {}
longlong val_int();
const char *func_name() const { return "microsecond"; }
void fix_length_and_dec()
void fix_length_and_dec()
{
decimals=0;
maybe_null=1;
Expand Down
2 changes: 0 additions & 2 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4108,9 +4108,7 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
thd->status_var.global_memory_used+= size;
}
else
{
update_global_memory_status(size);
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions sql/share/errmsg-utf8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4846,7 +4846,7 @@ ER_WARN_USING_OTHER_HANDLER
por "Usando engine de armazenamento %s para tabela '%s'"
spa "Usando motor de almacenamiento %s para tabla '%s'"
swe "Använder handler %s för tabell '%s'"
ER_CANT_AGGREGATE_2COLLATIONS
ER_CANT_AGGREGATE_2COLLATIONS
eng "Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'"
ger "Unerlaubte Mischung von Sortierreihenfolgen (%s, %s) und (%s, %s) für Operation '%s'"
jpn "照合順序 (%s,%s) と (%s,%s) の混在は操作 '%s' では不正です。"
Expand Down Expand Up @@ -7206,8 +7206,8 @@ ER_INVALID_NTILE_ARGUMENT
ER_EXPRESSION_IS_TOO_BIG
eng "%s expression is too big for '%s'"
ER_ERROR_EVALUATING_EXPRESSION
eng "Got an error evaluating stored expression %`.192s"
eng "Got an error evaluating stored expression %`s"
ER_CALCULATING_DEFAULT_VALUE
eng "Got an error when calculating default value for '%s'"
eng "Got an error when calculating default value for %`s"
ER_EXPRESSION_REFERS_TO_UNINIT_FIELD 01000
eng "Expression for field %`-.64s is refering to uninitialized field %`-.64s"
eng "Expression for field %`-.64s is refering to uninitialized field %`s"
2 changes: 1 addition & 1 deletion sql/sql_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
- Run a normal repair using the new index file and the old data file
*/

if (table->s->frm_version != FRM_VER_TRUE_VARCHAR &&
if (table->s->frm_version < FRM_VER_TRUE_VARCHAR &&
table->s->varchar_fields)
{
error= send_check_errmsg(thd, table_list, "repair",
Expand Down
36 changes: 21 additions & 15 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7728,7 +7728,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
table_arg->auto_increment_field_not_null= FALSE;
f.rewind();
}
else if (thd->lex->unit.insert_table_with_stored_vcol)
else
vcol_table= thd->lex->unit.insert_table_with_stored_vcol;

while ((fld= f++))
Expand Down Expand Up @@ -7796,6 +7796,7 @@ void switch_to_nullable_trigger_fields(List<Item> &items, TABLE *table)
{
Field** field= table->field_to_fill();

/* True if we have NOT NULL fields and BEFORE triggers */
if (field != table->field)
{
List_iterator_fast<Item> it(items);
Expand Down Expand Up @@ -7888,7 +7889,8 @@ static bool not_null_fields_have_null_values(TABLE *table)
*/

bool
fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields,
fill_record_n_invoke_before_triggers(THD *thd, TABLE *table,
List<Item> &fields,
List<Item> &values, bool ignore_errors,
enum trg_event_type event)
{
Expand All @@ -7898,29 +7900,30 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields,
result= fill_record(thd, table, fields, values, ignore_errors,
event == TRG_EVENT_UPDATE);

if (!result && triggers)
result= triggers->process_triggers(thd, event, TRG_ACTION_BEFORE, TRUE) ||
not_null_fields_have_null_values(table);

/*
Re-calculate virtual fields to cater for cases when base columns are
updated by the triggers.
*/
if (!result && triggers)
{
if (triggers->process_triggers(thd, event, TRG_ACTION_BEFORE,
TRUE) ||
not_null_fields_have_null_values(table))
return TRUE;

/*
Re-calculate virtual fields to cater for cases when base columns are
updated by the triggers.
*/
List_iterator_fast<Item> f(fields);
Item *fld;
Item_field *item_field;
if (fields.elements)
{
fld= (Item_field*)f++;
item_field= fld->field_for_view_update();
if (item_field && item_field->field && table && table->vfield)
if (item_field && table->vfield)
{
DBUG_ASSERT(table == item_field->field->table);
result= update_virtual_fields(thd, table,
table->triggers ? VCOL_UPDATE_ALL :
VCOL_UPDATE_FOR_WRITE);
VCOL_UPDATE_FOR_WRITE);
}
}
}
Expand All @@ -7930,6 +7933,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields,

/**
Fill the field buffer of a table with the values of an Item list
All fields are given a value

@param thd thread handler
@param table_arg the table that is being modified
Expand Down Expand Up @@ -8005,7 +8009,8 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
goto err;
field->set_explicit_default(value);
}
/* Update virtual fields*/
/* There is no default fields to update, as all fields are updated */
/* Update virtual fields */
thd->abort_on_warning= FALSE;
if (table->vfield &&
update_virtual_fields(thd, table,
Expand Down Expand Up @@ -8065,8 +8070,9 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, Field **ptr,
DBUG_ASSERT(table == (*ptr)->table);
if (table->vfield)
result= update_virtual_fields(thd, table,
table->triggers ? VCOL_UPDATE_ALL :
VCOL_UPDATE_FOR_WRITE);
table->triggers ?
VCOL_UPDATE_ALL :
VCOL_UPDATE_FOR_WRITE);
}
return result;

Expand Down
2 changes: 1 addition & 1 deletion sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ class Sub_statement_state
ha_rows cuted_fields, sent_row_count, examined_row_count;
ulonglong client_capabilities;
ulong query_plan_flags;
uint in_sub_stmt;
uint in_sub_stmt; /* 0, SUB_STMT_TRIGGER or SUB_STMT_FUNCTION */
bool enable_slow_log;
bool last_insert_id_used;
SAVEPOINT *savepoints;
Expand Down
Loading

0 comments on commit 2fe8dd0

Please sign in to comment.