summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-11-28 15:44:11 +0200
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-11-28 15:44:11 +0200
commitfad411e53207ba848416dbd48645f57850788504 (patch)
treefa4c02c70637d0f12ec543e10f073cc0738788a3 /sql/item.cc
parent0f58364388ce7f1aeb97240147eb23bb5d322cf4 (diff)
downloadmariadb-git-fad411e53207ba848416dbd48645f57850788504.tar.gz
BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0)
When implicitly converting string fields to numbers the string-to-number conversion error was not sent to the client. Added code to send the conversion error as warning. We also need to prevent generation of warnings from the places where val_xxx() methods are called for the sole purpose of updating the Item::null_value flag. To achieve that a special function is added (and called) : update_null_value(). This function will set the no_errors flag and will call val_xxx(). The warning generation in Field_string::val_xxx() will use the flag when generating the conversion warnings. mysql-test/r/compare.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - non-convertible strings in arithmetic operations mysql-test/r/func_gconcat.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - non-convertible strings in arithmetic operations mysql-test/r/func_group.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - non-convertible strings in arithmetic operations mysql-test/r/type_varchar.result: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - test case mysql-test/t/type_varchar.test: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - test case sql/field.cc: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - send conversion warning to the client sql/item.cc: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - send conversion warning to the client sql/item.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_func.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_subselect.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_sum.cc: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/item_sum.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - added a special function to explicitly update the null_value sql/sql_string.h: BUG#11927: Warnings shown for CAST( chr as signed) but not (chr + 0) - send conversion warning to the client
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 76f0332b4ab..79822fb0a12 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2175,12 +2175,6 @@ void Item_string::print(String *str)
}
-inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str, char *end)
-{
- return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
-}
-
-
double Item_string::val_real()
{
DBUG_ASSERT(fixed == 1);
@@ -4764,6 +4758,22 @@ bool Item_field::send(Protocol *protocol, String *buffer)
}
+void Item_field::update_null_value()
+{
+ /*
+ need to set no_errors to prevent warnings about type conversion
+ popping up.
+ */
+ THD *thd= field->table->in_use;
+ int no_errors;
+
+ no_errors= thd->no_errors;
+ thd->no_errors= 1;
+ Item::update_null_value();
+ thd->no_errors= no_errors;
+}
+
+
Item_ref::Item_ref(Name_resolution_context *context_arg,
Item **item, const char *table_name_arg,
const char *field_name_arg)
@@ -6120,7 +6130,7 @@ bool Item_cache_row::null_inside()
}
else
{
- values[i]->val_int();
+ values[i]->update_null_value();
if (values[i]->null_value)
return 1;
}