[Commits] Rev 2875: Fixed LP bug #697557. in file:///home/igor/maria/maria-5.3-bug697557/

Igor Babaev igor at askmonty.org
Thu Jan 6 01:03:31 EET 2011


At file:///home/igor/maria/maria-5.3-bug697557/

------------------------------------------------------------
revno: 2875
revision-id: igor at askmonty.org-20110105230330-2nzlm8641wcrwzio
parent: igor at askmonty.org-20101230021403-ly4ku1yq675l5d6b
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.3-bug697557
timestamp: Wed 2011-01-05 15:03:30 -0800
message:
  Fixed LP bug #697557.
  When stored in a key buffer any varchar field has a length prefix
  that always takes 2 bytes.
-------------- next part --------------
=== modified file 'mysql-test/r/join_cache.result'
--- a/mysql-test/r/join_cache.result	2010-12-30 02:14:03 +0000
+++ b/mysql-test/r/join_cache.result	2011-01-05 23:03:30 +0000
@@ -6200,4 +6200,24 @@
 2	NULL	42
 SET SESSION join_cache_level = DEFAULT;
 DROP TABLE t1,t2;
+#
+# Bug #697557: hash join on a varchar field 
+#
+CREATE TABLE t1 ( f1 varchar(10) , f2 int(11) , KEY (f1));
+INSERT INTO t1 VALUES ('r',1), ('m',2);
+CREATE TABLE t2 ( f1 varchar(10) , f2 int(11) , KEY (f1));
+INSERT INTO t2 VALUES
+('hgtofubn',1), ('GDOXZ',91), ('n',2), ('fggxgalh',88),
+('hgtofu',1), ('GDO',101), ('n',3), ('fggxga',55),
+('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77);
+SET SESSION join_cache_level=3;
+EXPLAIN 
+SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	f1	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ref	f1	f1	13	test.t1.f1	2	Using join buffer (flat, BNLH join)
+SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1;
+f1	f2	f1	f2
+SET SESSION join_cache_level = DEFAULT;
+DROP TABLE t1,t2;
 set @@optimizer_switch=@save_optimizer_switch;

=== modified file 'mysql-test/t/join_cache.test'
--- a/mysql-test/t/join_cache.test	2010-12-30 02:14:03 +0000
+++ b/mysql-test/t/join_cache.test	2011-01-05 23:03:30 +0000
@@ -2823,6 +2823,28 @@
 
 DROP TABLE t1,t2;
   
-
+--echo #
+--echo # Bug #697557: hash join on a varchar field 
+--echo #
+
+CREATE TABLE t1 ( f1 varchar(10) , f2 int(11) , KEY (f1));
+INSERT INTO t1 VALUES ('r',1), ('m',2);
+
+CREATE TABLE t2 ( f1 varchar(10) , f2 int(11) , KEY (f1));
+INSERT INTO t2 VALUES
+  ('hgtofubn',1), ('GDOXZ',91), ('n',2), ('fggxgalh',88),
+  ('hgtofu',1), ('GDO',101), ('n',3), ('fggxga',55),
+  ('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77);
+
+SET SESSION join_cache_level=3;
+
+EXPLAIN 
+SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1;
+SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1;
+
+SET SESSION join_cache_level = DEFAULT;
+
+DROP TABLE t1,t2;
+  
 # this must be the last command in the file
 set @@optimizer_switch=@save_optimizer_switch;

=== modified file 'sql/key.cc'
--- a/sql/key.cc	2010-12-27 00:31:03 +0000
+++ b/sql/key.cc	2011-01-05 23:03:30 +0000
@@ -689,20 +689,12 @@
       pack_length= 0;
       break;
     case HA_KEYTYPE_VARTEXT1:
+    case HA_KEYTYPE_VARTEXT2:
       cs= key_part->field->charset();
-      length= (uint)(pos[0]);
-      pack_length= 1;
+      length= uint2korr(pos);
+      pack_length= 2;
       break;
     case HA_KEYTYPE_VARBINARY1:
-      cs= &my_charset_bin;
-      length= (uint)(pos[0]);
-      pack_length= 1;
-      break;
-    case HA_KEYTYPE_VARTEXT2:
-      cs= key_part->field->charset();
-      length= uint2korr(pos);
-      pack_length= 2;
-      break;
     case HA_KEYTYPE_VARBINARY2:
       cs= &my_charset_bin;
       length= uint2korr(pos);
@@ -806,23 +798,13 @@
       pack_length= 0;
       break;
     case HA_KEYTYPE_VARTEXT1:
+    case HA_KEYTYPE_VARTEXT2:
       cs= key_part->field->charset();
-      length1= (uint)(pos1[0]);
-      length2= (uint)(pos2[0]);
-      pack_length= 1;
+      length1= uint2korr(pos1);
+      length2= uint2korr(pos2);
+      pack_length= 2;
       break;
     case HA_KEYTYPE_VARBINARY1:
-      cs= &my_charset_bin;
-      length1= (uint)(pos1[0]);
-      length2= (uint)(pos2[0]);
-      pack_length= 1;
-      break;
-    case HA_KEYTYPE_VARTEXT2:
-      cs= key_part->field->charset();
-      length1= uint2korr(pos1);
-      length2= uint2korr(pos2);
-      pack_length= 2;
-      break;
     case HA_KEYTYPE_VARBINARY2:
       cs= &my_charset_bin;
       length1= uint2korr(pos1);



More information about the commits mailing list