[Commits] Rev 2853: Merge in file:///home/igor/maria/maria-5.3-mwl128/

Igor Babaev igor at askmonty.org
Fri Nov 12 02:59:09 EET 2010


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

------------------------------------------------------------
revno: 2853 [merge]
revision-id: igor at askmonty.org-20101112005908-18gtyr4if2dyqo8c
parent: igor at askmonty.org-20101112003855-kfco6ovil7vx7tlk
parent: igor at askmonty.org-20101112004152-dt4vkj1w6gxafo4d
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.3-mwl128
timestamp: Thu 2010-11-11 16:59:08 -0800
message:
  Merge
modified:
  mysql-test/r/join_cache.result join_cache.result-20091221012827-jfu65h0x5bmixhh3-1
  mysql-test/t/join_cache.test   join_cache.test-20091221012705-n3szmbc9blgmmu84-1
  sql/field_conv.cc              sp1f-field_conv.cc-19700101030959-uuzkb66ot4kog3hexkbr2owd2zrkiazt
-------------- next part --------------
=== modified file 'mysql-test/r/join_cache.result'
--- a/mysql-test/r/join_cache.result	2010-11-11 23:35:11 +0000
+++ b/mysql-test/r/join_cache.result	2010-11-12 00:59:08 +0000
@@ -5675,7 +5675,6 @@
 f	5
 SET SESSION join_cache_level = DEFAULT;
 DROP TABLE t1,t2;
-#
 # Bug #672497: 3 way join with tiny incremental join buffer with
 #              and a ref access from the first table 
 #
@@ -5730,4 +5729,44 @@
 SET SESSION join_cache_level = DEFAULT;
 SET SESSION join_buffer_size = DEFAULT;
 DROP TABLE t1,t2,t3;
+#
+# Bug #672551: hash join over a long varchar field
+#
+CREATE TABLE t1 (
+pk int PRIMARY KEY,
+a varchar(512) CHARSET latin1 COLLATE latin1_bin DEFAULT NULL,
+INDEX idx (a)
+);
+INSERT INTO t1 VALUES (2, 'aa'), (5, 'ccccccc'), (3, 'bb');
+CREATE TABLE t2(
+pk int PRIMARY KEY,
+a varchar(512) CHARSET latin1 COLLATE latin1_bin DEFAULT NULL,
+INDEX idx (a)
+);
+INSERT INTO t2 VALUES 
+(10, 'a'), (20, 'c'), (30, 'aa'), (4, 'bb'),
+(11, 'a'), (21, 'c'), (31, 'aa'), (41, 'cc'),
+(12, 'a'), (22, 'c'), (32, 'bb'), (42, 'aa');
+SELECT * FROM t1,t2 WHERE t2.a=t1.a;
+pk	a	pk	a
+2	aa	30	aa
+2	aa	31	aa
+2	aa	42	aa
+3	bb	4	bb
+3	bb	32	bb
+SET SESSION join_cache_level = 4;
+EXPLAIN
+SELECT * FROM t1,t2 WHERE t2.a=t1.a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	idx	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t2	ref	idx	idx	515	test.t1.a	2	Using join buffer (flat, BNLH join)
+SELECT * FROM t1,t2 WHERE t2.a=t1.a;
+pk	a	pk	a
+2	aa	30	aa
+3	bb	4	bb
+2	aa	31	aa
+3	bb	32	bb
+2	aa	42	aa
+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-11-11 23:35:11 +0000
+++ b/mysql-test/t/join_cache.test	2010-11-12 00:59:08 +0000
@@ -2358,7 +2358,7 @@
 
 DROP TABLE t1,t2;
 
---echo #
+#--echo #
 --echo # Bug #672497: 3 way join with tiny incremental join buffer with
 --echo #              and a ref access from the first table 
 --echo #
@@ -2416,5 +2416,37 @@
 
 DROP TABLE t1,t2,t3;
 
+--echo #
+--echo # Bug #672551: hash join over a long varchar field
+--echo #
+
+CREATE TABLE t1 (
+  pk int PRIMARY KEY,
+  a varchar(512) CHARSET latin1 COLLATE latin1_bin DEFAULT NULL,
+  INDEX idx (a)
+);
+INSERT INTO t1 VALUES (2, 'aa'), (5, 'ccccccc'), (3, 'bb');
+
+CREATE TABLE t2(
+  pk int PRIMARY KEY,
+  a varchar(512) CHARSET latin1 COLLATE latin1_bin DEFAULT NULL,
+  INDEX idx (a)
+);
+INSERT INTO t2 VALUES 
+  (10, 'a'), (20, 'c'), (30, 'aa'), (4, 'bb'),
+  (11, 'a'), (21, 'c'), (31, 'aa'), (41, 'cc'),
+  (12, 'a'), (22, 'c'), (32, 'bb'), (42, 'aa');
+
+SELECT * FROM t1,t2 WHERE t2.a=t1.a;
+
+SET SESSION join_cache_level = 4;
+EXPLAIN
+SELECT * FROM t1,t2 WHERE t2.a=t1.a;
+SELECT * FROM t1,t2 WHERE t2.a=t1.a;
+
+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/field_conv.cc'
--- a/sql/field_conv.cc	2010-04-28 12:52:24 +0000
+++ b/sql/field_conv.cc	2010-11-12 00:41:52 +0000
@@ -449,7 +449,8 @@
   if (length > copy->to_length- 1)
   {
     length=copy->to_length - 1;
-    if (copy->from_field->table->in_use->count_cuted_fields)
+    if (copy->from_field->table->in_use->count_cuted_fields &&
+        copy->to_field)
       copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
                                   WARN_DATA_TRUNCATED, 1);
   }
@@ -485,7 +486,8 @@
   if (length > copy->to_length- HA_KEY_BLOB_LENGTH)
   {
     length=copy->to_length-HA_KEY_BLOB_LENGTH;
-    if (copy->from_field->table->in_use->count_cuted_fields)
+    if (copy->from_field->table->in_use->count_cuted_fields &&
+        copy->to_field)
       copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
                                   WARN_DATA_TRUNCATED, 1);
   }
@@ -549,9 +551,16 @@
       do_copy=	  do_field_to_null_str;
   }
   else
-  {
+  { 
     to_null_ptr=  0;				// For easy debugging
-    do_copy=	  do_field_eq;
+    /* Setup optimal copying for varchar */
+    if (from->real_type() == MYSQL_TYPE_VARCHAR)
+    {
+      do_copy= (((Field_varstring*) from)->length_bytes == 1 ?
+                 do_varstring1 : do_varstring2);
+    }  
+    else
+      do_copy= do_field_eq;
   }
 }
 
@@ -710,6 +719,10 @@
                                                     do_varstring1_mb) :
                   (from->charset()->mbmaxlen == 1 ? do_varstring2 :
                                                     do_varstring2_mb));
+        else 
+          return  (((Field_varstring*) from)->length_bytes == 1 ?
+                    do_varstring1 : do_varstring2);
+
       }
       else if (to_length < from_length)
 	return (from->charset()->mbmaxlen == 1 ?



More information about the commits mailing list