Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf 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.1953 05/06/08 20:35:37 hf@deer.(none) +4 -0
Fix for bug #9764 (DISTINCT IFNULL truncates data)
sql/item_cmpfunc.cc
1.154 05/06/08 20:34:40 hf@deer.(none) +12 -14
max_length should be calculated differently for DECIMAL_RESULT and others
mysql-test/t/distinct.test
1.17 05/06/08 20:34:40 hf@deer.(none) +8 -0
test case added
mysql-test/r/distinct.result
1.39 05/06/08 20:34:40 hf@deer.(none) +8 -0
test result fixed
mysql-test/r/create.result
1.92 05/06/08 20:34:40 hf@deer.(none) +1 -1
test result fixed
# 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: hf
# Host: deer.(none)
# Root: /home/hf/work/mysql-5.0.9764
--- 1.153/sql/item_cmpfunc.cc Mon Jun 6 23:21:25 2005
+++ 1.154/sql/item_cmpfunc.cc Wed Jun 8 20:34:40 2005
@@ -1109,12 +1109,14 @@
void
Item_func_ifnull::fix_length_and_dec()
{
+ agg_result_type(&hybrid_type, args, 2);
maybe_null=args[1]->maybe_null;
decimals= max(args[0]->decimals, args[1]->decimals);
- max_length= (max(args[0]->max_length - args[0]->decimals,
- args[1]->max_length - args[1]->decimals) +
- decimals);
- agg_result_type(&hybrid_type, args, 2);
+ max_length= (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT) ?
+ (max(args[0]->max_length - args[0]->decimals,
+ args[1]->max_length - args[1]->decimals) + decimals) :
+ max(args[0]->max_length, args[1]->max_length);
+
switch (hybrid_type) {
case STRING_RESULT:
agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV);
@@ -1225,16 +1227,7 @@
{
maybe_null=args[1]->maybe_null || args[2]->maybe_null;
decimals= max(args[1]->decimals, args[2]->decimals);
- if (decimals == NOT_FIXED_DEC)
- {
- max_length= max(args[1]->max_length, args[2]->max_length);
- }
- else
- {
- max_length= (max(args[1]->max_length - args[1]->decimals,
- args[2]->max_length - args[2]->decimals) +
- decimals);
- }
+
enum Item_result arg1_type=args[1]->result_type();
enum Item_result arg2_type=args[2]->result_type();
bool null1=args[1]->const_item() && args[1]->null_value;
@@ -1263,6 +1256,11 @@
collation.set(&my_charset_bin); // Number
}
}
+ max_length=
+ (cached_result_type == DECIMAL_RESULT || cached_result_type == INT_RESULT) ?
+ (max(args[1]->max_length - args[1]->decimals,
+ args[2]->max_length - args[2]->decimals) + decimals) :
+ max(args[1]->max_length, args[2]->max_length);
}
--- 1.91/mysql-test/r/create.result Mon Jun 6 23:21:22 2005
+++ 1.92/mysql-test/r/create.result Wed Jun 8 20:34:40 2005
@@ -434,7 +434,7 @@
e varchar(1) NO
f datetime YES NULL
g time YES NULL
-h varbinary(23) NO
+h longblob NO
dd time YES NULL
select * from t2;
a b c d e f g h dd
--- 1.38/mysql-test/r/distinct.result Fri May 6 01:01:34 2005
+++ 1.39/mysql-test/r/distinct.result Wed Jun 8 20:34:40 2005
@@ -464,3 +464,11 @@
html prod
1 0.0000
drop table t1;
+create table t1 (id int, dsc varchar(50));
+insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three");
+select distinct id, IFNULL(dsc, '-') from t1;
+id IFNULL(dsc, '-')
+1 line number one
+2 line number two
+3 line number three
+drop table t1;
--- 1.16/mysql-test/t/distinct.test Tue Dec 16 18:44:17 2003
+++ 1.17/mysql-test/t/distinct.test Wed Jun 8 20:34:40 2005
@@ -332,3 +332,11 @@
INSERT INTO t1 VALUES ('1',1,0);
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
drop table t1;
+
+#
+# Bug 9784 DISTINCT IFNULL truncates data
+#
+create table t1 (id int, dsc varchar(50));
+insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three");
+select distinct id, IFNULL(dsc, '-') from t1;
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (hf:1.1953) BUG#9764 | holyfoot | 8 Jun |