Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-06-09 21:27:06+05:00, gshchepa@stripped +5 -0
Fixed bug #28625:
DECIMAL column was used instead of BIGINT for the minimal possible
BIGINT (-9223372036854775808).
Partial evaluation mechanism was added to Item_func_neg for
the case of LONGLONG_MIN constant argment.
mysql-test/r/bigint.result@stripped, 2007-06-09 21:18:51+05:00, gshchepa@stripped +7 -0
Added test case for bug #28625.
mysql-test/t/bigint.test@stripped, 2007-06-09 21:18:50+05:00, gshchepa@stripped +8 -0
Added test result for bug #28625.
sql/item_func.cc@stripped, 2007-06-09 21:18:53+05:00, gshchepa@stripped +79 -0
Fixed bug #28625.
The Item_func_neg::partial_eval method has been added to
implement partial evaluation mechanism for case of LONGLONG_MIN
argument.
sql/item_func.h@stripped, 2007-06-09 21:24:16+05:00, gshchepa@stripped +1 -0
Fixed bug #28625.
The Item_func_neg::partial_eval method has been added.
sql/sql_yacc.yy@stripped, 2007-06-09 21:24:30+05:00, gshchepa@stripped +1 -1
Fixed bug #28625.
The Item_func_neg::partial_eval method has been used
instead of direct call to Item_func_neg class constructor.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gshchepa
# Host: gleb.loc
# Root: /home/uchum/work/bk/5.0-opt-28625
--- 1.344/sql/item_func.cc 2007-06-01 02:17:03 +05:00
+++ 1.345/sql/item_func.cc 2007-06-09 21:18:53 +05:00
@@ -1475,6 +1475,85 @@ void Item_func_mod::fix_length_and_dec()
}
+/*
+ Prepend given expression string with unary minus sign
+
+ SYNOPSIS
+ alloc_negated_string()
+ thd Thread object
+ str Pointer to original expression string
+ length Length of str excluding terminating '\0' byte
+
+ DESCRIPTION
+ The alloc_negated_string function allocates new string and
+ fill it with unary minus sign and data of given expression
+ string `str' of size `length'. When it is necessary,
+ alloc_negated_string() also surrounds `str' with brackets.
+
+ RETURN
+ Allocated string with length.
+*/
+
+static LEX_STRING alloc_negated_string(THD *thd, const char *str, uint length)
+{
+ LEX_STRING tmp;
+ if (my_isdigit(thd->charset(), *str))
+ {
+ tmp.length= length + 1; // +1 for '-'
+ tmp.str= (char *) thd->alloc(tmp.length + 1); // +1 for '\0'
+ tmp.str[0]= '-';
+ memcpy(tmp.str + 1, str, length);
+ }
+ else
+ {
+ tmp.length= length + 3; // +3 for '-', '(' and ')'
+ tmp.str= (char *) thd->alloc(tmp.length + 1); // +1 for '\0'
+ tmp.str[0]= '-';
+ tmp.str[1]= '(';
+ memcpy(tmp.str + 2, str, length);
+ tmp.str[tmp.length - 1]= ')';
+ }
+ tmp.str[tmp.length]= '\0';
+ return tmp;
+}
+
+
+/*
+ Partially evaluate Item_func_neg when it is possible
+
+ SYNOPSIS
+ Item_func_neg::partial_eval()
+ thd Thread object
+ a Pointer to argument object
+
+ DESCRIPTION
+ The partial_eval method applies negation operator to
+ the given argument on the fly when it is possible and
+ returns Item_int object instead of Item_func_neg.
+
+ RETURN
+ Allocated Item object.
+
+ NOTE
+ Currently this method applies unary minus to Item_uint
+ constant of value (ulonglong) LONGLONG_MIN only.
+ TODO: improve the partial_eval method to deal with
+ another numeric constants.
+*/
+
+Item* Item_func_neg::partial_eval(THD *thd, Item *a)
+{
+ if (a->type() == INT_ITEM &&
+ a->unsigned_flag &&
+ a->val_int() == LONGLONG_MIN)
+ {
+ LEX_STRING tmp= alloc_negated_string(thd, a->name, a->max_length);
+ return new Item_int(tmp.str, LONGLONG_MIN, tmp.length);
+ }
+ return new Item_func_neg(a);
+}
+
+
double Item_func_neg::real_op()
{
double value= args[0]->val_real();
--- 1.170/sql/item_func.h 2007-06-01 02:17:03 +05:00
+++ 1.171/sql/item_func.h 2007-06-09 21:24:16 +05:00
@@ -430,6 +430,7 @@ public:
class Item_func_neg :public Item_func_num1
{
public:
+ static Item* partial_eval(THD *thd, Item *a);
Item_func_neg(Item *a) :Item_func_num1(a) {}
double real_op();
longlong int_op();
--- 1.519/sql/sql_yacc.yy 2007-05-15 14:56:05 +05:00
+++ 1.520/sql/sql_yacc.yy 2007-06-09 21:24:30 +05:00
@@ -4673,7 +4673,7 @@ simple_expr:
| simple_expr OR_OR_SYM simple_expr
{ $$= new Item_func_concat($1, $3); }
| '+' simple_expr %prec NEG { $$= $2; }
- | '-' simple_expr %prec NEG { $$= new Item_func_neg($2); }
+ | '-' simple_expr %prec NEG { $$= Item_func_neg::partial_eval(YYTHD, $2); }
| '~' simple_expr %prec NEG { $$= new Item_func_bit_neg($2); }
| not2 simple_expr %prec NEG { $$= negate_expression(YYTHD, $2); }
| '(' subselect ')'
--- 1.35/mysql-test/r/bigint.result 2007-05-16 10:12:48 +05:00
+++ 1.36/mysql-test/r/bigint.result 2007-06-09 21:18:51 +05:00
@@ -362,3 +362,10 @@ cast(-19999999999999999999 as signed)
-9223372036854775808
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
+create table t1 select -9223372036854775808;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `-9223372036854775808` bigint(20) NOT NULL default '0'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
--- 1.30/mysql-test/t/bigint.test 2007-05-16 10:12:48 +05:00
+++ 1.31/mysql-test/t/bigint.test 2007-06-09 21:18:50 +05:00
@@ -294,3 +294,11 @@ drop table t1;
select cast(19999999999999999999 as signed);
select cast(-19999999999999999999 as signed);
+
+#
+# Bug #28625: -9223372036854775808 doesn't fit in BIGINT.
+#
+
+create table t1 select -9223372036854775808;
+show create table t1;
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (gshchepa:1.2506) BUG#28625 | gshchepa | 9 Jun |