@@ -385,6 +385,36 @@ SELECT COLUMN_GET(@aaa, 'price' AS DECIMAL) aaa;
385385SELECT COLUMN_GET(@aaa, 'price' AS INT) aaa;
386386SELECT COLUMN_GET(@aaa, 'price' AS DOUBLE) aaa;
387387
388+
389+ --echo #
390+ --echo # MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
391+ --echo #
392+
393+ SET sql_mode=STRICT_ALL_TABLES;
394+ CREATE OR REPLACE TABLE t1 (
395+ a INT NOT NULL DEFAULT 10,
396+ b INT AS (a+1) VIRTUAL
397+ ) ENGINE=MyISAM;
398+
399+ # Testing with a column list
400+
401+ --error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
402+ INSERT INTO t1 (b) VALUES (10);
403+ --error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
404+ INSERT INTO t1 (b) VALUES (DEFAULT(a));
405+ INSERT INTO t1 (b) VALUES (DEFAULT);
406+
407+ # Testing without a column list
408+ --error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
409+ INSERT INTO t1 VALUES (10,10);
410+ --error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
411+ INSERT INTO t1 VALUES (10,DEFAULT(a));
412+ INSERT INTO t1 VALUES (10, DEFAULT);
413+
414+ DROP TABLE t1;
415+ SET sql_mode=DEFAULT;
416+
417+
388418--echo #
389419--echo # End of 10.1 tests
390420--echo #
@@ -442,6 +472,37 @@ REPLACE INTO t1 (pk,i) VALUES (1,2);
442472DROP TABLE t1;
443473SET @sql_mode=@old_sql_mode;
444474
475+ --echo #
476+ --echo # MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
477+ --echo # 10.2+ specific part
478+ --echo #
479+
480+ SET sql_mode=STRICT_ALL_TABLES;
481+ CREATE OR REPLACE TABLE t1 (
482+ a INT NOT NULL DEFAULT 10,
483+ b INT AS (a+1) VIRTUAL
484+ ) ENGINE=MyISAM;
485+
486+ # Testing with column list
487+
488+ EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING DEFAULT;
489+ EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING IGNORE;
490+ INSERT INTO t1 (b) VALUES (DEFAULT);
491+ INSERT INTO t1 (b) VALUES (IGNORE);
492+ SELECT * FROM t1;
493+ DELETE FROM t1;
494+
495+ # Testing without column list
496+
497+ EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(10,?)' USING DEFAULT;
498+ EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(11,?)' USING IGNORE;
499+ INSERT INTO t1 VALUES (12,DEFAULT);
500+ INSERT INTO t1 VALUES (13,IGNORE);
501+ SELECT * FROM t1;
502+
503+ DROP TABLE t1;
504+ SET sql_mode=DEFAULT;
505+
445506--echo #
446507--echo # End of 10.2 tests
447508--echo #
0 commit comments