summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2005-05-03 12:47:27 +0400
committerkonstantin@mysql.com <>2005-05-03 12:47:27 +0400
commit3589e78fdaad94daaefa69054588b2769c0096b1 (patch)
tree08af187bf187a284afa4c4965c0bedf2de9add60 /sql/item_func.cc
parent4b9f462da72bf125f74d3640946607c9735e471f (diff)
downloadmariadb-git-3589e78fdaad94daaefa69054588b2769c0096b1.tar.gz
A fix and test case for Bug#9096 "select doesn't return all matched
records if prepared statements is used". This fix changes equality evaluation method of basic constants from by-name to by-value, thus effectively enabling use of parameter markers in some optimizations (constants propagation, evaluation of possible keys for query).
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 2b38584fe23..3c548b2aa9f 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -790,10 +790,12 @@ void Item_func_neg::fix_length_and_dec()
maximum number of bytes real or integer may require. Note that all
constants are non negative so we don't need to account for removed '-'.
B) argument returns a string.
+ Use val() to get value as arg_type doesn't mean that item is
+ Item_int or Item_real due to existence of Item_param.
*/
if (arg_result == STRING_RESULT ||
- (arg_type == REAL_ITEM && ((Item_real*)args[0])->value >= 0) ||
- (arg_type == INT_ITEM && ((Item_int*)args[0])->value > 0))
+ (arg_type == REAL_ITEM && args[0]->val() >= 0) ||
+ (arg_type == INT_ITEM && args[0]->val_int() > 0))
max_length++;
if (args[0]->result_type() == INT_RESULT)
@@ -809,8 +811,7 @@ void Item_func_neg::fix_length_and_dec()
signed integers)
*/
if (args[0]->type() != INT_ITEM ||
- ((ulonglong) ((Item_uint*) args[0])->value <=
- (ulonglong) LONGLONG_MIN))
+ (((ulonglong) args[0]->val_int()) <= (ulonglong) LONGLONG_MIN))
hybrid_type= INT_RESULT;
}
}