diff --git a/mysql-test/include/varchar.inc b/mysql-test/include/varchar.inc
index 646cc4cbdd4a6ae14fe3647f67c8f627f04d5edb..060afbfb066a36a0bead596092d1b8637ab74134 100644
--- a/mysql-test/include/varchar.inc
+++ b/mysql-test/include/varchar.inc
@@ -66,18 +66,26 @@ select count(*) from t1 where v like 'a%';
 select count(*) from t1 where c like 'a%';
 select count(*) from t1 where t like 'a%';
 select count(*) from t1 where v like 'a %';
+# Test results differ for BDB, see comments in bdb.test
+# and they are also different from MySAM test results.
+--replace_column 9 #
 explain select count(*) from t1 where v='a  ';
+--replace_column 9 #
 explain select count(*) from t1 where c='a  ';
+--replace_column 9 #
 explain select count(*) from t1 where t='a  ';
+--replace_column 9 #
 explain select count(*) from t1 where v like 'a%';
+--replace_column 9 #
 explain select count(*) from t1 where v between 'a' and 'a ';
+--replace_column 9 #
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
 --error 1062
 alter table t1 add unique(v);
 alter table t1 add key(v);
 select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
---replace_column 6 #
+--replace_column 6 # 9 #
 explain select * from t1 where v='a';
 
 # GROUP BY
@@ -106,10 +114,15 @@ select count(*) from t1 where v between 'a' and 'a ';
 select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 select count(*) from t1 where v like 'a%';
 select count(*) from t1 where v like 'a %';
+--replace_column 9 #
 explain select count(*) from t1 where v='a  ';
+--replace_column 9 #
 explain select count(*) from t1 where v like 'a%';
+--replace_column 9 #
 explain select count(*) from t1 where v between 'a' and 'a ';
+--replace_column 9 #
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+--replace_column 9 #
 explain select * from t1 where v='a';
 
 # GROUP BY
@@ -130,10 +143,15 @@ select count(*) from t1 where v between 'a' and 'a ';
 select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 select count(*) from t1 where v like 'a%';
 select count(*) from t1 where v like 'a %';
+--replace_column 9 #
 explain select count(*) from t1 where v='a  ';
+--replace_column 9 #
 explain select count(*) from t1 where v like 'a%';
+--replace_column 9 #
 explain select count(*) from t1 where v between 'a' and 'a ';
+--replace_column 9 #
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
+--replace_column 9 #
 explain select * from t1 where v='a';
 
 # GROUP BY
diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result
index df904b04e2275b6e7608a56c6a5eebb1316455bb..e3674486a21fa5ba2d006da37eea52d75f8f2d28 100644
--- a/mysql-test/r/bdb.result
+++ b/mysql-test/r/bdb.result
@@ -140,13 +140,13 @@ id	parent_id	level
 1015	102	2
 explain select level from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	6	Using index
+1	SIMPLE	t1	ref	level	level	1	const	X	Using index
 explain select level,id from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	6	Using index
+1	SIMPLE	t1	ref	level	level	1	const	X	Using index
 explain select level,id,parent_id from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	6	
+1	SIMPLE	t1	ref	level	level	1	const	X	
 select level,id from t1 where level=1;
 level	id
 1	1002
@@ -625,7 +625,7 @@ id	parent_id	level
 1016	102	2
 explain select level from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	6	Using index
+1	SIMPLE	t1	ref	level	level	1	const	X	Using index
 select level,id from t1 where level=1;
 level	id
 1	1004
@@ -1412,22 +1412,22 @@ count(*)
 9
 explain select count(*) from t1 where v='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	13	const	10	Using where
+1	SIMPLE	t1	ref	v	v	13	const	#	Using where
 explain select count(*) from t1 where c='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	c	c	11	const	10	Using where
+1	SIMPLE	t1	ref	c	c	11	const	#	Using where
 explain select count(*) from t1 where t='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	t	t	13	NULL	10	Using where
+1	SIMPLE	t1	range	t	t	13	NULL	#	Using where
 explain select count(*) from t1 where v like 'a%';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	13	NULL	11	Using where
+1	SIMPLE	t1	range	v	v	13	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	13	NULL	10	Using where
+1	SIMPLE	t1	range	v	v	13	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	13	NULL	10	Using where
+1	SIMPLE	t1	range	v	v	13	NULL	#	Using where
 alter table t1 add unique(v);
 ERROR 23000: Duplicate entry '{ ' for key 1
 alter table t1 add key(v);
@@ -1445,7 +1445,7 @@ qq
 *a         *a*a         *
 explain select * from t1 where v='a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v,v_2	#	13	const	10	Using where
+1	SIMPLE	t1	ref	v,v_2	#	13	const	#	Using where
 select v,count(*) from t1 group by v limit 10;
 v	count(*)
 a	1
@@ -1611,19 +1611,19 @@ count(*)
 9
 explain select count(*) from t1 where v='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	258	const	10	Using where
+1	SIMPLE	t1	ref	v	v	258	const	#	Using where
 explain select count(*) from t1 where v like 'a%';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	258	NULL	11	Using where
+1	SIMPLE	t1	range	v	v	258	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	258	NULL	10	Using where
+1	SIMPLE	t1	range	v	v	258	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	258	NULL	10	Using where
+1	SIMPLE	t1	range	v	v	258	NULL	#	Using where
 explain select * from t1 where v='a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	258	const	10	Using where
+1	SIMPLE	t1	ref	v	v	258	const	#	Using where
 select v,count(*) from t1 group by v limit 10;
 v	count(*)
 a	1
@@ -1691,19 +1691,19 @@ count(*)
 9
 explain select count(*) from t1 where v='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	10	Using where
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
 explain select count(*) from t1 where v like 'a%';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	33	NULL	11	Using where
+1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	33	NULL	10	Using where
+1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	33	NULL	10	Using where
+1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
 explain select * from t1 where v='a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	10	Using where
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
 select v,count(*) from t1 group by v limit 10;
 v	count(*)
 a	1
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index 2bb9cb9fa07bf00e12d8fb212bffe3c82410f693..1e1d6f96eb711f19206e9823754c4a27ceab3a3f 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -190,7 +190,7 @@ insert into t3 select * from t4;
 explain select distinct t1.a from t1,t3 where t1.a=t3.a;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index	PRIMARY	PRIMARY	4	NULL	4	Using index; Using temporary
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	10	Using where; Using index; Distinct
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	11	Using where; Using index; Distinct
 select distinct t1.a from t1,t3 where t1.a=t3.a;
 a
 1
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index bc79b6e4a68245e82a9cb59f0301a31c16226b95..1ac2f9631d7fd4f076a2baad102aa89eb4bd6264 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -683,22 +683,22 @@ count(*)
 9
 explain select count(*) from t1 where v='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	13	const	9	Using where; Using index
+1	SIMPLE	t1	ref	v	v	13	const	#	Using where; Using index
 explain select count(*) from t1 where c='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	c	c	11	const	9	Using where; Using index
+1	SIMPLE	t1	ref	c	c	11	const	#	Using where; Using index
 explain select count(*) from t1 where t='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	t	t	13	NULL	9	Using where
+1	SIMPLE	t1	range	t	t	13	NULL	#	Using where
 explain select count(*) from t1 where v like 'a%';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	13	NULL	10	Using where; Using index
+1	SIMPLE	t1	range	v	v	13	NULL	#	Using where; Using index
 explain select count(*) from t1 where v between 'a' and 'a ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	13	NULL	9	Using where; Using index
+1	SIMPLE	t1	range	v	v	13	NULL	#	Using where; Using index
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	13	NULL	9	Using where; Using index
+1	SIMPLE	t1	range	v	v	13	NULL	#	Using where; Using index
 alter table t1 add unique(v);
 ERROR 23000: Duplicate entry '{ ' for key 1
 alter table t1 add key(v);
@@ -716,7 +716,7 @@ qq
 *a         *a*a         *
 explain select * from t1 where v='a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v,v_2	#	13	const	7	Using where
+1	SIMPLE	t1	ref	v,v_2	#	13	const	#	Using where
 select v,count(*) from t1 group by v limit 10;
 v	count(*)
 a	1
@@ -880,19 +880,19 @@ count(*)
 9
 explain select count(*) from t1 where v='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	303	const	7	Using where; Using index
+1	SIMPLE	t1	ref	v	v	303	const	#	Using where; Using index
 explain select count(*) from t1 where v like 'a%';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	303	NULL	8	Using where; Using index
+1	SIMPLE	t1	range	v	v	303	NULL	#	Using where; Using index
 explain select count(*) from t1 where v between 'a' and 'a ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	303	NULL	7	Using where; Using index
+1	SIMPLE	t1	range	v	v	303	NULL	#	Using where; Using index
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	303	NULL	7	Using where; Using index
+1	SIMPLE	t1	range	v	v	303	NULL	#	Using where; Using index
 explain select * from t1 where v='a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	303	const	7	Using where
+1	SIMPLE	t1	ref	v	v	303	const	#	Using where
 select v,count(*) from t1 group by v limit 10;
 v	count(*)
 a	1
@@ -960,19 +960,19 @@ count(*)
 9
 explain select count(*) from t1 where v='a  ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	7	Using where
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
 explain select count(*) from t1 where v like 'a%';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	33	NULL	8	Using where
+1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	33	NULL	7	Using where
+1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
 explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	v	v	33	NULL	7	Using where
+1	SIMPLE	t1	range	v	v	33	NULL	#	Using where
 explain select * from t1 where v='a';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	v	v	33	const	7	Using where
+1	SIMPLE	t1	ref	v	v	33	const	#	Using where
 select v,count(*) from t1 group by v limit 10;
 v	count(*)
 a	1
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index e8929b2afdd94938335eb42390e875e349cf248a..a425f054d5e051034e17702a97e0bb316c14e4ad 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1353,7 +1353,7 @@ explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t2	index	NULL	a	5	NULL	4	Using where; Using index
 2	DEPENDENT SUBQUERY	t3	index	a	a	5	NULL	3	Using index
-2	DEPENDENT SUBQUERY	t1	ref	a	a	10	func,test.t3.a	1000	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ref	a	a	10	func,test.t3.a	1167	Using where; Using index
 Warnings:
 Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` join `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`a`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
 insert into t1 values (3,31);
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index b319cf79ec2c339a927b0bd1c9cbe4890e708463..af38be98151001d49284e3c60453343fcf5978d1 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -42,8 +42,13 @@ update ignore t1 set id=id+1; # This will change all rows
 select * from t1;
 update ignore t1 set id=1023 where id=1010;
 select * from t1 where parent_id=102 order by parent_id,id;
+# Here and below the differences in result are caused by difference in 
+# floating point calculations performed in BDB handler. 
+--replace_result 5 X 6 X
 explain select level from t1 where level=1;
+--replace_result 5 X 6 X
 explain select level,id from t1 where level=1;
+--replace_result 5 X 6 X
 explain select level,id,parent_id from t1 where level=1;
 select level,id from t1 where level=1;
 select level,id,parent_id from t1 where level=1;
@@ -349,6 +354,7 @@ update ignore t1 set id=id+1; # This will change all rows
 select * from t1;
 update ignore t1 set id=1023 where id=1010;
 select * from t1 where parent_id=102;
+--replace_result 5 X 6 X
 explain select level from t1 where level=1;
 select level,id from t1 where level=1;
 select level,id,parent_id from t1 where level=1;