summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/sql/item.cc b/sql/item.cc
index de4716350c2..c4bb1a399ab 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1,5 +1,6 @@
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2012, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -8505,10 +8506,14 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
or less than the original Item. A 0 may also be returned if
out of memory.
- @note We only use this on the range optimizer/partition pruning,
+ @note We use this in the range optimizer/partition pruning,
because in some cases we can't store the value in the field
without some precision/character loss.
+ We similarly use it to verify that expressions like
+ BIGINT_FIELD <cmp> <literal value>
+ is done correctly (as int/decimal/float according to literal type).
+
@todo rewrite it to use Arg_comparator (currently it's a simplified and
incomplete version of it)
*/
@@ -8552,7 +8557,7 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
return my_time_compare(&field_time, &item_time);
}
- return stringcmp(field_result, item_result);
+ return sortcmp(field_result, item_result, field->charset());
}
if (res_type == INT_RESULT)
return 0; // Both are of type int
@@ -8564,7 +8569,7 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
if (item->null_value)
return 0;
field_val= field->val_decimal(&field_buf);
- return my_decimal_cmp(item_val, field_val);
+ return my_decimal_cmp(field_val, item_val);
}
/*
We have to check field->cmp_type() instead of res_type,
@@ -8585,10 +8590,15 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
}
return my_time_compare(&field_time, &item_time);
}
- double result= item->val_real();
+ /*
+ The patch for Bug#13463415 started using this function for comparing
+ BIGINTs. That uncovered a bug in Visual Studio 32bit optimized mode.
+ Prefixing the auto variables with volatile fixes the problem....
+ */
+ volatile double result= item->val_real();
if (item->null_value)
return 0;
- double field_result= field->val_real();
+ volatile double field_result= field->val_real();
if (field_result < result)
return -1;
else if (field_result > result)