1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
95
96
97
98
99
100
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
187
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
|
################################################################################
# t/gcol_bugfixes.test #
# #
# Purpose: #
# Bug fixes that only need one storage engine #
# #
################################################################################
--source include/have_innodb.inc
--echo # Bug#21230709: Alter table statement fails with division by zero
CREATE TABLE t1 (
col1 INTEGER NOT NULL,
col2 INTEGER NOT NULL,
col3 INTEGER NOT NULL,
gcol1 INTEGER GENERATED ALWAYS AS (col3 + col3) VIRTUAL,
col4 INTEGER DEFAULT NULL,
col5 INTEGER DEFAULT NULL,
col6 INTEGER DEFAULT NULL,
col7 INTEGER DEFAULT NULL,
col8 INTEGER DEFAULT NULL,
col9 INTEGER DEFAULT NULL,
col10 INTEGER DEFAULT NULL,
col11 INTEGER DEFAULT NULL,
col12 INTEGER DEFAULT NULL,
col13 INTEGER DEFAULT NULL,
col14 INTEGER DEFAULT NULL,
col15 INTEGER DEFAULT NULL,
col16 INTEGER DEFAULT NULL,
col17 INTEGER DEFAULT NULL,
col18 INTEGER DEFAULT NULL,
col19 INTEGER DEFAULT NULL,
col20 INTEGER DEFAULT NULL,
col21 INTEGER DEFAULT NULL,
col22 INTEGER DEFAULT NULL,
col23 INTEGER DEFAULT NULL,
col24 INTEGER DEFAULT NULL,
col25 INTEGER DEFAULT NULL,
col26 INTEGER DEFAULT NULL,
col27 INTEGER DEFAULT NULL,
col28 INTEGER DEFAULT NULL,
col29 INTEGER DEFAULT NULL,
col30 INTEGER DEFAULT NULL,
col31 INTEGER DEFAULT NULL,
col32 INTEGER DEFAULT NULL,
col33 INTEGER DEFAULT NULL,
gcol2 INTEGER GENERATED ALWAYS AS (col2 + col2) VIRTUAL,
gcol3 INTEGER GENERATED ALWAYS AS (gcol2 / gcol2) VIRTUAL,
PRIMARY KEY (col1),
KEY idx1 (gcol1)
) engine=innodb;
INSERT INTO t1 (col1, col2, col3)
VALUES (0,1,2), (1,2,3), (2,3,4), (3,4,5), (4,5,6);
# This is likely needed to ensure we allocate a new record buffer that
# contains zero in the mis-used field
FLUSH TABLE t1;
ALTER TABLE t1 ADD COLUMN extra INTEGER;
DROP TABLE t1;
--echo #
--echo # Bug 21340801 WL8149:ASSERTION `IS_VIRTUAL_GCOL()' FAILED
--echo #
CREATE TABLE t1 (
c_blob BLOB,
c_blob_key BLOB GENERATED ALWAYS AS (REPEAT(c_blob,15)) STORED,
KEY (c_blob_key(200))
);
INSERT INTO t1 (c_blob) VALUES ('xceks');
DROP TABLE t1;
--echo #
--echo # Bug#21345972 WL8149:JOIN_CACHE::FILTER_VIRTUAL_GCOL_BASE_COLS(): ASSERTION `FALSE' FAILED.
--echo #
CREATE TABLE c (
pk INTEGER AUTO_INCREMENT,
col_int_nokey INTEGER,
gcol_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL,
col_date_nokey DATE,
gcol_date_key DATE GENERATED ALWAYS AS (DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL,
col_datetime_nokey DATETIME,
col_time_nokey TIME,
gcol_datetime_key DATETIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
gcol_time_key TIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
col_varchar_nokey VARCHAR(1),
gcol_varchar_key VARCHAR(2) GENERATED ALWAYS AS (CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
PRIMARY KEY (pk),
UNIQUE KEY (gcol_int_key),
UNIQUE KEY (gcol_varchar_key),
UNIQUE KEY (gcol_date_key),
KEY (gcol_time_key),
KEY (gcol_datetime_key),
UNIQUE KEY (gcol_int_key, gcol_varchar_key),
KEY (gcol_int_key, col_int_nokey),
KEY(gcol_int_key,gcol_date_key),
KEY(gcol_int_key, gcol_time_key),
KEY(gcol_int_key, gcol_datetime_key),
UNIQUE KEY(gcol_date_key,gcol_time_key,gcol_datetime_key),
UNIQUE KEY (gcol_varchar_key, col_varchar_nokey),
UNIQUE KEY (gcol_int_key, gcol_varchar_key, gcol_date_key, gcol_time_key, gcol_datetime_key)
) ENGINE=INNODB;
INSERT IGNORE INTO c ( col_int_nokey, col_date_nokey, col_time_nokey, col_datetime_nokey, col_varchar_nokey)
VALUES (7, '2004-04-09', '14:03:03.042673', '2001-11-28 00:50:27.051028', 'c'),
(1, '2006-05-13', '01:46:09.016386', '2007-10-09 19:53:04.008332', NULL);
CREATE TABLE bb (
pk INTEGER AUTO_INCREMENT,
col_int_nokey INTEGER,
gcol_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL,
col_date_nokey DATE,
gcol_date_key DATE GENERATED ALWAYS AS (DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL,
col_datetime_nokey DATETIME,
col_time_nokey TIME,
gcol_datetime_key DATETIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
gcol_time_key TIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
col_varchar_nokey VARCHAR(1),
gcol_varchar_key VARCHAR(2) GENERATED ALWAYS AS (CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
PRIMARY KEY (pk),
UNIQUE KEY (gcol_int_key),
UNIQUE KEY (gcol_varchar_key),
UNIQUE KEY (gcol_date_key),
KEY (gcol_time_key),
KEY (gcol_datetime_key),
UNIQUE KEY (gcol_int_key, gcol_varchar_key),
KEY (gcol_int_key, col_int_nokey),
KEY(gcol_int_key,gcol_date_key),
KEY(gcol_int_key, gcol_time_key),
KEY(gcol_int_key, gcol_datetime_key),
UNIQUE KEY(gcol_date_key,gcol_time_key,gcol_datetime_key),
UNIQUE KEY (gcol_varchar_key, col_varchar_nokey),
UNIQUE KEY (gcol_int_key, gcol_varchar_key, gcol_date_key, gcol_time_key, gcol_datetime_key)
) AUTO_INCREMENT=10 ENGINE=INNODB;
INSERT IGNORE INTO bb ( col_int_nokey, col_date_nokey, col_time_nokey, col_datetime_nokey, col_varchar_nokey)
VALUES (0, '2003-08-04', '01:48:05.048577', '2006-11-03 00:00:00', 'p'),
(2, '2007-11-06', '00:00:00', '2009-11-26 19:28:11.005115', 'n');
CREATE TABLE cc (
pk INTEGER AUTO_INCREMENT,
col_int_nokey INTEGER,
gcol_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL,
col_date_nokey DATE,
gcol_date_key DATE GENERATED ALWAYS AS (DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL,
col_datetime_nokey DATETIME,
col_time_nokey TIME,
gcol_datetime_key DATETIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
gcol_time_key TIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
col_varchar_nokey VARCHAR(1),
gcol_varchar_key VARCHAR(2) GENERATED ALWAYS AS (CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
PRIMARY KEY (pk),
UNIQUE KEY (gcol_int_key),
UNIQUE KEY (gcol_varchar_key),
UNIQUE KEY (gcol_date_key),
KEY (gcol_time_key),
KEY (gcol_datetime_key),
UNIQUE KEY (gcol_int_key, gcol_varchar_key),
KEY (gcol_int_key, col_int_nokey),
KEY(gcol_int_key,gcol_date_key),
KEY(gcol_int_key, gcol_time_key),
KEY(gcol_int_key, gcol_datetime_key),
UNIQUE KEY(gcol_date_key,gcol_time_key,gcol_datetime_key),
UNIQUE KEY (gcol_varchar_key, col_varchar_nokey),
UNIQUE KEY (gcol_int_key, gcol_varchar_key, gcol_date_key, gcol_time_key, gcol_datetime_key)
) AUTO_INCREMENT=10 ENGINE=INNODB;
INSERT IGNORE INTO cc (col_int_nokey, col_date_nokey, col_time_nokey, col_datetime_nokey, col_varchar_nokey)
VALUES (172, '2009-04-23', '00:00:00', '2000-12-07 10:17:40.013275', 'h'),
(NULL, '2002-10-06', '00:50:49.017545', NULL, 'm');
let $query=
SELECT
gp1 . gcol_datetime_key AS g1
FROM cc AS gp1 LEFT JOIN c AS gp2 ON ( gp2 . gcol_datetime_key <> gp1 .
col_time_nokey )
WHERE
gp1 . col_varchar_nokey IN
(
SELECT
DISTINCT p1 . gcol_varchar_key AS p1
FROM bb AS p1 LEFT JOIN bb AS p2
ON ( p1 . gcol_int_key = p2 . pk )
)
AND gp1 . col_varchar_nokey = 'b'
HAVING g1 > 6;
eval EXPLAIN $query;
eval $query;
DROP TABLE bb, c, cc;
--echo # Bug#21284646: Assertion !(table || table->read_set || bitmap_is_set())
CREATE TABLE c (
pk INTEGER AUTO_INCREMENT,
col_int_nokey INTEGER NOT NULL,
col_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL,
col_date_nokey DATE NOT NULL,
col_date_key DATE GENERATED ALWAYS AS (DATE_ADD(col_date_nokey,interval 30 day)) VIRTUAL,
col_datetime_nokey DATETIME NOT NULL,
col_time_nokey TIME NOT NULL,
col_datetime_key DATETIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
col_time_key TIME GENERATED ALWAYS AS (ADDTIME(col_datetime_nokey, col_time_nokey)) VIRTUAL,
col_varchar_nokey VARCHAR(1) NOT NULL,
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS (CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL,
PRIMARY KEY (pk,col_int_nokey),
UNIQUE KEY (col_int_key),
UNIQUE KEY (col_varchar_key),
UNIQUE KEY (col_date_key),
KEY (col_time_key),
KEY (col_datetime_key),
UNIQUE KEY (col_int_key, col_varchar_key),
KEY (col_int_key, col_int_nokey),
KEY(col_int_key,col_date_key),
KEY(col_int_key, col_time_key),
KEY(col_int_key, col_datetime_key),
UNIQUE KEY (col_date_key,col_time_key,col_datetime_key),
UNIQUE KEY (col_varchar_key, col_varchar_nokey),
UNIQUE KEY (col_int_key, col_varchar_key, col_date_key, col_time_key, col_datetime_key)
) ENGINE=INNODB;
INSERT INTO c (col_int_nokey, col_date_nokey, col_time_nokey, col_datetime_nokey, col_varchar_nokey) VALUES
(1, '2009-12-01', '00:21:38.058143', '2007-05-28 00:00:00', 'c'),
(8, '2004-12-17', '04:08:02.046897', '2009-07-25 09:21:20.064099', 'm'),
(9, '2000-03-14', '16:25:11.040240', '2002-01-16 00:00:00', 'd'),
(6, '2006-05-25', '19:47:59.011283', '2001-02-15 03:08:38.035426', 'y'),
(2, '2002-10-13', '00:00:00', '1900-01-01 00:00:00', 's'),
(4, '1900-01-01', '15:57:25.019666', '2005-08-15 00:00:00', 'r');
ANALYZE TABLE c;
let $query=
SELECT COUNT(DISTINCT col_varchar_key) AS x
FROM c
WHERE col_varchar_key IN ('rr', 'rr') OR
col_int_nokey <> 9 AND
pk >= 8
HAVING x > '2000-02-06'
ORDER BY col_time_nokey, pk;
eval explain $query;
eval $query;
DROP TABLE c;
--echo # Bug#21341044: Conditional jump at sort_param::make_sort_key
CREATE TABLE t1 (
pk INTEGER AUTO_INCREMENT,
col_int_nokey INTEGER,
col_int_key INTEGER GENERATED ALWAYS AS (col_int_nokey + col_int_nokey) VIRTUAL,
col_blob_nokey BLOB,
col_blob_key BLOB GENERATED ALWAYS AS (REPEAT(col_blob_nokey,15)) VIRTUAL,
col_longblob_nokey LONGBLOB,
col_longtext_nokey LONGTEXT,
col_longblob_key LONGBLOB GENERATED ALWAYS AS (REPEAT(col_longblob_nokey, 20)) VIRTUAL,
col_longtext_key LONGTEXT GENERATED ALWAYS AS (REPEAT(col_longblob_nokey, 18)) VIRTUAL,
col_text_nokey TEXT,
col_text_key TEXT GENERATED ALWAYS AS (REPEAT(col_text_nokey, 30)) VIRTUAL,
PRIMARY KEY (pk),
KEY (col_int_key),
KEY (col_text_key(50)),
KEY (col_blob_key(200)),
KEY (col_longtext_key(200)),
KEY (col_longblob_key(200)),
KEY (col_int_key, col_text_key(100)),
KEY (col_int_key, col_longtext_key(100)),
KEY (col_int_key, col_blob_key(100)),
KEY (col_int_key, col_longblob_key(100)),
KEY (col_longtext_key(10), col_longblob_key(100)),
KEY (col_int_key, col_text_key(10), col_blob_key(100), col_longtext_key(50), col_longblob_key(50))
) engine=innodb;
INSERT INTO t1 (col_int_nokey,col_blob_nokey,col_longtext_nokey,col_longblob_nokey,col_text_nokey)
VALUES
(0, 'ijcszxw', 'ijcszxw', 'ijcszxw', 'ijcszxw'),
(5, 'jcszxwb', 'jcszxwb', 'jcszxwb', 'jcszxwb'),
(4, 'cszxwbjjvv', 'cszxwbjjvv', 'cszxwbjjvv', 'cszxwbjjvv'),
(3, 'szxw', 'szxw', 'szxw', 'szxw'),
(7, 'zxwb', 'zxwb', 'zxwb', 'zxwb'),
(42, 'xwbjjvvky', 'xwbjjvvky', 'xwbjjvvky', 'xwbjjvvky'),
(142, 'wbjj', 'wbjj', 'wbjj', 'wbjj'),
(5, 'bjjv', 'bjjv', 'bjjv', 'bjjv'),
(0, 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu'),
(3, 'j', 'j', 'j', 'j');
SELECT alias1.pk AS field1
FROM t1 AS alias1 LEFT OUTER JOIN t1 AS alias2
ON alias1.col_int_key = alias2.col_int_key
WHERE alias2.col_int_key BETWEEN 8 AND (8 + 1 ) OR
alias2.col_int_key BETWEEN 8 AND (8 + 5 ) AND
alias2.col_int_key != 20 OR
alias2.col_int_key IN (8, 5, 8) AND
alias2.col_int_key >= 0 AND
alias2.col_int_key <= ( 8 + 75 ) AND
alias1.pk IS NOT NULL
ORDER BY field1;
DROP TABLE t1;
--echo # bug#21487651: gcols: memory leak after failed alter table
CREATE TABLE t(a int);
ALTER TABLE t ADD COLUMN b int GENERATED ALWAYS AS (
date_sub(a,interval a month)) VIRTUAL;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t ADD COLUMN c int GENERATED ALWAYS AS (sum(a));
DROP TABLE t;
--echo #
--echo # Bug#21628840: CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN
--echo # (II)
--echo #
CREATE TABLE t1( a INT ) ENGINE = INNODB;
INSERT INTO t1( a ) VALUES ( 1 ), ( 2 ), ( 3 ), ( 4 ), ( 5 );
ALTER TABLE t1 ADD COLUMN b INT GENERATED ALWAYS AS (a - 1) STORED;
ALTER TABLE t1 ADD COLUMN c INT GENERATED ALWAYS AS (b + 1) VIRTUAL;
--echo # Used to cause valgrind warning.
ALTER TABLE t1 ADD INDEX( c );
ANALYZE TABLE t1;
--echo # Make sure the index is correct. That's kinda important.
EXPLAIN
SELECT c FROM t1;
SELECT c FROM t1;
DROP TABLE t1;
--echo #
--echo # Bug#21797776 ASSERTION `BIT < MAP->N_BITS' FAILED.
--echo #
CREATE TABLE C (
col_int_1 INT,
col_int_2 INT GENERATED ALWAYS AS (col_int_1 + col_int_1) STORED,
col_int_3 INT GENERATED ALWAYS AS (col_int_2 + col_int_1) VIRTUAL
);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS
SELECT
col_int_2 AS field1, col_int_2 AS field2,
col_int_3 AS field3, col_int_3 AS field4
FROM C;
SELECT * FROM v1;
DROP TABLE C;
DROP VIEW v1;
--echo #
--echo # Bug#21613615 GCOLS: ASSERTION FAILED: !TABLE || (!TABLE->READ_SET || BITMAP_IS_SET
--echo #
CREATE TABLE t (a INT);
CREATE TABLE v (
a INT,
c INT,
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL,
KEY(c,b(1)));
INSERT INTO v (a,c) VALUES (1,1);
let $query=
SELECT 1 FROM t WHERE ( SELECT 1 FROM t ) >=ANY( SELECT c FROM v );
eval EXPLAIN $query;
eval $query;
# A similar one:
let $query=
SELECT (SELECT MAX(c) FROM v);
eval EXPLAIN $query;
eval $query;
DROP TABLE t, v;
CREATE TABLE v (
a INT,
c INT,
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL, KEY(c,b(1)));
INSERT INTO v (a,c) VALUES (1,1);
SELECT MAX(c), COUNT(b) FROM v;
DROP TABLE v;
# Using PK suffix of secondary index
CREATE TABLE v (
a INT PRIMARY KEY,
b INT, KEY(b));
INSERT INTO v (a,b) VALUES (1,1);
SELECT MAX(a) FROM v WHERE b=1;
DROP TABLE v;
--echo #
--echo # Bug#21824519: ASSERTION IN DROP TRIGGER WHEN TABLE HAS
--echo # VIRTUAL GENERATED COLUMN
--echo #
CREATE TABLE t (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL);
CREATE TRIGGER tr BEFORE INSERT ON t FOR EACH ROW BEGIN END;
INSERT INTO t (a) VALUES (1);
SELECT * FROM t;
# DROP TRIGGER used to hit a DBUG_ASSERT.
DROP TRIGGER tr;
SELECT * FROM t;
CREATE FUNCTION f() RETURNS INT RETURN (SELECT COUNT(*) FROM t);
# And this function call hit the same DBUG_ASSERT.
SELECT f();
DROP FUNCTION f;
SELECT * FROM t;
DROP TABLE t;
--echo #
--echo # Bug#21833760 CALC_DAYNR: ASSERTION `DELSUM+(INT) Y/4-TEMP >= 0' FAILED.
--echo #
CREATE TABLE C(
c1 INT AUTO_INCREMENT,
c8 DATETIME,
c9 TIME,
c11 TIME GENERATED ALWAYS AS(ADDTIME(c8,c9)) VIRTUAL,
c13 TIME GENERATED ALWAYS AS(ADDTIME(c8,c11)) VIRTUAL,
PRIMARY KEY(c1),
UNIQUE KEY(c13)
);
INSERT INTO C (c8,c9) VALUES('1970-01-01',0),('1970-01-01',1);
CREATE VIEW view_C AS SELECT * FROM C;
SELECT /*+ NO_BNL(t1) */ t1.c13 FROM C AS t2 STRAIGHT_JOIN C AS t1 FORCE INDEX(c13);
SELECT DISTINCT t1.c13 FROM C AS t1, view_C AS t2;
DROP TABLE C;
DROP VIEW view_C;
--echo #
--echo # Bug#21810529: CRASH IN ITEM_FUNC::WALK WHEN CODE JUMPS TO GARBAGE
--echo # LOCATION
--echo #
CREATE TABLE t (a TIME,b INT GENERATED ALWAYS AS (a=1) VIRTUAL);
--error ER_BAD_FIELD_ERROR
ALTER TABLE t CHANGE COLUMN q w INT;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t CHANGE COLUMN q w INT;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t CHANGE COLUMN q w INT;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t CHANGE COLUMN q w INT;
DROP TABLE t;
--echo #
--echo # Bug#21940542 TOO MUCH SPAM: INNODB: COMPUTE VIRTUAL COLUMN VALUES FAILED
--echo #
CREATE TABLE t(b BLOB);
--error ER_OPERAND_COLUMNS
ALTER TABLE t ADD COLUMN c INT GENERATED ALWAYS AS ((1,1)) VIRTUAL;
DROP TABLE t;
--error ER_OPERAND_COLUMNS
CREATE TABLE t(b BLOB, c INT GENERATED ALWAYS AS ((1,1)) VIRTUAL);
--echo #
--echo # Bug#21929967 GCOLS: GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE
--echo #
CREATE TABLE t1(a CHAR(1), b CHAR(1), c CHAR(2) AS (a || b));
SHOW CREATE TABLE t1;
INSERT INTO t1 (a,b) VALUES('1','1');
SELECT * FROM t1;
SET SQL_MODE=PIPES_AS_CONCAT;
SELECT * FROM t1;
FLUSH TABLES;
SELECT * FROM t1;
DROP TABLE t1;
# The other way around:
CREATE TABLE t1(a CHAR(1), b CHAR(1), c CHAR(2) AS (a || b));
SHOW CREATE TABLE t1;
INSERT INTO t1 (a,b) VALUES('1','1');
SELECT * FROM t1;
SET SQL_MODE=DEFAULT;
SELECT * FROM t1;
FLUSH TABLES;
SELECT * FROM t1;
DROP TABLE t1;
--echo # Bug#22018999: gcols: assertion failed: !error
SET @save_old_sql_mode= @@sql_mode;
SET sql_mode="";
CREATE TABLE t (a INTEGER AS (SUBSTR('','a',1))) engine=innodb;
DROP TABLE t;
CREATE TABLE t (a INTEGER) engine=innodb;
ALTER TABLE t ADD b INTEGER AS (SUBSTR('','a',1));
DROP TABLE t;
set sql_mode= @save_old_sql_mode;
--echo # Bug#21875520 Problems with virtual column indexes
CREATE TABLE t(
a TIMESTAMP,
b BLOB,
c TIMESTAMP GENERATED ALWAYS AS (GREATEST(a, '2000-01-01 00:00:00')) VIRTUAL,
UNIQUE KEY(c)
);
INSERT INTO t(b) VALUES ('');
UPDATE t SET a='2001-01-01 00:00:00';
SELECT c FROM t;
SELECT c, a FROM t;
UPDATE t SET b='xyz';
DO (SELECT @c1:= c FROM t);
DO (SELECT (@c2:= c) - a FROM t);
SELECT @c2 - @c1;
DROP TABLE t;
--echo #
--echo # Bug#22133710 GCOLS: READ UNCOMMITTED: ASSERT !TABLE || (!TABLE->WRITE_SET || BITMAP_IS_SET(TA
--echo #
CREATE TABLE t (
a INT,
b INT GENERATED ALWAYS AS (1) VIRTUAL,
c INT GENERATED ALWAYS AS (1) VIRTUAL,
d INT GENERATED ALWAYS AS (1) VIRTUAL,
KEY (b,d)
) ENGINE=INNODB;
INSERT INTO t VALUES();
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
SELECT 1 FROM t WHERE c GROUP BY b;
COMMIT;
DROP TABLE t;
--echo #
--echo # Bug #25793677 INNODB: FAILING ASSERTION: CLUST_TEMPL_FOR_SEC || LEN ....
--echo #
CREATE TABLE v (
a INT,
c INT,
b CHAR(2) GENERATED ALWAYS AS (a IN (1)) VIRTUAL,
KEY(c,b(1))) charset utf8mb4;
INSERT INTO v (a,c) VALUES (1,1);
SELECT (SELECT MAX(c) FROM v);
DROP TABLE v;
--echo #
--echo # MDEV-9255 Add generation_expression to information_schema.columns.
--echo #
CREATE TABLE gcol_t1 (
sidea DOUBLE,
sideb DOUBLE,
sidec DOUBLE AS (SQRT(sidea * sidea + sideb * sideb))
);
SELECT table_schema,table_name,column_name,extra,is_generated,generation_expression
FROM information_schema.columns WHERE table_name='gcol_t1';
DROP TABLE gcol_t1;
--echo #
--echo # MDEV-16039 Crash when selecting virtual columns
--echo # generated using functions with DAYNAME()
--echo #
CREATE TABLE t1 (
suppliersenttoday INT NOT NULL,
suppliercaptoday CHAR(10) AS (CONCAT('',DAYNAME('2020-02-05')))
) COLLATE utf8_bin;
INSERT INTO t1 (suppliersenttoday) VALUES (0);
INSERT INTO t1 (suppliersenttoday) VALUES (0);
SELECT * FROM t1;
PREPARE STMT FROM 'INSERT INTO t1 (suppliersenttoday) VALUES (1)';
CREATE OR REPLACE TABLE t1 (
suppliersenttoday INT NOT NULL,
suppliercaptoday CHAR(10) AS (CONCAT('',DAYNAME('2020-02-05')))
) COLLATE utf8_bin;
EXECUTE STMT;
EXECUTE STMT;
SELECT * FROM t1;
DROP TABLE t1;
--echo # (duplicate) MDEV-20380 Server crash during update
CREATE TABLE gafld (
nuigafld INTEGER NOT NULL,
ucrgafld VARCHAR(30) COLLATE UTF8_BIN NOT NULL
DEFAULT SUBSTRING_INDEX(USER(),'@',1)
);
EXPLAIN UPDATE gafld SET nuigafld = 0 WHERE nuigafld = 10;
EXPLAIN UPDATE gafld SET nuigafld = 0 WHERE nuigafld = 10;
DROP TABLE gafld;
--echo # (duplicate) MDEV-17653 replace into generated columns is unstable
--echo # Some columns are snipped from the MDEV test
CREATE TABLE t (
c0 TIMESTAMP NOT NULL DEFAULT current_timestamp()
ON UPDATE current_timestamp(),
c1 DECIMAL(27,25) GENERATED ALWAYS AS (DAYOFMONTH('2020-02-05')),
c4 TIME NOT NULL,
c8 SMALLINT(6) GENERATED ALWAYS AS
(CONCAT_WS(CONVERT(C1 USING CP932),
'900') <> (c4 = 1)),
PRIMARY KEY (c4)
) DEFAULT CHARSET=latin1;
REPLACE INTO t SET c0 = '2018-06-03 10:31:43', c4 = '02:58:55';
REPLACE INTO t SET c0 = '2018-06-03 10:31:44', c4 = '02:58:55';
REPLACE INTO t SET c0 = '2018-06-03 10:31:45', c4 = '02:58:55';
DROP TABLE t;
--echo # (duplicate) MDEV-17986 crash when I insert on a table
CREATE OR REPLACE TABLE t2 (
number BIGINT(20) NOT NULL,
lrn BIGINT(20) NOT NULL DEFAULT 0,
source VARCHAR(15) NOT NULL
DEFAULT (REVERSE(SUBSTRING_INDEX(REVERSE(user()), '@', 1))),
PRIMARY KEY (number)
);
REPLACE t2(number) VALUES('1');
REPLACE t2(number) VALUES('1');
DROP TABLE t2;
--echo # MDEV-24583 SELECT aborts after failed REPLACE into table with vcol
CREATE TABLE t1 (pk INT, a VARCHAR(3), v VARCHAR(3) AS (CONCAT('x-',a)),
PRIMARY KEY(pk)) ENGINE=MyISAM;
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 (pk, a) VALUES (1,'foo');
SET sql_mode=CONCAT(@@sql_mode,',STRICT_ALL_TABLES');
--error 0,ER_DATA_TOO_LONG
REPLACE INTO t1 (pk,a) VALUES (1,'qux');
SELECT * FROM v1;
# Cleanup
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (
pk INT,
a VARCHAR(1),
v VARCHAR(1) AS (CONCAT('virt-',a)) VIRTUAL,
PRIMARY KEY (pk)
) ENGINE=InnoDB;
INSERT INTO t1 (pk,a) VALUES
(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f');
--error ER_DATA_TOO_LONG
REPLACE INTO t1 (pk) VALUES (1);
SELECT * FROM t1 ORDER BY a;
SET SQL_MODE=DEFAULT;
DROP TABLE t1;
--echo # (duplicate) MDEV-24656
--echo # [FATAL] InnoDB: Data field type 0, len 0, ASAN heap-buffer-overflow
--echo # upon LOAD DATA with virtual columns
CREATE TABLE t1 (id INT PRIMARY KEY, a VARCHAR(2333),
va VARCHAR(171) AS (a)) ENGINE=InnoDB;
INSERT INTO t1 (id,a) VALUES (1,REPEAT('x',200));
--disable_ps2_protocol
SELECT id, va INTO OUTFILE 'load_t1' FROM t1;
--enable_ps2_protocol
--error ER_DATA_TOO_LONG
LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1 (id,va);
SELECT * FROM t1;
LOAD DATA INFILE 'load_t1' IGNORE INTO TABLE t1 (id,va);
DROP TABLE t1;
--let $datadir= `select @@datadir`
--remove_file $datadir/test/load_t1
CREATE TABLE t1 (id BIGINT PRIMARY KEY, a VARCHAR(2333),
va VARCHAR(171) AS (a)) ENGINE=InnoDB;
INSERT INTO t1 (id,a) VALUES (1,REPEAT('x',200));
--disable_ps2_protocol
SELECT id, va INTO OUTFILE 'load_t1' FROM t1;
--enable_ps2_protocol
--error ER_DATA_TOO_LONG
LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1 (id,va);
SELECT * FROM t1;
LOAD DATA INFILE 'load_t1' IGNORE INTO TABLE t1 (id,va);
# Cleanup
DROP TABLE t1;
--let $datadir= `select @@datadir`
--remove_file $datadir/test/load_t1
--echo # (duplicate) MDEV-24665
--echo # ASAN errors, assertion failures, corrupt values after failed
--echo # LOAD DATA into table with virtual/stored column
CREATE TABLE t1 (id INT PRIMARY KEY,
ts TIMESTAMP DEFAULT '1971-01-01 00:00:00',
c VARBINARY(8) DEFAULT '', vc VARCHAR(3) AS (c) STORED);
INSERT IGNORE INTO t1 (id,c) VALUES (1,'foobar');
--disable_ps2_protocol
SELECT id, ts, vc INTO OUTFILE 'load_t1' FROM t1;
--enable_ps2_protocol
--error 0,ER_DATA_TOO_LONG
LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1 (id, ts, vc);
INSERT IGNORE INTO t1 (id) VALUES (2);
# Cleanup
DROP TABLE t1;
--let $datadir= `select @@datadir`
--remove_file $datadir/test/load_t1
|