[Commits] Rev 2941: Merge in file:///home/igor/maria/maria-5.1/

igor at askmonty.org igor at askmonty.org
Mon Sep 20 22:39:46 EEST 2010


At file:///home/igor/maria/maria-5.1/

------------------------------------------------------------
revno: 2941 [merge]
revision-id: igor at askmonty.org-20100920193941-kirxqacsw500ihc1
parent: sergii at pisem.net-20100920131759-d8uvabe633jmcudf
parent: igor at askmonty.org-20100920014639-e8ntlwg6lz2fn7k3
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.1
timestamp: Mon 2010-09-20 12:39:41 -0700
message:
  Merge
modified:
  mysql-test/r/index_merge_innodb.result sp1f-index_merge_innodb.r-20060816114352-umgqkfavfljswrg7qhdkcoptdwi5gipo
  mysql-test/t/index_merge_innodb.test sp1f-index_merge_innodb.t-20060816114353-jlqkbce4q5pp3yqqhbhrox4ovfz3yce4
  sql/records.cc                 sp1f-records.cc-19700101030959-xg6elqzdqhvrmobazxrjajmiyqxf7lx7
-------------- next part --------------
=== modified file 'mysql-test/r/index_merge_innodb.result'
--- a/mysql-test/r/index_merge_innodb.result	2009-11-14 01:15:03 +0000
+++ b/mysql-test/r/index_merge_innodb.result	2010-09-20 01:46:39 +0000
@@ -581,3 +581,58 @@
 `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
 `TESTID`='' AND `UCCHECK`='';
 drop table t1;
+# 
+# BUG#56862/640419: Wrong result with sort_union index merge when one
+#                   of the merged index scans is the primary key scan
+# 
+CREATE TABLE t1 (
+pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
+a int,
+b int,
+INDEX idx(a))
+ENGINE=INNODB;
+INSERT INTO t1(a,b) VALUES
+(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
+(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
+(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
+(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
+INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
+INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
+INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1 VALUES (1000000, 0, 0);
+SET SESSION sort_buffer_size = 1024*36;
+EXPLAIN
+SELECT COUNT(*) FROM 
+(SELECT * FROM t1 
+WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
+2	DERIVED	t1	index_merge	PRIMARY,idx	idx,PRIMARY	5,4	NULL	11419	Using sort_union(idx,PRIMARY); Using where
+SELECT COUNT(*) FROM 
+(SELECT * FROM t1 
+WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+COUNT(*)
+6145
+EXPLAIN
+SELECT COUNT(*) FROM 
+(SELECT * FROM t1 IGNORE INDEX(idx)
+WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	#	Select tables optimized away
+2	DERIVED	t1	ALL	PRIMARY	NULL	NULL	NULL	#	Using where
+SELECT COUNT(*) FROM 
+(SELECT * FROM t1 IGNORE INDEX(idx)
+WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+COUNT(*)
+6145
+DROP TABLE t1;

=== modified file 'mysql-test/t/index_merge_innodb.test'
--- a/mysql-test/t/index_merge_innodb.test	2009-06-05 15:35:22 +0000
+++ b/mysql-test/t/index_merge_innodb.test	2010-09-20 01:46:39 +0000
@@ -29,3 +29,56 @@
 --source include/index_merge2.inc
 --source include/index_merge_2sweeps.inc
 --source include/index_merge_ror_cpk.inc
+
+--echo # 
+--echo # BUG#56862/640419: Wrong result with sort_union index merge when one
+--echo #                   of the merged index scans is the primary key scan
+--echo # 
+
+CREATE TABLE t1 (
+  pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
+  a int,
+  b int,
+  INDEX idx(a))
+ENGINE=INNODB;
+
+INSERT INTO t1(a,b) VALUES
+  (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
+  (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
+  (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
+  (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
+INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
+INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
+INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1(a,b) SELECT a,b FROM t1;
+INSERT INTO t1 VALUES (1000000, 0, 0);
+
+SET SESSION sort_buffer_size = 1024*36;
+
+EXPLAIN
+SELECT COUNT(*) FROM 
+  (SELECT * FROM t1 
+     WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+SELECT COUNT(*) FROM 
+  (SELECT * FROM t1 
+     WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+
+--replace_column 9 #
+EXPLAIN
+SELECT COUNT(*) FROM 
+  (SELECT * FROM t1 IGNORE INDEX(idx)
+     WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+SELECT COUNT(*) FROM 
+  (SELECT * FROM t1 IGNORE INDEX(idx)
+     WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
+
+DROP TABLE t1;

=== modified file 'sql/records.cc'
--- a/sql/records.cc	2010-04-28 12:52:24 +0000
+++ b/sql/records.cc	2010-09-20 01:46:39 +0000
@@ -196,7 +196,8 @@
     tempfile= &select->file;
   else
     tempfile= table->sort.io_cache;
-  if (tempfile && my_b_inited(tempfile)) // Test if ref-records was used
+  if (tempfile && my_b_inited(tempfile) &&
+      !(select && select->quick)) 
   {
     DBUG_PRINT("info",("using rr_from_tempfile"));
     info->read_record= (table->sort.addon_field ?



More information about the commits mailing list