delayed.test 8.61 KB
Newer Older
1 2
# delayed works differently in embedded server
--source include/not_embedded.inc
3 4 5 6 7
#
# test of DELAYED insert and timestamps
# (Can't be tested with purify :( )
#

8
--disable_warnings
9
drop table if exists t1;
10
--enable_warnings
11 12 13 14 15 16 17 18
create table t1 (a char(10), tmsp timestamp);
insert into t1 set a = 1;
insert delayed into t1 set a = 2;
insert into t1 set a = 3, tmsp=NULL;
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);
19 20
# Wait until the rows are flushed to the table files.
FLUSH TABLE t1;
21 22 23 24
insert into t1 set a = 8,tmsp=19711006010203;
select * from t1 where tmsp=0;
select * from t1 where tmsp=19711006010203;
drop table t1;
25 26 27 28 29 30 31 32 33 34 35 36

#
# Test bug when inserting NULL into an auto_increment field with
# INSERT DELAYED
#

create table t1 (a int not null auto_increment primary key, b char(10));
insert delayed into t1 values (1,"b");
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");
37 38
# Wait until the rows are flushed to the table files.
FLUSH TABLE t1;
39
show status like 'not_flushed_delayed_rows';
40 41
select * from t1;
drop table t1;
42 43

# End of 4.1 tests
44 45 46 47 48 49 50 51 52

#
# Bug #12226: Crash when a delayed insert fails due to a duplicate key
#
create table t1 (a int not null primary key);
insert into t1 values (1);
insert delayed into t1 values (1);
select * from t1;
drop table t1;
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

#
# Bug #20195: INSERT DELAYED with auto_increment is assigned wrong values
#
CREATE TABLE t1 ( a int(10) NOT NULL auto_increment, PRIMARY KEY (a));

# Make one delayed insert to start the separate thread
insert delayed into t1 values(null);

# Do some normal inserts
insert into t1 values(null);
insert into t1 values(null);

# Discarded, since the delayed-counter is 2, which is already used
insert delayed into t1 values(null);

# Discarded, since the delayed-counter is 3, which is already used
insert delayed into t1 values(null);

# Works, since the delayed-counter is 4, which is unused
insert delayed into t1 values(null);

# Do some more inserts
insert into t1 values(null);
insert into t1 values(null);
insert into t1 values(null);

# Delete one of the above to make a hole
delete from t1 where a=6;

# Discarded, since the delayed-counter is 5, which is already used
insert delayed into t1 values(null);

# Works, since the delayed-counter is 6, which is unused (the row we deleted)
insert delayed into t1 values(null);

# Discarded, since the delayed-counter is 7, which is already used
insert delayed into t1 values(null);

# Works, since the delayed-counter is 8, which is unused
insert delayed into t1 values(null);

95 96
# Wait until the rows are flushed to the table files.
FLUSH TABLE t1;
97 98 99 100
# Check what we have now
select * from t1 order by a;

DROP TABLE t1;
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186

#
# 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;
187
--error ER_DUP_ENTRY
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
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;

237 238 239 240 241 242 243 244
#
# BUG#26238 - inserted delayed always inserts 0 for BIT columns
#
CREATE TABLE t1(a BIT);
INSERT DELAYED INTO t1 VALUES(1);
FLUSH TABLE t1;
SELECT HEX(a) FROM t1;
DROP TABLE t1;
245 246 247 248 249 250 251 252 253

#
# Bug#26464 - insert delayed + update + merge = corruption
#
CREATE TABLE t1(c1 INT) ENGINE=MyISAM;
CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1);
--error 1031
INSERT DELAYED INTO t2 VALUES(1);
DROP TABLE t1, t2;
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
#
# Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client
#
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
CREATE TABLE `t1` (
  `id` int(11) PRIMARY KEY auto_increment,
  `f1` varchar(10) NOT NULL UNIQUE
);
INSERT DELAYED INTO t1 VALUES(0,"test1");
sleep 1;
SELECT * FROM t1;
SET SQL_MODE='PIPES_AS_CONCAT';
INSERT DELAYED INTO t1 VALUES(0,'a' || 'b');
sleep 1;
SELECT * FROM t1;
SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES';
--error 1365
INSERT DELAYED INTO t1 VALUES(mod(1,0),"test3");
CREATE TABLE t2 (
  `id` int(11) PRIMARY KEY auto_increment,
  `f1` date
);
SET SQL_MODE='NO_ZERO_DATE,STRICT_ALL_TABLES,NO_ZERO_IN_DATE';
--error ER_TRUNCATED_WRONG_VALUE
INSERT DELAYED INTO t2 VALUES (0,'0000-00-00');
--error ER_TRUNCATED_WRONG_VALUE
INSERT DELAYED INTO t2 VALUES (0,'2007-00-00');
DROP TABLE t1,t2;
285