Loading mysql-test/r/delayed.result +174 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ insert delayed into t1 set a = 4; insert delayed into t1 set a = 5, tmsp = 19711006010203; insert delayed into t1 (a, tmsp) values (6, 19711006010203); insert delayed into t1 (a, tmsp) values (7, NULL); FLUSH TABLE t1; insert into t1 set a = 8,tmsp=19711006010203; select * from t1 where tmsp=0; a tmsp Loading @@ -22,6 +23,7 @@ insert delayed into t1 values (null,"c"); insert delayed into t1 values (3,"d"),(null,"e"); insert delayed into t1 values (3,"this will give an","error"); ERROR 21S01: Column count doesn't match value count at row 1 FLUSH TABLE t1; show status like 'not_flushed_delayed_rows'; Variable_name Value Not_flushed_delayed_rows 0 Loading Loading @@ -54,6 +56,7 @@ insert delayed into t1 values(null); insert delayed into t1 values(null); insert delayed into t1 values(null); insert delayed into t1 values(null); FLUSH TABLE t1; select * from t1 order by a; a 1 Loading @@ -69,3 +72,174 @@ a 12 13 DROP TABLE t1; SET @bug20627_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20627_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20627_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20627_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT INTO t1 VALUES (NULL),(NULL),(NULL); SELECT * FROM t1; c1 4 9 14 DROP TABLE t1; CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT DELAYED INTO t1 VALUES (NULL),(NULL),(NULL); FLUSH TABLE t1; SELECT * FROM t1; c1 4 9 14 DROP TABLE t1; SET @@auto_increment_offset= @bug20627_old_auto_increment_offset; SET @@auto_increment_increment= @bug20627_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20627_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20627_old_session_auto_increment_increment; SET @bug20830_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20830_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20830_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20830_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); INSERT INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); SET insert_id= 114; INSERT INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); INSERT INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); SET insert_id= 114; INSERT INTO t1 VALUES(NULL, 91); ERROR 23000: Duplicate entry '114' for key 'PRIMARY' INSERT INTO t1 VALUES (NULL, 92), (NULL, 93); SELECT * FROM t1; c1 c2 14 11 19 12 24 13 29 21 34 22 39 23 69 31 74 32 79 33 84 41 89 42 94 43 114 51 119 52 124 53 129 61 134 62 139 63 49 71 144 72 149 73 154 81 159 82 164 83 169 92 174 93 SELECT COUNT(*) FROM t1; COUNT(*) 26 SELECT SUM(c1) FROM t1; SUM(c1) 2569 DROP TABLE t1; CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT DELAYED INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT DELAYED INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); INSERT DELAYED INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT DELAYED INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT DELAYED INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); INSERT DELAYED INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT DELAYED INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 91); INSERT DELAYED INTO t1 VALUES (NULL, 92), (NULL, 93); FLUSH TABLE t1; SELECT * FROM t1; c1 c2 14 11 19 12 24 13 29 21 34 22 39 23 69 31 74 32 79 33 84 41 89 42 94 43 114 51 119 52 124 53 129 61 134 62 139 63 49 71 144 72 149 73 154 81 159 82 164 83 169 92 174 93 SELECT COUNT(*) FROM t1; COUNT(*) 26 SELECT SUM(c1) FROM t1; SUM(c1) 2569 DROP TABLE t1; SET @@auto_increment_offset= @bug20830_old_auto_increment_offset; SET @@auto_increment_increment= @bug20830_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20830_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20830_old_session_auto_increment_increment; mysql-test/r/merge.result +19 −4 Original line number Diff line number Diff line Loading @@ -178,12 +178,12 @@ t3 CREATE TABLE `t3` ( ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); select * from t4; ERROR HY000: All tables in the MERGE table are not identically defined ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists alter table t4 add column c int; ERROR HY000: All tables in the MERGE table are not identically defined ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists flush tables; select * from t4; ERROR HY000: All tables in the MERGE table are not identically defined ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists create database mysqltest; create table mysqltest.t6 (a int not null primary key auto_increment, message char(20)); create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6); Loading Loading @@ -277,7 +277,7 @@ t3 CREATE TABLE `t3` ( drop table t3,t2,t1; create table t1 (a int not null, key(a)) engine=merge; select * from t1; a ERROR HY000: Got error 124 from storage engine drop table t1; create table t1 (a int not null, b int not null, key(a,b)); create table t2 (a int not null, b int not null, key(a,b)); Loading Loading @@ -771,6 +771,21 @@ Table Op Msg_type Msg_text test.t1 check status OK test.t2 check status OK drop table t1, t2, t3; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(2),(1); CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); SELECT * FROM t2 WHERE a=2; ERROR HY000: Got error 124 from storage engine DROP TABLE t1, t2; CREATE TABLE t1(a INT) ENGINE=MEMORY; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); SELECT * FROM t2; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists DROP TABLE t1, t2; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); SELECT * FROM t2; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists DROP TABLE t2; create table t1 (b bit(1)); create table t2 (b bit(1)); create table tm (b bit(1)) engine = merge union = (t1,t2); Loading mysql-test/t/delayed.test +142 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ insert delayed into t1 set a = 4; insert delayed into t1 set a = 5, tmsp = 19711006010203; insert delayed into t1 (a, tmsp) values (6, 19711006010203); insert delayed into t1 (a, tmsp) values (7, NULL); --sleep 2 # Wait until the rows are flushed to the table files. FLUSH TABLE t1; insert into t1 set a = 8,tmsp=19711006010203; select * from t1 where tmsp=0; select * from t1 where tmsp=19711006010203; Loading @@ -34,8 +35,8 @@ insert delayed into t1 values (null,"c"); insert delayed into t1 values (3,"d"),(null,"e"); --error 1136 insert delayed into t1 values (3,"this will give an","error"); # 2 was not enough for --ps-protocol --sleep 4 # Wait until the rows are flushed to the table files. FLUSH TABLE t1; show status like 'not_flushed_delayed_rows'; select * from t1; drop table t1; Loading Loading @@ -92,10 +93,145 @@ insert delayed into t1 values(null); # Works, since the delayed-counter is 8, which is unused insert delayed into t1 values(null); # Wait until the rows are flushed to the table files. FLUSH TABLE t1; # Check what we have now # must wait so that the delayed thread finishes # Note: this must be increased if the test fails --sleep 1 select * from t1 order by a; DROP TABLE t1; # # Bug#20627 - INSERT DELAYED does not honour auto_increment_* variables # SET @bug20627_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20627_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20627_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20627_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; # # Normal insert as reference. CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT INTO t1 VALUES (NULL),(NULL),(NULL); # Check what we have now SELECT * FROM t1; DROP TABLE t1; # # Delayed insert. CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT DELAYED INTO t1 VALUES (NULL),(NULL),(NULL); # Wait until the rows are flushed to the table files. FLUSH TABLE t1; # Check what we have now SELECT * FROM t1; DROP TABLE t1; # # Cleanup SET @@auto_increment_offset= @bug20627_old_auto_increment_offset; SET @@auto_increment_increment= @bug20627_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20627_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20627_old_session_auto_increment_increment; # # Bug#20830 - INSERT DELAYED does not honour SET INSERT_ID # SET @bug20830_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20830_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20830_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20830_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; # # Normal insert as reference. CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); # Restart sequence at a different value. INSERT INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); # Restart sequence at a different value. SET insert_id= 114; INSERT INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); # Set one value below the maximum value. INSERT INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); # Create a duplicate value. SET insert_id= 114; --error 1062 INSERT INTO t1 VALUES(NULL, 91); INSERT INTO t1 VALUES (NULL, 92), (NULL, 93); # Check what we have now SELECT * FROM t1; SELECT COUNT(*) FROM t1; SELECT SUM(c1) FROM t1; DROP TABLE t1; # # Delayed insert. CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT DELAYED INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT DELAYED INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); # Restart sequence at a different value. INSERT DELAYED INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT DELAYED INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); # Restart sequence at a different value. SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT DELAYED INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); # Set one value below the maximum value. INSERT DELAYED INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT DELAYED INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); # Create a duplicate value. SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 91); INSERT DELAYED INTO t1 VALUES (NULL, 92), (NULL, 93); # Wait until the rows are flushed to the table files. FLUSH TABLE t1; # Check what we have now SELECT * FROM t1; SELECT COUNT(*) FROM t1; SELECT SUM(c1) FROM t1; DROP TABLE t1; # # Cleanup SET @@auto_increment_offset= @bug20830_old_auto_increment_offset; SET @@auto_increment_increment= @bug20830_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20830_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20830_old_session_auto_increment_increment; mysql-test/t/merge.test +26 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,7 @@ drop table t3,t2,t1; # Test table without unions # create table t1 (a int not null, key(a)) engine=merge; --error 1030 select * from t1; drop table t1; Loading Loading @@ -381,6 +382,31 @@ select * from t3; check table t1, t2; drop table t1, t2, t3; # # BUG#21617 - crash when selecting from merge table with inconsistent # indexes # CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(2),(1); CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); --error 1030 SELECT * FROM t2 WHERE a=2; DROP TABLE t1, t2; # # BUG#10974 - No error message if merge table based on union of innodb, # memory # CREATE TABLE t1(a INT) ENGINE=MEMORY; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); --error 1168 SELECT * FROM t2; DROP TABLE t1, t2; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); --error 1168 SELECT * FROM t2; DROP TABLE t2; # End of 4.1 tests # Loading mysys/queues.c +19 −29 Original line number Diff line number Diff line Loading @@ -210,14 +210,9 @@ void queue_insert(register QUEUE *queue, byte *element) { reg2 uint idx, next; int cmp; #ifndef DBUG_OFF if (queue->elements < queue->max_elements) #endif { DBUG_ASSERT(queue->elements < queue->max_elements); queue->root[0]= element; idx= ++queue->elements; /* max_at_top swaps the comparison if we want to order by desc */ while ((cmp= queue->compare(queue->first_cmp_arg, element + queue->offset_to_key, Loading @@ -230,7 +225,6 @@ void queue_insert(register QUEUE *queue, byte *element) } queue->root[idx]= element; } } /* Does safe insert. If no more space left on the queue resize it. Loading Loading @@ -262,16 +256,12 @@ int queue_insert_safe(register QUEUE *queue, byte *element) byte *queue_remove(register QUEUE *queue, uint idx) { #ifndef DBUG_OFF if (idx >= queue->max_elements) return 0; #endif { byte *element=queue->root[++idx]; /* Intern index starts from 1 */ byte *element; DBUG_ASSERT(idx < queue->max_elements); element= queue->root[++idx]; /* Intern index starts from 1 */ queue->root[idx]= queue->root[queue->elements--]; _downheap(queue, idx); return element; } } /* Fix when element on top has been replaced */ Loading Loading
mysql-test/r/delayed.result +174 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ insert delayed into t1 set a = 4; insert delayed into t1 set a = 5, tmsp = 19711006010203; insert delayed into t1 (a, tmsp) values (6, 19711006010203); insert delayed into t1 (a, tmsp) values (7, NULL); FLUSH TABLE t1; insert into t1 set a = 8,tmsp=19711006010203; select * from t1 where tmsp=0; a tmsp Loading @@ -22,6 +23,7 @@ insert delayed into t1 values (null,"c"); insert delayed into t1 values (3,"d"),(null,"e"); insert delayed into t1 values (3,"this will give an","error"); ERROR 21S01: Column count doesn't match value count at row 1 FLUSH TABLE t1; show status like 'not_flushed_delayed_rows'; Variable_name Value Not_flushed_delayed_rows 0 Loading Loading @@ -54,6 +56,7 @@ insert delayed into t1 values(null); insert delayed into t1 values(null); insert delayed into t1 values(null); insert delayed into t1 values(null); FLUSH TABLE t1; select * from t1 order by a; a 1 Loading @@ -69,3 +72,174 @@ a 12 13 DROP TABLE t1; SET @bug20627_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20627_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20627_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20627_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT INTO t1 VALUES (NULL),(NULL),(NULL); SELECT * FROM t1; c1 4 9 14 DROP TABLE t1; CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT DELAYED INTO t1 VALUES (NULL),(NULL),(NULL); FLUSH TABLE t1; SELECT * FROM t1; c1 4 9 14 DROP TABLE t1; SET @@auto_increment_offset= @bug20627_old_auto_increment_offset; SET @@auto_increment_increment= @bug20627_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20627_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20627_old_session_auto_increment_increment; SET @bug20830_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20830_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20830_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20830_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); INSERT INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); SET insert_id= 114; INSERT INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); INSERT INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); SET insert_id= 114; INSERT INTO t1 VALUES(NULL, 91); ERROR 23000: Duplicate entry '114' for key 'PRIMARY' INSERT INTO t1 VALUES (NULL, 92), (NULL, 93); SELECT * FROM t1; c1 c2 14 11 19 12 24 13 29 21 34 22 39 23 69 31 74 32 79 33 84 41 89 42 94 43 114 51 119 52 124 53 129 61 134 62 139 63 49 71 144 72 149 73 154 81 159 82 164 83 169 92 174 93 SELECT COUNT(*) FROM t1; COUNT(*) 26 SELECT SUM(c1) FROM t1; SUM(c1) 2569 DROP TABLE t1; CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT DELAYED INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT DELAYED INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); INSERT DELAYED INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT DELAYED INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT DELAYED INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); INSERT DELAYED INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT DELAYED INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 91); INSERT DELAYED INTO t1 VALUES (NULL, 92), (NULL, 93); FLUSH TABLE t1; SELECT * FROM t1; c1 c2 14 11 19 12 24 13 29 21 34 22 39 23 69 31 74 32 79 33 84 41 89 42 94 43 114 51 119 52 124 53 129 61 134 62 139 63 49 71 144 72 149 73 154 81 159 82 164 83 169 92 174 93 SELECT COUNT(*) FROM t1; COUNT(*) 26 SELECT SUM(c1) FROM t1; SUM(c1) 2569 DROP TABLE t1; SET @@auto_increment_offset= @bug20830_old_auto_increment_offset; SET @@auto_increment_increment= @bug20830_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20830_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20830_old_session_auto_increment_increment;
mysql-test/r/merge.result +19 −4 Original line number Diff line number Diff line Loading @@ -178,12 +178,12 @@ t3 CREATE TABLE `t3` ( ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); select * from t4; ERROR HY000: All tables in the MERGE table are not identically defined ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists alter table t4 add column c int; ERROR HY000: All tables in the MERGE table are not identically defined ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists flush tables; select * from t4; ERROR HY000: All tables in the MERGE table are not identically defined ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists create database mysqltest; create table mysqltest.t6 (a int not null primary key auto_increment, message char(20)); create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6); Loading Loading @@ -277,7 +277,7 @@ t3 CREATE TABLE `t3` ( drop table t3,t2,t1; create table t1 (a int not null, key(a)) engine=merge; select * from t1; a ERROR HY000: Got error 124 from storage engine drop table t1; create table t1 (a int not null, b int not null, key(a,b)); create table t2 (a int not null, b int not null, key(a,b)); Loading Loading @@ -771,6 +771,21 @@ Table Op Msg_type Msg_text test.t1 check status OK test.t2 check status OK drop table t1, t2, t3; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(2),(1); CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); SELECT * FROM t2 WHERE a=2; ERROR HY000: Got error 124 from storage engine DROP TABLE t1, t2; CREATE TABLE t1(a INT) ENGINE=MEMORY; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); SELECT * FROM t2; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists DROP TABLE t1, t2; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); SELECT * FROM t2; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists DROP TABLE t2; create table t1 (b bit(1)); create table t2 (b bit(1)); create table tm (b bit(1)) engine = merge union = (t1,t2); Loading
mysql-test/t/delayed.test +142 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,8 @@ insert delayed into t1 set a = 4; insert delayed into t1 set a = 5, tmsp = 19711006010203; insert delayed into t1 (a, tmsp) values (6, 19711006010203); insert delayed into t1 (a, tmsp) values (7, NULL); --sleep 2 # Wait until the rows are flushed to the table files. FLUSH TABLE t1; insert into t1 set a = 8,tmsp=19711006010203; select * from t1 where tmsp=0; select * from t1 where tmsp=19711006010203; Loading @@ -34,8 +35,8 @@ insert delayed into t1 values (null,"c"); insert delayed into t1 values (3,"d"),(null,"e"); --error 1136 insert delayed into t1 values (3,"this will give an","error"); # 2 was not enough for --ps-protocol --sleep 4 # Wait until the rows are flushed to the table files. FLUSH TABLE t1; show status like 'not_flushed_delayed_rows'; select * from t1; drop table t1; Loading Loading @@ -92,10 +93,145 @@ insert delayed into t1 values(null); # Works, since the delayed-counter is 8, which is unused insert delayed into t1 values(null); # Wait until the rows are flushed to the table files. FLUSH TABLE t1; # Check what we have now # must wait so that the delayed thread finishes # Note: this must be increased if the test fails --sleep 1 select * from t1 order by a; DROP TABLE t1; # # Bug#20627 - INSERT DELAYED does not honour auto_increment_* variables # SET @bug20627_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20627_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20627_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20627_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; # # Normal insert as reference. CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT INTO t1 VALUES (NULL),(NULL),(NULL); # Check what we have now SELECT * FROM t1; DROP TABLE t1; # # Delayed insert. CREATE TABLE t1 ( c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1) ); INSERT DELAYED INTO t1 VALUES (NULL),(NULL),(NULL); # Wait until the rows are flushed to the table files. FLUSH TABLE t1; # Check what we have now SELECT * FROM t1; DROP TABLE t1; # # Cleanup SET @@auto_increment_offset= @bug20627_old_auto_increment_offset; SET @@auto_increment_increment= @bug20627_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20627_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20627_old_session_auto_increment_increment; # # Bug#20830 - INSERT DELAYED does not honour SET INSERT_ID # SET @bug20830_old_auto_increment_offset= @@auto_increment_offset= 2; SET @bug20830_old_auto_increment_increment= @@auto_increment_increment= 3; SET @bug20830_old_session_auto_increment_offset= @@session.auto_increment_offset= 4; SET @bug20830_old_session_auto_increment_increment= @@session.auto_increment_increment= 5; SET @@auto_increment_offset= 2; SET @@auto_increment_increment= 3; SET @@session.auto_increment_offset= 4; SET @@session.auto_increment_increment= 5; # # Normal insert as reference. CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); # Restart sequence at a different value. INSERT INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); # Restart sequence at a different value. SET insert_id= 114; INSERT INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); # Set one value below the maximum value. INSERT INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); # Create a duplicate value. SET insert_id= 114; --error 1062 INSERT INTO t1 VALUES(NULL, 91); INSERT INTO t1 VALUES (NULL, 92), (NULL, 93); # Check what we have now SELECT * FROM t1; SELECT COUNT(*) FROM t1; SELECT SUM(c1) FROM t1; DROP TABLE t1; # # Delayed insert. CREATE TABLE t1 ( c1 INT(11) NOT NULL AUTO_INCREMENT, c2 INT(11) DEFAULT NULL, PRIMARY KEY (c1) ); SET insert_id= 14; INSERT DELAYED INTO t1 VALUES(NULL, 11), (NULL, 12), (NULL, 13); INSERT DELAYED INTO t1 VALUES(NULL, 21), (NULL, 22), (NULL, 23); # Restart sequence at a different value. INSERT DELAYED INTO t1 VALUES( 69, 31), (NULL, 32), (NULL, 33); INSERT DELAYED INTO t1 VALUES(NULL, 41), (NULL, 42), (NULL, 43); # Restart sequence at a different value. SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 51), (NULL, 52), (NULL, 53); INSERT DELAYED INTO t1 VALUES(NULL, 61), (NULL, 62), (NULL, 63); # Set one value below the maximum value. INSERT DELAYED INTO t1 VALUES( 49, 71), (NULL, 72), (NULL, 73); INSERT DELAYED INTO t1 VALUES(NULL, 81), (NULL, 82), (NULL, 83); # Create a duplicate value. SET insert_id= 114; INSERT DELAYED INTO t1 VALUES(NULL, 91); INSERT DELAYED INTO t1 VALUES (NULL, 92), (NULL, 93); # Wait until the rows are flushed to the table files. FLUSH TABLE t1; # Check what we have now SELECT * FROM t1; SELECT COUNT(*) FROM t1; SELECT SUM(c1) FROM t1; DROP TABLE t1; # # Cleanup SET @@auto_increment_offset= @bug20830_old_auto_increment_offset; SET @@auto_increment_increment= @bug20830_old_auto_increment_increment; SET @@session.auto_increment_offset= @bug20830_old_session_auto_increment_offset; SET @@session.auto_increment_increment= @bug20830_old_session_auto_increment_increment;
mysql-test/t/merge.test +26 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,7 @@ drop table t3,t2,t1; # Test table without unions # create table t1 (a int not null, key(a)) engine=merge; --error 1030 select * from t1; drop table t1; Loading Loading @@ -381,6 +382,31 @@ select * from t3; check table t1, t2; drop table t1, t2, t3; # # BUG#21617 - crash when selecting from merge table with inconsistent # indexes # CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(2),(1); CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); --error 1030 SELECT * FROM t2 WHERE a=2; DROP TABLE t1, t2; # # BUG#10974 - No error message if merge table based on union of innodb, # memory # CREATE TABLE t1(a INT) ENGINE=MEMORY; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); --error 1168 SELECT * FROM t2; DROP TABLE t1, t2; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); --error 1168 SELECT * FROM t2; DROP TABLE t2; # End of 4.1 tests # Loading
mysys/queues.c +19 −29 Original line number Diff line number Diff line Loading @@ -210,14 +210,9 @@ void queue_insert(register QUEUE *queue, byte *element) { reg2 uint idx, next; int cmp; #ifndef DBUG_OFF if (queue->elements < queue->max_elements) #endif { DBUG_ASSERT(queue->elements < queue->max_elements); queue->root[0]= element; idx= ++queue->elements; /* max_at_top swaps the comparison if we want to order by desc */ while ((cmp= queue->compare(queue->first_cmp_arg, element + queue->offset_to_key, Loading @@ -230,7 +225,6 @@ void queue_insert(register QUEUE *queue, byte *element) } queue->root[idx]= element; } } /* Does safe insert. If no more space left on the queue resize it. Loading Loading @@ -262,16 +256,12 @@ int queue_insert_safe(register QUEUE *queue, byte *element) byte *queue_remove(register QUEUE *queue, uint idx) { #ifndef DBUG_OFF if (idx >= queue->max_elements) return 0; #endif { byte *element=queue->root[++idx]; /* Intern index starts from 1 */ byte *element; DBUG_ASSERT(idx < queue->max_elements); element= queue->root[++idx]; /* Intern index starts from 1 */ queue->root[idx]= queue->root[queue->elements--]; _downheap(queue, idx); return element; } } /* Fix when element on top has been replaced */ Loading