List:Commits« Previous MessageNext Message »
From:<gshchepa Date:June 15 2007 2:29pm
Subject:bk commit into 5.0 tree (gshchepa:1.2506) BUG#28625
View as plain text  
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-15 17:29:26+05:00, gshchepa@stripped +5 -0
  Fixed bug #28625:
  DECIMAL column was used instead of BIGINT for the minimal possible
  BIGINT (-9223372036854775808).
  
  Direct creation of Item_func_neg object has been replaced with
  call to wrapper function `neg_expression'. Than function
  returns new Item_int object instead of Item_func_neg object
  when underlying object is an Item_uint literal of value
  9223372036854775808.

  mysql-test/r/bigint.result@stripped, 2007-06-15 17:29:11+05:00, gshchepa@stripped +13 -0
    Added test case for bug #28625.

  mysql-test/t/bigint.test@stripped, 2007-06-15 17:28:41+05:00, gshchepa@stripped +10 -0
    Added test result for bug #28625.

  sql/mysql_priv.h@stripped, 2007-06-15 17:20:43+05:00, gshchepa@stripped +1 -0
    Fixed bug #28625.
    The neg_expression function has been added.

  sql/sql_parse.cc@stripped, 2007-06-15 17:21:07+05:00, gshchepa@stripped +36 -0
    Fixed bug #28625.
    The neg_expression function has been added to return new Item_int
    object of value LONGLONG_MIN if the given expression is an Item_uint
    object with ((ulonglong)  LONGLONG_MIN) value, otherwise this function
    returns new Item_func_neg object.

  sql/sql_yacc.yy@stripped, 2007-06-15 17:23:07+05:00, gshchepa@stripped +1 -1
    Fixed bug #28625.
    Direct creation of Item_func_neg object has been replaced with
    call to the neg_expression function.

# 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.452/sql/mysql_priv.h	2007-05-18 01:17:45 +05:00
+++ 1.453/sql/mysql_priv.h	2007-06-15 17:20:43 +05:00
@@ -620,6 +620,7 @@ enum enum_mysql_completiontype {
 int end_trans(THD *thd, enum enum_mysql_completiontype completion);
 
 Item *negate_expression(THD *thd, Item *expr);
+Item *neg_expression(THD *thd, Item *expr);
 #include "sql_class.h"
 #include "sql_acl.h"
 #include "tztime.h"

--- 1.621/sql/sql_parse.cc	2007-05-15 14:56:04 +05:00
+++ 1.622/sql/sql_parse.cc	2007-06-15 17:21:07 +05:00
@@ -7625,6 +7625,42 @@ Item *negate_expression(THD *thd, Item *
   return new Item_func_not(expr);
 }
 
+
+/*
+  change sign of given expression
+
+  SYNOPSIS
+    neg_expression()
+    thd  thread handler
+    expr expression for negation
+
+  DESCRIPTION
+    The neg_expression function returns new Item_int object of
+    value LONGLONG_MIN if the given expression is an Item_uint object
+    with ((ulonglong)  LONGLONG_MIN) value, otherwise this function
+    returns new Item_func_neg object.
+
+  RETURN
+    expression with changed sign
+*/
+
+Item *neg_expression(THD *thd, Item *expr)
+{
+  if (expr->type() == Item::INT_ITEM &&
+      expr->unsigned_flag &&
+      expr->val_int() == LONGLONG_MIN)
+  {
+    uint new_length= expr->max_length + 1;          // +1 for '-'
+    char *buf= (char *) thd->alloc(new_length + 1); // +1 for '\0'
+    buf[0]= '-';
+    strncpy(buf + 1, expr->name, expr->max_length);
+    buf[new_length]= '\0';
+    return new Item_int(buf, LONGLONG_MIN, new_length);
+  }
+  return new Item_func_neg(expr);
+}
+
+
 /*
   Set the specified definer to the default value, which is the current user in
   the thread.

--- 1.519/sql/sql_yacc.yy	2007-05-15 14:56:05 +05:00
+++ 1.520/sql/sql_yacc.yy	2007-06-15 17:23:07 +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	{ $$= neg_expression(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-15 17:29:11 +05:00
@@ -362,3 +362,16 @@ 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;
+select -9223372036854775808, --9223372036854775808, ---9223372036854775808;
+-9223372036854775808	--9223372036854775808	---9223372036854775808
+-9223372036854775808	9223372036854775808	-9223372036854775808
+select -(-9223372036854775808), -(-(-9223372036854775808));
+-(-9223372036854775808)	-(-(-9223372036854775808))
+9223372036854775808	-9223372036854775808

--- 1.30/mysql-test/t/bigint.test	2007-05-16 10:12:48 +05:00
+++ 1.31/mysql-test/t/bigint.test	2007-06-15 17:28:41 +05:00
@@ -294,3 +294,13 @@ 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;
+select -9223372036854775808, --9223372036854775808, ---9223372036854775808;
+select -(-9223372036854775808), -(-(-9223372036854775808));
Thread
bk commit into 5.0 tree (gshchepa:1.2506) BUG#28625gshchepa15 Jun