Below is the list of changes that have just been committed into a local
4.1 repository of timka. When timka 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
1.2085 05/03/09 16:51:03 timour@stripped +4 -0
Fix for BUG#7425.
The reported problems were due to two completely unrelated omissions.
1) The file sort procedure didn't correctly create the sort key in
make_sortkey when the sortkey was an unsigned integer.
2) The name resolution procedure for column references inside a HAVING
clause did not propagate the unsigned_flag of the resolved references.
This patch corrects both problems.
sql/item.cc
1.193 05/03/09 16:50:57 timour@stripped +1 -0
Once an Item_ref is resolved, propagate the unsigned_flag to the resolved item.
sql/filesort.cc
1.92 05/03/09 16:50:57 timour@stripped +8 -2
Take into account whether 'item' represents a signed or an unsigned integer.
mysql-test/t/select.test
1.34 05/03/09 16:50:57 timour@stripped +11 -0
Added test for BUG#7425.
mysql-test/r/select.result
1.50 05/03/09 16:50:57 timour@stripped +23 -0
Added test result for BUG#7425.
# 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: timour
# Host: zmei.home
# Root: /home/timka/mysql/src/4.1-bug-7425
--- 1.91/sql/filesort.cc 2005-02-28 11:59:41 +02:00
+++ 1.92/sql/filesort.cc 2005-03-09 16:50:57 +02:00
@@ -656,12 +656,18 @@
to[3]= (uchar) (value >> 32);
to[2]= (uchar) (value >> 40);
to[1]= (uchar) (value >> 48);
- to[0]= (uchar) (value >> 56) ^ 128; // Fix sign
+ if (item->unsigned_flag) /* Fix sign */
+ to[0]= (uchar) (value >> 56);
+ else
+ to[0]= (uchar) (value >> 56) ^ 128; /* Reverse signbit */
#else
to[3]= (uchar) value;
to[2]= (uchar) (value >> 8);
to[1]= (uchar) (value >> 16);
- to[0]= (uchar) (value >> 24) ^ 128; // Fix sign
+ if (item->unsigned_flag) /* Fix sign */
+ to[0]= (uchar) (value >> 24);
+ else
+ to[0]= (uchar) (value >> 24) ^ 128; /* Reverse signbit */
#endif
break;
}
--- 1.192/sql/item.cc 2005-03-04 12:15:39 +02:00
+++ 1.193/sql/item.cc 2005-03-09 16:50:57 +02:00
@@ -2281,6 +2281,7 @@
decimals= (*ref)->decimals;
collation.set((*ref)->collation);
with_sum_func= (*ref)->with_sum_func;
+ unsigned_flag= (*ref)->unsigned_flag;
fixed= 1;
}
--- 1.49/mysql-test/r/select.result 2005-02-17 07:16:54 +02:00
+++ 1.50/mysql-test/r/select.result 2005-03-09 16:50:57 +02:00
@@ -2422,3 +2422,26 @@
city
London
DROP TABLE t1;
+create table t1 (a int(11) unsigned, b int(11) unsigned);
+insert into t1 values (1,0), (1,1), (1,2);
+select a-b from t1 order by 1;
+a-b
+0
+1
+18446744073709551615
+select a-b , (a-b < 0) from t1 order by 1;
+a-b (a-b < 0)
+0 0
+1 0
+18446744073709551615 0
+select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
+d (a-b >= 0) b
+1 1 0
+0 1 1
+18446744073709551615 1 2
+select cast((a - b) as unsigned) from t1 order by 1;
+cast((a - b) as unsigned)
+0
+1
+18446744073709551615
+drop table t1;
--- 1.33/mysql-test/t/select.test 2005-02-17 07:16:15 +02:00
+++ 1.34/mysql-test/t/select.test 2005-03-09 16:50:57 +02:00
@@ -1964,3 +1964,14 @@
DROP TABLE t1;
+#
+# Bug#7425 inconsistent sort order on unsigned columns result of substraction
+#
+
+create table t1 (a int(11) unsigned, b int(11) unsigned);
+insert into t1 values (1,0), (1,1), (1,2);
+select a-b from t1 order by 1;
+select a-b , (a-b < 0) from t1 order by 1;
+select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
+select cast((a - b) as unsigned) from t1 order by 1;
+drop table t1;
| Thread |
|---|
| • bk commit into 4.1 tree (timour:1.2085) BUG#7425 | timour | 9 Mar |