mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-19611 INPLACE ALTER does not fail on bad implicit default value
- Inplace alter shouldn't set default date column as '0000-00-00' when table is not empty. So mysql_inplace_alter_table() copied alter_ctx.error_if_not_empty to a new field of Alter_inplace_info. In ha_innobase::check_if_supported_inplace_alter() should check the error_if_not_empty flag and return INPLACE_NOT_SUPPORTED if the table is not empty
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_sequence.inc
|
||||
|
||||
CREATE TABLE t1 (i1 INT UNSIGNED NULL DEFAULT 42) ENGINE=innodb;
|
||||
INSERT INTO t1 VALUES(NULL);
|
||||
@ -82,3 +83,23 @@ ALTER TABLE t1 ADD COLUMN d4 TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
|
||||
SELECT COUNT(DISTINCT d4),COUNT(d4),COUNT(*) FROM t1;
|
||||
SELECT DISTINCT (CURRENT_TIMESTAMP()-d4) <= 60 FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# MDEV-19611 INPLACE ALTER does not fail on bad implicit default value
|
||||
|
||||
# Empty-table
|
||||
CREATE TABLE t1(f1 int) ENGINE=InnoDB;
|
||||
INSERT INTO t1 SELECT * FROM seq_1_to_4096;
|
||||
connect(purge_control,localhost,root,,);
|
||||
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||
|
||||
connection default;
|
||||
DELETE FROM t1;
|
||||
SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES,NO_ZERO_DATE';
|
||||
ALTER TABLE t1 ADD f2 DATE NOT NULL, ALGORITHM=INPLACE;
|
||||
|
||||
# Non-empty table
|
||||
INSERT INTO t1 VALUES (1, now());
|
||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
||||
ALTER TABLE t1 ADD f3 DATE NOT NULL, ALGORITHM=INPLACE;
|
||||
DROP TABLE t1;
|
||||
disconnect purge_control;
|
||||
|
Reference in New Issue
Block a user