Skip to content

Commit ece2cf8

Browse files
MDEV-38752 [wip] check supertype
1 parent 82ba33a commit ece2cf8

18 files changed

+2252
-119
lines changed

mysql-test/suite/gcol/inc/gcol_keys.inc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ DROP TABLE t1;
370370
--echo #
371371
--echo # Test how optimizer picks indexes defined on a GC
372372
--echo #
373-
CREATE TABLE t1 (f1 int, gc int AS (f1 + 1) STORED, UNIQUE(gc));
373+
CREATE TABLE t1 (f1 int, gc bigint AS (f1 + 1) STORED, UNIQUE(gc));
374374
INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6);
375375
ANALYZE TABLE t1;
376376
--echo # Should use index
@@ -388,6 +388,7 @@ SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
388388
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
389389

390390
--echo # Check that expression isn't transformed for a disabled key
391+
--echo # TODO: despite IGNORE KEY (gc) it still prints "Cannot substitute"...
391392
--sorted_result
392393
SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
393394
EXPLAIN SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
@@ -411,7 +412,7 @@ EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0;
411412
DROP TABLE t1;
412413
--echo # Pick index with proper type
413414
CREATE TABLE t1 (f1 int,
414-
gc_int int AS (f1 + 1) STORED,
415+
gc_int bigint AS (f1 + 1) STORED,
415416
gc_date DATE AS (f1 + 1) STORED,
416417
KEY gc_int_idx(gc_int),
417418
KEY gc_date_idx(gc_date));
@@ -429,7 +430,7 @@ ANALYZE TABLE t1;
429430

430431
--sorted_result
431432
SELECT * FROM t1 WHERE f1 + 1 > 070707;
432-
--echo # INT column & index should be picked
433+
--echo # BIGINT column & index should be picked
433434
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707;
434435
--sorted_result
435436
SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);

mysql-test/suite/gcol/r/gcol_keys_innodb.result

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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));
344344
INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6);
345345
ANALYZE TABLE t1;
346346
Table Op Msg_type Msg_text
@@ -354,29 +354,30 @@ f1 gc
354354
9 10
355355
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7;
356356
id 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
358358
SELECT * FROM t1 WHERE f1 + 1 = 7;
359359
f1 gc
360360
6 7
361361
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7;
362362
id 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
364364
SELECT * FROM t1 WHERE f1 + 1 IN (7,5);
365365
f1 gc
366366
4 5
367367
6 7
368368
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5);
369369
id 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
371371
SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
372372
f1 gc
373373
4 5
374374
5 6
375375
6 7
376376
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
377377
id 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"...
380381
SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
381382
f1 gc
382383
4 5
@@ -419,7 +420,7 @@ f1 + 1 MAX(GC)
419420
10 10
420421
EXPLAIN SELECT f1 + 1, MAX(GC) FROM t1 GROUP BY f1 + 1;
421422
id 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
423424
EXPLAIN SELECT f1 + 1, MAX(GC)
424425
FROM t1 IGNORE KEY (gc) GROUP BY f1 + 1;
425426
id select_type table type possible_keys key key_len ref rows Extra
@@ -432,11 +433,11 @@ f1 gc
432433
9 10
433434
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0;
434435
id 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
436437
DROP TABLE t1;
437438
# Pick index with proper type
438439
CREATE TABLE t1 (f1 int,
439-
gc_int int AS (f1 + 1) STORED,
440+
gc_int bigint AS (f1 + 1) STORED,
440441
gc_date DATE AS (f1 + 1) STORED,
441442
KEY gc_int_idx(gc_int),
442443
KEY gc_date_idx(gc_date));
@@ -460,10 +461,10 @@ f1 gc_int gc_date
460461
70707 70708 2007-07-08
461462
80808 80809 2008-08-09
462463
90909 90910 2009-09-10
463-
# INT column & index should be picked
464+
# BIGINT column & index should be picked
464465
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707;
465466
id 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
467468
SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
468469
f1 gc_int gc_date
469470
101010 101011 2010-10-11
@@ -475,7 +476,7 @@ EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
475476
id select_type table type possible_keys key key_len ref rows Extra
476477
1 SIMPLE t1 ALL gc_int_idx NULL NULL NULL 18 Using where
477478
Warnings:
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`
479480
DROP TABLE t1;
480481
#
481482
# BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST
@@ -502,6 +503,8 @@ ORDER BY field1, field2;
502503
id select_type table type possible_keys key key_len ref rows Extra
503504
1 SIMPLE table1 ALL PRIMARY NULL NULL NULL 1 Using temporary; Using filesort
504505
1 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
505508
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
506509
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
507510
GROUP BY field1, field2;
@@ -513,6 +516,8 @@ GROUP BY field1, field2;
513516
id select_type table type possible_keys key key_len ref rows Extra
514517
1 SIMPLE table1 ALL PRIMARY NULL NULL NULL 1 Using temporary; Using filesort
515518
1 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
516521
DROP TABLE t1;
517522
#
518523
# Bug#21391781 ASSERT WHEN RUNNING ALTER TABLE ON A TABLE WITH INDEX

mysql-test/suite/gcol/r/gcol_keys_myisam.result

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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));
344344
INSERT INTO t1(f1) VALUES (1),(2),(0),(9),(3),(4),(8),(7),(5),(6);
345345
ANALYZE TABLE t1;
346346
Table Op Msg_type Msg_text
@@ -354,29 +354,30 @@ f1 gc
354354
9 10
355355
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7;
356356
id 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
358358
SELECT * FROM t1 WHERE f1 + 1 = 7;
359359
f1 gc
360360
6 7
361361
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 = 7;
362362
id 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
364364
SELECT * FROM t1 WHERE f1 + 1 IN (7,5);
365365
f1 gc
366366
4 5
367367
6 7
368368
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 IN(7,5);
369369
id 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
371371
SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
372372
f1 gc
373373
4 5
374374
5 6
375375
6 7
376376
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 BETWEEN 5 AND 7;
377377
id 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"...
380381
SELECT * FROM t1 IGNORE KEY (gc) WHERE f1 + 1 BETWEEN 5 AND 7;
381382
f1 gc
382383
4 5
@@ -432,11 +433,11 @@ f1 gc
432433
9 10
433434
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 7.0;
434435
id 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
436437
DROP TABLE t1;
437438
# Pick index with proper type
438439
CREATE TABLE t1 (f1 int,
439-
gc_int int AS (f1 + 1) STORED,
440+
gc_int bigint AS (f1 + 1) STORED,
440441
gc_date DATE AS (f1 + 1) STORED,
441442
KEY gc_int_idx(gc_int),
442443
KEY gc_date_idx(gc_date));
@@ -460,10 +461,10 @@ f1 gc_int gc_date
460461
70707 70708 2007-07-08
461462
80808 80809 2008-08-09
462463
90909 90910 2009-09-10
463-
# INT column & index should be picked
464+
# BIGINT column & index should be picked
464465
EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > 070707;
465466
id 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
467468
SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
468469
f1 gc_int gc_date
469470
101010 101011 2010-10-11
@@ -475,7 +476,7 @@ EXPLAIN SELECT * FROM t1 WHERE f1 + 1 > CAST(070707 AS DATE);
475476
id select_type table type possible_keys key key_len ref rows Extra
476477
1 SIMPLE t1 ALL gc_int_idx NULL NULL NULL 18 Using where
477478
Warnings:
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`
479480
DROP TABLE t1;
480481
#
481482
# BUG#21229846: WL8170: SIGNAL 11 IN JOIN::MAKE_SUM_FUNC_LIST
@@ -502,6 +503,8 @@ ORDER BY field1, field2;
502503
id select_type table type possible_keys key key_len ref rows Extra
503504
1 SIMPLE table1 system PRIMARY NULL NULL NULL 1
504505
1 SIMPLE table2 system PRIMARY NULL NULL NULL 1
506+
Warnings:
507+
Note 1105 Cannot substitute virtual column expression `table1`.`col_int_key` + 1 -> col_int_gc_key due to potential truncation
505508
SELECT table1.col_int_key + 1 AS field1, table2.col_int_key AS field2
506509
FROM (t1 AS table1 JOIN t1 AS table2 ON (table2.pk = table1.pk))
507510
GROUP BY field1, field2;
@@ -513,6 +516,8 @@ GROUP BY field1, field2;
513516
id select_type table type possible_keys key key_len ref rows Extra
514517
1 SIMPLE table1 system PRIMARY NULL NULL NULL 1
515518
1 SIMPLE table2 system PRIMARY NULL NULL NULL 1
519+
Warnings:
520+
Note 1105 Cannot substitute virtual column expression `table1`.`col_int_key` + 1 -> col_int_gc_key due to potential truncation
516521
DROP TABLE t1;
517522
#
518523
# Bug#21391781 ASSERT WHEN RUNNING ALTER TABLE ON A TABLE WITH INDEX

0 commit comments

Comments
 (0)