@@ -340,7 +340,7 @@ DROP TABLE t1;
340340#
341341# Test how optimizer picks indexes defined on a GC
342342#
343- CREATE TABLE t1 (f1 int, gc int AS (f1 + 1) STORED, UNIQUE(gc));
343+ CREATE TABLE t1 (f1 int, gc bigint AS (f1 + 1) STORED, UNIQUE(gc));
344344INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6);
345345ANALYZE TABLE t1;
346346Table Op Msg_type Msg_text
@@ -354,29 +354,30 @@ f1 gc
3543549 10
355355EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7;
356356id select_type table type possible_keys key key_len ref rows Extra
357- 1 SIMPLE t1 range gc gc 5 NULL 3 Using index condition
357+ 1 SIMPLE t1 range gc gc 9 NULL 3 Using index condition
358358SELECT * FROM t1 WHERE f1 + 1 = 7;
359359f1 gc
3603606 7
361361EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7;
362362id select_type table type possible_keys key key_len ref rows Extra
363- 1 SIMPLE t1 const gc gc 5 const 1
363+ 1 SIMPLE t1 const gc gc 9 const 1
364364SELECT * FROM t1 WHERE f1 + 1 IN (7,5);
365365f1 gc
3663664 5
3673676 7
368368EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5);
369369id select_type table type possible_keys key key_len ref rows Extra
370- 1 SIMPLE t1 range gc gc 5 NULL 2 Using index condition
370+ 1 SIMPLE t1 range gc gc 9 NULL 2 Using index condition
371371SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
372372f1 gc
3733734 5
3743745 6
3753756 7
376376EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
377377id select_type table type possible_keys key key_len ref rows Extra
378- 1 SIMPLE t1 range gc gc 5 NULL 3 Using index condition
378+ 1 SIMPLE t1 range gc gc 9 NULL 3 Using index condition
379379# Check that expression isn't transformed for a disabled key
380+ # TODO: despite IGNORE KEY (gc) it still prints "Cannot substitute"...
380381SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
381382f1 gc
3823834 5
@@ -419,7 +420,7 @@ f1 + 1 MAX(GC)
41942010 10
420421EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
421422id select_type table type possible_keys key key_len ref rows Extra
422- 1 SIMPLE t1 index NULL gc 5 NULL 10
423+ 1 SIMPLE t1 index NULL gc 9 NULL 10
423424EXPLAIN SELECT f1 + 1, MAX(GC)
424425FROM t1 IGNORE KEY (gc) GROUP BY f1 + 1;
425426id select_type table type possible_keys key key_len ref rows Extra
@@ -432,11 +433,11 @@ f1 gc
4324339 10
433434EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0;
434435id select_type table type possible_keys key key_len ref rows Extra
435- 1 SIMPLE t1 range gc gc 5 NULL 3 Using index condition
436+ 1 SIMPLE t1 range gc gc 9 NULL 3 Using index condition
436437DROP TABLE t1;
437438# Pick index with proper type
438439CREATE TABLE t1 (f1 int,
439- gc_int int AS (f1 + 1) STORED,
440+ gc_int bigint AS (f1 + 1) STORED,
440441gc_date DATE AS (f1 + 1) STORED,
441442KEY gc_int_idx(gc_int),
442443KEY gc_date_idx(gc_date));
@@ -460,10 +461,10 @@ f1 gc_int gc_date
46046170707 70708 2007-07-08
46146280808 80809 2008-08-09
46246390909 90910 2009-09-10
463- # INT column & index should be picked
464+ # BIGINT column & index should be picked
464465EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707;
465466id select_type table type possible_keys key key_len ref rows Extra
466- 1 SIMPLE t1 range gc_int_idx gc_int_idx 5 NULL 4 Using index condition
467+ 1 SIMPLE t1 range gc_int_idx gc_int_idx 9 NULL 4 Using index condition
467468SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
468469f1 gc_int gc_date
469470101010 101011 2010-10-11
@@ -475,7 +476,7 @@ EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
475476id select_type table type possible_keys key key_len ref rows Extra
4764771 SIMPLE t1 ALL gc_int_idx NULL NULL NULL 18 Using where
477478Warnings:
478- Note 1105 Cannot use key `gc_int_idx` part[0] for lookup: `test`.`t1`.`gc_int` of type `int ` > "cast(70707 as date)" of type `date`
479+ Note 1105 Cannot use key `gc_int_idx` part[0] for lookup: `test`.`t1`.`gc_int` of type `bigint ` > "cast(70707 as date)" of type `date`
479480DROP TABLE t1;
480481#
481482# BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST
@@ -502,6 +503,8 @@ ORDER BY field1, field2;
502503id select_type table type possible_keys key key_len ref rows Extra
5035041 SIMPLE table1 ALL PRIMARY NULL NULL NULL 1 Using temporary; Using filesort
5045051 SIMPLE table2 eq_ref PRIMARY PRIMARY 4 test.table1.pk 1
506+ Warnings:
507+ Note 1105 Cannot substitute virtual column expression `table1`.`col_int_key` + 1 -> col_int_gc_key due to potential truncation
505508SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
506509FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
507510GROUP BY field1, field2;
@@ -513,6 +516,8 @@ GROUP BY field1, field2;
513516id select_type table type possible_keys key key_len ref rows Extra
5145171 SIMPLE table1 ALL PRIMARY NULL NULL NULL 1 Using temporary; Using filesort
5155181 SIMPLE table2 eq_ref PRIMARY PRIMARY 4 test.table1.pk 1
519+ Warnings:
520+ Note 1105 Cannot substitute virtual column expression `table1`.`col_int_key` + 1 -> col_int_gc_key due to potential truncation
516521DROP TABLE t1;
517522#
518523# Bug#21391781 ASSERT WHEN RUNNING ALTER TABLE ON A TABLE WITH INDEX
0 commit comments