List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:August 26 2011 11:04am
Subject:bzr push into mysql-trunk branch (tor.didriksen:3403 to 3404) Bug#12694872
View as plain text  
 3404 Tor Didriksen	2011-08-25
      Bug#12694872 - VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET
      
      The leak was caused by failure to clean up after QUICK_INDEX_MERGE_SELECT/Unique.
     @ dbug/dbug.c
        Add line number to RETURN points in DBUG trace.
     @ mysql-test/include/range.inc
        New test case.
     @ mysql-test/r/range_icp.result
        New test case.
     @ mysql-test/r/range_icp_mrr.result
        New test case.
     @ mysql-test/r/range_mrr.result
        New test case.
     @ mysql-test/r/range_mrr_cost.result
        New test case.
     @ mysql-test/r/range_none.result
        New test case.
     @ sql/filesort.cc
        DBUG_ASSERT that we are not about to leak record_pointers.
        Add trace of filesort_free_buffers.
     @ sql/opt_range.cc
        Fix DBUG trace.
     @ sql/sql_select.cc
        Call free() routines for *all* non-const tables, rather than only the first one.
     @ sql/uniques.cc
        Some DBUG_ASSERTS that we are not going to leak memory.

    modified:
      dbug/dbug.c
      mysql-test/include/range.inc
      mysql-test/r/range_icp.result
      mysql-test/r/range_icp_mrr.result
      mysql-test/r/range_mrr.result
      mysql-test/r/range_mrr_cost.result
      mysql-test/r/range_none.result
      sql/filesort.cc
      sql/opt_range.cc
      sql/sql_select.cc
      sql/uniques.cc
 3403 Rohit Kalhans	2011-08-26
      BUG#11755836: Rpl_spec_variables fails sporadically in PB2 hpux.
      Background:
      The test Rpl_spec_variables fails sporadically in PB2 hpux.  
      Problem:
      Same as background of the BUG. Moreover this is a sporadical failure.
      Fix:
      Since there were no failures recorded by pb2 in past 6 months for 
      this test,We are classifying this bug as "cant repeat".
      This test will be put up as an experimental test so that we can record the
      failures in this test (if any) in the future.
     @ mysql-test/collections/default.experimental
        Added test rpl.rpl_spec_variables to this file to make it experimental, so that we can record the failures in the future.
     @ mysql-test/suite/rpl/t/disabled.def
        Enabled rpl.rpl_spec_variables  test and made it experimental to record the failures, (if any) in future.

    modified:
      mysql-test/collections/default.experimental
      mysql-test/suite/rpl/t/disabled.def
=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2011-07-19 15:11:15 +0000
+++ b/dbug/dbug.c	2011-08-25 10:54:34 +0000
@@ -1179,7 +1179,7 @@ void _db_return_(uint _line_, struct _db
         pthread_mutex_lock(&THR_LOCK_dbug);
       DoPrefix(cs, _line_);
       Indent(cs, cs->level);
-      (void) fprintf(cs->stack->out_file, "<%s\n", cs->func);
+      (void) fprintf(cs->stack->out_file, "<%s %u\n", cs->func, _line_);
       DbugFlush(cs);
     }
   }

=== modified file 'mysql-test/include/range.inc'
--- a/mysql-test/include/range.inc	2011-08-05 14:30:29 +0000
+++ b/mysql-test/include/range.inc	2011-08-25 10:54:34 +0000
@@ -1534,3 +1534,82 @@ eval EXPLAIN $query;
 eval $query;
 
 DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug#12694872 - 
+--echo # VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET
+--echo #
+
+CREATE TABLE t1 (
+  pk INTEGER AUTO_INCREMENT,
+  col_int_nokey INTEGER NOT NULL,
+  col_int_key INTEGER NOT NULL,
+
+  col_date_key DATE NOT NULL,
+
+  col_varchar_key VARCHAR(1) NOT NULL,
+  col_varchar_nokey VARCHAR(1) NOT NULL,
+
+  PRIMARY KEY (pk),
+  KEY (col_int_key),
+  KEY (col_date_key),
+  KEY (col_varchar_key, col_int_key)
+);
+
+INSERT INTO t1 (
+   col_int_key,
+   col_int_nokey,
+   col_date_key,
+   col_varchar_key,
+   col_varchar_nokey
+) VALUES 
+(0, 4, '2011-08-25', 'j', 'j'),
+(8, 6, '2004-09-18', 'v', 'v'),
+(1, 3, '2009-12-01', 'c', 'c'),
+(8, 5, '2004-12-17', 'm', 'm'),
+(9, 3, '2000-03-14', 'd', 'd'),
+(6, 2, '2006-05-25', 'y', 'y'),
+(1, 9, '2008-01-23', 't', 't'),
+(6, 3, '2007-06-18', 'd', 'd'),
+(2, 8, '2002-10-13', 's', 's'),
+(4, 1, '1900-01-01', 'r', 'r'),
+(8, 8, '1959-04-25', 'm', 'm'),
+(4, 8, '2006-03-09', 'b', 'b'),
+(4, 5, '2001-06-05', 'x', 'x'),
+(7, 7, '2006-05-28', 'g', 'g'),
+(4, 5, '2001-04-19', 'p', 'p'),
+(1, 1, '1900-01-01', 'q', 'q'),
+(9, 6, '2004-08-20', 'w', 'w'),
+(4, 2, '2004-10-10', 'd', 'd'),
+(8, 9, '2000-04-02', 'e', 'e')
+;
+
+let $query=
+SELECT table2.col_date_key AS field1,
+       CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+       ON (( table2.pk <> table1.pk ) AND
+           ( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+        table1.pk < ( 226 + 102 ) OR
+        ( table1.col_int_key > 226 AND
+          table1.col_int_key < ( 226 + 36 ) OR
+          ( table1.col_varchar_key <= 'h' OR
+            table1.col_int_key > 226 AND
+            table1.col_int_key < ( 226 + 227 ) )
+        ) 
+      )
+;
+
+ALTER TABLE t1 DISABLE KEYS;
+sorted_result;
+eval $query;
+ALTER TABLE t1 ENABLE KEYS;
+
+eval CREATE TABLE t2 $query;
+
+sorted_result;
+eval SELECT * FROM t2
+     WHERE (field1, field2) IN ($query);
+
+DROP TABLE t1, t2;

=== modified file 'mysql-test/r/range_icp.result'
--- a/mysql-test/r/range_icp.result	2011-08-08 14:16:20 +0000
+++ b/mysql-test/r/range_icp.result	2011-08-25 10:54:34 +0000
@@ -1909,4 +1909,294 @@ ON t2.col_int_key = t1.col_int WHERE t2.
 col_int	pk	col_int_key	col_varchar	pk
 1	6	1	GOOD	1
 DROP TABLE t1,t2;
+#
+# Bug#12694872 - 
+# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_int_key INTEGER NOT NULL,
+col_date_key DATE NOT NULL,
+col_varchar_key VARCHAR(1) NOT NULL,
+col_varchar_nokey VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_date_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1 (
+col_int_key,
+col_int_nokey,
+col_date_key,
+col_varchar_key,
+col_varchar_nokey
+) VALUES 
+(0, 4, '2011-08-25', 'j', 'j'),
+(8, 6, '2004-09-18', 'v', 'v'),
+(1, 3, '2009-12-01', 'c', 'c'),
+(8, 5, '2004-12-17', 'm', 'm'),
+(9, 3, '2000-03-14', 'd', 'd'),
+(6, 2, '2006-05-25', 'y', 'y'),
+(1, 9, '2008-01-23', 't', 't'),
+(6, 3, '2007-06-18', 'd', 'd'),
+(2, 8, '2002-10-13', 's', 's'),
+(4, 1, '1900-01-01', 'r', 'r'),
+(8, 8, '1959-04-25', 'm', 'm'),
+(4, 8, '2006-03-09', 'b', 'b'),
+(4, 5, '2001-06-05', 'x', 'x'),
+(7, 7, '2006-05-28', 'g', 'g'),
+(4, 5, '2001-04-19', 'p', 'p'),
+(1, 1, '1900-01-01', 'q', 'q'),
+(9, 6, '2004-08-20', 'w', 'w'),
+(4, 2, '2004-10-10', 'd', 'd'),
+(8, 9, '2000-04-02', 'e', 'e')
+;
+ALTER TABLE t1 DISABLE KEYS;
+SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+ALTER TABLE t1 ENABLE KEYS;
+CREATE TABLE t2 SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+SELECT * FROM t2
+WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+);
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_icp_mrr.result'
--- a/mysql-test/r/range_icp_mrr.result	2011-08-08 14:16:20 +0000
+++ b/mysql-test/r/range_icp_mrr.result	2011-08-25 10:54:34 +0000
@@ -1909,4 +1909,294 @@ ON t2.col_int_key = t1.col_int WHERE t2.
 col_int	pk	col_int_key	col_varchar	pk
 1	6	1	GOOD	1
 DROP TABLE t1,t2;
+#
+# Bug#12694872 - 
+# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_int_key INTEGER NOT NULL,
+col_date_key DATE NOT NULL,
+col_varchar_key VARCHAR(1) NOT NULL,
+col_varchar_nokey VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_date_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1 (
+col_int_key,
+col_int_nokey,
+col_date_key,
+col_varchar_key,
+col_varchar_nokey
+) VALUES 
+(0, 4, '2011-08-25', 'j', 'j'),
+(8, 6, '2004-09-18', 'v', 'v'),
+(1, 3, '2009-12-01', 'c', 'c'),
+(8, 5, '2004-12-17', 'm', 'm'),
+(9, 3, '2000-03-14', 'd', 'd'),
+(6, 2, '2006-05-25', 'y', 'y'),
+(1, 9, '2008-01-23', 't', 't'),
+(6, 3, '2007-06-18', 'd', 'd'),
+(2, 8, '2002-10-13', 's', 's'),
+(4, 1, '1900-01-01', 'r', 'r'),
+(8, 8, '1959-04-25', 'm', 'm'),
+(4, 8, '2006-03-09', 'b', 'b'),
+(4, 5, '2001-06-05', 'x', 'x'),
+(7, 7, '2006-05-28', 'g', 'g'),
+(4, 5, '2001-04-19', 'p', 'p'),
+(1, 1, '1900-01-01', 'q', 'q'),
+(9, 6, '2004-08-20', 'w', 'w'),
+(4, 2, '2004-10-10', 'd', 'd'),
+(8, 9, '2000-04-02', 'e', 'e')
+;
+ALTER TABLE t1 DISABLE KEYS;
+SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+ALTER TABLE t1 ENABLE KEYS;
+CREATE TABLE t2 SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+SELECT * FROM t2
+WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+);
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_mrr.result'
--- a/mysql-test/r/range_mrr.result	2011-08-08 14:16:20 +0000
+++ b/mysql-test/r/range_mrr.result	2011-08-25 10:54:34 +0000
@@ -1909,4 +1909,294 @@ ON t2.col_int_key = t1.col_int WHERE t2.
 col_int	pk	col_int_key	col_varchar	pk
 1	6	1	GOOD	1
 DROP TABLE t1,t2;
+#
+# Bug#12694872 - 
+# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_int_key INTEGER NOT NULL,
+col_date_key DATE NOT NULL,
+col_varchar_key VARCHAR(1) NOT NULL,
+col_varchar_nokey VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_date_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1 (
+col_int_key,
+col_int_nokey,
+col_date_key,
+col_varchar_key,
+col_varchar_nokey
+) VALUES 
+(0, 4, '2011-08-25', 'j', 'j'),
+(8, 6, '2004-09-18', 'v', 'v'),
+(1, 3, '2009-12-01', 'c', 'c'),
+(8, 5, '2004-12-17', 'm', 'm'),
+(9, 3, '2000-03-14', 'd', 'd'),
+(6, 2, '2006-05-25', 'y', 'y'),
+(1, 9, '2008-01-23', 't', 't'),
+(6, 3, '2007-06-18', 'd', 'd'),
+(2, 8, '2002-10-13', 's', 's'),
+(4, 1, '1900-01-01', 'r', 'r'),
+(8, 8, '1959-04-25', 'm', 'm'),
+(4, 8, '2006-03-09', 'b', 'b'),
+(4, 5, '2001-06-05', 'x', 'x'),
+(7, 7, '2006-05-28', 'g', 'g'),
+(4, 5, '2001-04-19', 'p', 'p'),
+(1, 1, '1900-01-01', 'q', 'q'),
+(9, 6, '2004-08-20', 'w', 'w'),
+(4, 2, '2004-10-10', 'd', 'd'),
+(8, 9, '2000-04-02', 'e', 'e')
+;
+ALTER TABLE t1 DISABLE KEYS;
+SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+ALTER TABLE t1 ENABLE KEYS;
+CREATE TABLE t2 SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+SELECT * FROM t2
+WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+);
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_mrr_cost.result'
--- a/mysql-test/r/range_mrr_cost.result	2011-08-08 14:16:20 +0000
+++ b/mysql-test/r/range_mrr_cost.result	2011-08-25 10:54:34 +0000
@@ -1909,4 +1909,294 @@ ON t2.col_int_key = t1.col_int WHERE t2.
 col_int	pk	col_int_key	col_varchar	pk
 1	6	1	GOOD	1
 DROP TABLE t1,t2;
+#
+# Bug#12694872 - 
+# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_int_key INTEGER NOT NULL,
+col_date_key DATE NOT NULL,
+col_varchar_key VARCHAR(1) NOT NULL,
+col_varchar_nokey VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_date_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1 (
+col_int_key,
+col_int_nokey,
+col_date_key,
+col_varchar_key,
+col_varchar_nokey
+) VALUES 
+(0, 4, '2011-08-25', 'j', 'j'),
+(8, 6, '2004-09-18', 'v', 'v'),
+(1, 3, '2009-12-01', 'c', 'c'),
+(8, 5, '2004-12-17', 'm', 'm'),
+(9, 3, '2000-03-14', 'd', 'd'),
+(6, 2, '2006-05-25', 'y', 'y'),
+(1, 9, '2008-01-23', 't', 't'),
+(6, 3, '2007-06-18', 'd', 'd'),
+(2, 8, '2002-10-13', 's', 's'),
+(4, 1, '1900-01-01', 'r', 'r'),
+(8, 8, '1959-04-25', 'm', 'm'),
+(4, 8, '2006-03-09', 'b', 'b'),
+(4, 5, '2001-06-05', 'x', 'x'),
+(7, 7, '2006-05-28', 'g', 'g'),
+(4, 5, '2001-04-19', 'p', 'p'),
+(1, 1, '1900-01-01', 'q', 'q'),
+(9, 6, '2004-08-20', 'w', 'w'),
+(4, 2, '2004-10-10', 'd', 'd'),
+(8, 9, '2000-04-02', 'e', 'e')
+;
+ALTER TABLE t1 DISABLE KEYS;
+SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+ALTER TABLE t1 ENABLE KEYS;
+CREATE TABLE t2 SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+SELECT * FROM t2
+WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+);
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/range_none.result'
--- a/mysql-test/r/range_none.result	2011-08-08 14:16:20 +0000
+++ b/mysql-test/r/range_none.result	2011-08-25 10:54:34 +0000
@@ -1908,4 +1908,294 @@ ON t2.col_int_key = t1.col_int WHERE t2.
 col_int	pk	col_int_key	col_varchar	pk
 1	6	1	GOOD	1
 DROP TABLE t1,t2;
+#
+# Bug#12694872 - 
+# VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST IN UNIQUE::GET
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_int_key INTEGER NOT NULL,
+col_date_key DATE NOT NULL,
+col_varchar_key VARCHAR(1) NOT NULL,
+col_varchar_nokey VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_date_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1 (
+col_int_key,
+col_int_nokey,
+col_date_key,
+col_varchar_key,
+col_varchar_nokey
+) VALUES 
+(0, 4, '2011-08-25', 'j', 'j'),
+(8, 6, '2004-09-18', 'v', 'v'),
+(1, 3, '2009-12-01', 'c', 'c'),
+(8, 5, '2004-12-17', 'm', 'm'),
+(9, 3, '2000-03-14', 'd', 'd'),
+(6, 2, '2006-05-25', 'y', 'y'),
+(1, 9, '2008-01-23', 't', 't'),
+(6, 3, '2007-06-18', 'd', 'd'),
+(2, 8, '2002-10-13', 's', 's'),
+(4, 1, '1900-01-01', 'r', 'r'),
+(8, 8, '1959-04-25', 'm', 'm'),
+(4, 8, '2006-03-09', 'b', 'b'),
+(4, 5, '2001-06-05', 'x', 'x'),
+(7, 7, '2006-05-28', 'g', 'g'),
+(4, 5, '2001-04-19', 'p', 'p'),
+(1, 1, '1900-01-01', 'q', 'q'),
+(9, 6, '2004-08-20', 'w', 'w'),
+(4, 2, '2004-10-10', 'd', 'd'),
+(8, 9, '2000-04-02', 'e', 'e')
+;
+ALTER TABLE t1 DISABLE KEYS;
+SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+ALTER TABLE t1 ENABLE KEYS;
+CREATE TABLE t2 SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+;
+SELECT * FROM t2
+WHERE (field1, field2) IN (SELECT table2.col_date_key AS field1,
+CONCAT ( table2.col_varchar_nokey, table1.col_varchar_nokey ) AS field2
+FROM ( t1 AS table1 INNER JOIN t1 AS table2
+ON (( table2.pk <> table1.pk ) AND
+( table2.pk >= table1.col_int_nokey ) ) )
+WHERE ( table1.pk > 226 AND
+table1.pk < ( 226 + 102 ) OR
+( table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 36 ) OR
+( table1.col_varchar_key <= 'h' OR
+table1.col_int_key > 226 AND
+table1.col_int_key < ( 226 + 227 ) )
+) 
+)
+);
+field1	field2
+1900-01-01	qb
+1900-01-01	qc
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qd
+1900-01-01	qe
+1900-01-01	qg
+1900-01-01	rb
+1900-01-01	rc
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	rd
+1900-01-01	re
+1900-01-01	rg
+1959-04-25	mb
+1959-04-25	mc
+1959-04-25	md
+1959-04-25	md
+1959-04-25	md
+1959-04-25	me
+1959-04-25	mg
+2000-03-14	dc
+2000-03-14	dd
+2000-03-14	dd
+2000-04-02	eb
+2000-04-02	ec
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	ed
+2000-04-02	eg
+2001-04-19	pb
+2001-04-19	pc
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pd
+2001-04-19	pe
+2001-04-19	pg
+2001-06-05	xb
+2001-06-05	xc
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xd
+2001-06-05	xe
+2001-06-05	xg
+2002-10-13	sb
+2002-10-13	sc
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	sd
+2002-10-13	se
+2002-10-13	sg
+2004-08-20	wb
+2004-08-20	wc
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	wd
+2004-08-20	we
+2004-08-20	wg
+2004-09-18	vd
+2004-10-10	db
+2004-10-10	dc
+2004-10-10	dd
+2004-10-10	dd
+2004-10-10	de
+2004-10-10	dg
+2004-12-17	mc
+2004-12-17	md
+2004-12-17	md
+2004-12-17	md
+2006-03-09	bc
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	bd
+2006-03-09	be
+2006-03-09	bg
+2006-05-25	yc
+2006-05-25	yd
+2006-05-25	yd
+2006-05-25	yd
+2006-05-28	gb
+2006-05-28	gc
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	gd
+2006-05-28	ge
+2007-06-18	db
+2007-06-18	dc
+2007-06-18	dd
+2007-06-18	dd
+2007-06-18	dg
+2008-01-23	tc
+2008-01-23	td
+2008-01-23	td
+2008-01-23	td
+2008-01-23	tg
+2009-12-01	cd
+2009-12-01	cd
+2009-12-01	cd
+DROP TABLE t1, t2;
 set optimizer_switch=default;

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2011-06-30 15:50:45 +0000
+++ b/sql/filesort.cc	2011-08-25 10:54:34 +0000
@@ -176,6 +176,7 @@ ha_rows filesort(THD *thd, TABLE *table,
   */
   FILESORT_INFO table_sort= table->sort;
   table->sort.io_cache= NULL;
+  DBUG_ASSERT(table_sort.record_pointers == NULL);
   
   outfile= table_sort.io_cache;
   my_b_clear(&tempfile);
@@ -392,6 +393,7 @@ ha_rows filesort(THD *thd, TABLE *table,
 
 void filesort_free_buffers(TABLE *table, bool full)
 {
+  DBUG_ENTER("filesort_free_buffers");
   my_free(table->sort.record_pointers);
   table->sort.record_pointers= NULL;
 
@@ -408,6 +410,7 @@ void filesort_free_buffers(TABLE *table,
   my_free(table->sort.addon_field);
   table->sort.addon_buf= NULL;
   table->sort.addon_field= NULL;
+  DBUG_VOID_RETURN;
 }
 
 /**

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2011-08-16 19:33:03 +0000
+++ b/sql/opt_range.cc	2011-08-25 10:54:34 +0000
@@ -1380,7 +1380,8 @@ int QUICK_INDEX_MERGE_SELECT::init()
 int QUICK_INDEX_MERGE_SELECT::reset()
 {
   DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::reset");
-  DBUG_RETURN(read_keys_and_merge());
+  const int retval= read_keys_and_merge();
+  DBUG_RETURN(retval);
 }
 
 bool

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-08-19 11:39:15 +0000
+++ b/sql/sql_select.cc	2011-08-25 10:54:34 +0000
@@ -12720,14 +12720,14 @@ void JOIN::cleanup(bool full)
   {
     JOIN_TAB *tab,*end;
     /*
-      Only a sorted table may be cached.  This sorted table is always the
-      first non const table in join->all_tables
+      Free resources allocated by filesort() and Unique::get()
     */
     if (tables > const_tables) // Test for not-const tables
-    {
-      free_io_cache(all_tables[const_tables]);
-      filesort_free_buffers(all_tables[const_tables],full);
-    }
+      for (uint ix= const_tables; ix < tables; ++ix)
+      {
+        free_io_cache(all_tables[ix]);
+        filesort_free_buffers(all_tables[ix], full);
+      }
 
     if (full)
     {

=== modified file 'sql/uniques.cc'
--- a/sql/uniques.cc	2011-06-30 15:50:45 +0000
+++ b/sql/uniques.cc	2011-08-25 10:54:34 +0000
@@ -57,7 +57,10 @@ int unique_write_to_ptrs(uchar* key, ele
 
 Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
 	       uint size_arg, ulonglong max_in_memory_size_arg)
-  :max_in_memory_size(max_in_memory_size_arg), size(size_arg), elements(0)
+  :max_in_memory_size(max_in_memory_size_arg),
+   record_pointers(NULL),
+   size(size_arg),
+   elements(0)
 {
   my_b_clear(&file);
   init_tree(&tree, (ulong) (max_in_memory_size / 16), 0, size, comp_func, 0,
@@ -581,6 +584,7 @@ bool Unique::get(TABLE *table)
   if (my_b_tell(&file) == 0)
   {
     /* Whole tree is in memory;  Don't use disk if you don't need to */
+    DBUG_ASSERT(table->sort.record_pointers == NULL);
     if ((record_pointers=table->sort.record_pointers= (uchar*)
 	 my_malloc(size * tree.elements_in_tree, MYF(0))))
     {
@@ -601,6 +605,7 @@ bool Unique::get(TABLE *table)
   bool error=1;
 
       /* Open cached file if it isn't open */
+  DBUG_ASSERT(table->sort.io_cache == NULL);
   outfile=table->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),
                                 MYF(MY_ZEROFILL));
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (tor.didriksen:3403 to 3404) Bug#12694872Tor Didriksen26 Aug