summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc74
1 files changed, 57 insertions, 17 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index c16aa3a1823..6ff743ed91d 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2071,10 +2071,12 @@ double Item_func_round::real_op()
{
double value= args[0]->val_real();
- if (!(null_value= args[0]->null_value || args[1]->null_value))
- return my_double_round(value, args[1]->val_int(), args[1]->unsigned_flag,
- truncate);
-
+ if (!(null_value= args[0]->null_value))
+ {
+ longlong dec= args[1]->val_int();
+ if (!(null_value= args[1]->null_value))
+ return my_double_round(value, dec, args[1]->unsigned_flag, truncate);
+ }
return 0.0;
}
@@ -3165,11 +3167,15 @@ void Item_udf_func::print(String *str, enum_query_type query_type)
double Item_func_udf_float::val_real()
{
+ double res;
+ my_bool tmp_null_value;
DBUG_ASSERT(fixed == 1);
DBUG_ENTER("Item_func_udf_float::val");
DBUG_PRINT("info",("result_type: %d arg_count: %d",
args[0]->result_type(), arg_count));
- DBUG_RETURN(udf.val(&null_value));
+ res= udf.val(&tmp_null_value);
+ null_value= tmp_null_value;
+ DBUG_RETURN(res);
}
@@ -3186,9 +3192,13 @@ String *Item_func_udf_float::val_str(String *str)
longlong Item_func_udf_int::val_int()
{
+ longlong res;
+ my_bool tmp_null_value;
DBUG_ASSERT(fixed == 1);
DBUG_ENTER("Item_func_udf_int::val_int");
- DBUG_RETURN(udf.val_int(&null_value));
+ res= udf.val_int(&tmp_null_value);
+ null_value= tmp_null_value;
+ DBUG_RETURN(res);
}
@@ -3205,8 +3215,10 @@ String *Item_func_udf_int::val_str(String *str)
longlong Item_func_udf_decimal::val_int()
{
- my_decimal dec_buf, *dec= udf.val_decimal(&null_value, &dec_buf);
+ my_bool tmp_null_value;
longlong result;
+ my_decimal dec_buf, *dec= udf.val_decimal(&tmp_null_value, &dec_buf);
+ null_value= tmp_null_value;
if (null_value)
return 0;
my_decimal2int(E_DEC_FATAL_ERROR, dec, unsigned_flag, &result);
@@ -3216,8 +3228,10 @@ longlong Item_func_udf_decimal::val_int()
double Item_func_udf_decimal::val_real()
{
- my_decimal dec_buf, *dec= udf.val_decimal(&null_value, &dec_buf);
+ my_bool tmp_null_value;
double result;
+ my_decimal dec_buf, *dec= udf.val_decimal(&tmp_null_value, &dec_buf);
+ null_value= tmp_null_value;
if (null_value)
return 0.0;
my_decimal2double(E_DEC_FATAL_ERROR, dec, &result);
@@ -3227,18 +3241,24 @@ double Item_func_udf_decimal::val_real()
my_decimal *Item_func_udf_decimal::val_decimal(my_decimal *dec_buf)
{
+ my_decimal *res;
+ my_bool tmp_null_value;
DBUG_ASSERT(fixed == 1);
DBUG_ENTER("Item_func_udf_decimal::val_decimal");
DBUG_PRINT("info",("result_type: %d arg_count: %d",
args[0]->result_type(), arg_count));
- DBUG_RETURN(udf.val_decimal(&null_value, dec_buf));
+ res= udf.val_decimal(&tmp_null_value, dec_buf);
+ null_value= tmp_null_value;
+ DBUG_RETURN(res);
}
String *Item_func_udf_decimal::val_str(String *str)
{
- my_decimal dec_buf, *dec= udf.val_decimal(&null_value, &dec_buf);
+ my_bool tmp_null_value;
+ my_decimal dec_buf, *dec= udf.val_decimal(&tmp_null_value, &dec_buf);
+ null_value= tmp_null_value;
if (null_value)
return 0;
if (str->length() < DECIMAL_MAX_STR_LENGTH)
@@ -3872,10 +3892,30 @@ bool Item_func_set_user_var::register_field_in_read_map(uchar *arg)
TABLE *table= (TABLE *) arg;
if (result_field->table == table || !table)
bitmap_set_bit(result_field->table->read_set, result_field->field_index);
+ if (result_field->vcol_info)
+ return result_field->vcol_info->
+ expr_item->walk(&Item::register_field_in_read_map, 1, arg);
}
return 0;
}
+/*
+ Mark field in bitmap supplied as *arg
+
+*/
+
+bool Item_func_set_user_var::register_field_in_bitmap(uchar *arg)
+{
+ MY_BITMAP *bitmap = (MY_BITMAP *) arg;
+ DBUG_ASSERT(bitmap);
+ if (result_field)
+ {
+ if (!bitmap)
+ return 1;
+ bitmap_set_bit(bitmap, result_field->field_index);
+ }
+ return 0;
+}
/**
Set value to user variable.
@@ -3979,7 +4019,7 @@ Item_func_set_user_var::update_hash(void *ptr, uint length,
/** Get the value of a variable as a double. */
-double user_var_entry::val_real(my_bool *null_value)
+double user_var_entry::val_real(bool *null_value)
{
if ((*null_value= (value == 0)))
return 0.0;
@@ -4008,7 +4048,7 @@ double user_var_entry::val_real(my_bool *null_value)
/** Get the value of a variable as an integer. */
-longlong user_var_entry::val_int(my_bool *null_value) const
+longlong user_var_entry::val_int(bool *null_value) const
{
if ((*null_value= (value == 0)))
return LL(0);
@@ -4040,7 +4080,7 @@ longlong user_var_entry::val_int(my_bool *null_value) const
/** Get the value of a variable as a string. */
-String *user_var_entry::val_str(my_bool *null_value, String *str,
+String *user_var_entry::val_str(bool *null_value, String *str,
uint decimals)
{
if ((*null_value= (value == 0)))
@@ -4073,7 +4113,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str,
/** Get the value of a variable as a decimal. */
-my_decimal *user_var_entry::val_decimal(my_bool *null_value, my_decimal *val)
+my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
{
if ((*null_value= (value == 0)))
return 0;
@@ -5762,7 +5802,7 @@ Item_func_sp::cleanup()
sp_result_field= NULL;
}
m_sp= NULL;
- dummy_table->alias= NULL;
+ dummy_table->alias.free();
Item_func::cleanup();
}
@@ -5788,7 +5828,7 @@ Item_func_sp::func_name() const
qname.append('.');
}
append_identifier(thd, &qname, m_name->m_name.str, m_name->m_name.length);
- return qname.ptr();
+ return qname.c_ptr_safe();
}
@@ -5844,7 +5884,7 @@ Item_func_sp::init_result_field(THD *thd)
*/
share= dummy_table->s;
- dummy_table->alias = "";
+ dummy_table->alias.set("", 0, table_alias_charset);
dummy_table->maybe_null = maybe_null;
dummy_table->in_use= thd;
dummy_table->copy_blobs= TRUE;