-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ddl: fix Incorrect behavior of NO_ZERO_DATE when altering table #21564
base: master
Are you sure you want to change the base?
Conversation
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
/run-tics-test |
@XuHuaiyu Hello,I am a little confused why the execution of |
We have some internal tests that run in addition to the unit tests. The log seems to show that the test is failing because it relied on the previous behavior:
I will take a look at this for you. |
@morgo thx😊 |
Here is a simplified version of the test (it's an end-to-end test, testing tiflash among other things..). I have ran the queries against MySQL 8.0 and commented where they break, but not against your branch yet. I think some of the tests look really helpful though, you may want to include them in your tests: drop table if exists test.t;
create table test.t(a int);
insert into test.t values (1);
alter table test.t add date_0 DATE NULL DEFAULT '1000-01-01';
alter table test.t add date_1 DATE NULL DEFAULT '9999-12-31';
alter table test.t add date_a DATE NOT NULL; -- fails on MySQL
alter table test.t add time_0 TIME NULL DEFAULT '59';
alter table test.t add time_1 TIME(6) NULL DEFAULT '-838:59:59.000000';
alter table test.t add time_2 TIME(6) NULL DEFAULT '838:59:59.000000';
alter table test.t add time_3 TIME(6) NULL DEFAULT '0';
alter table test.t add time_a TIME NOT NULL;
alter table test.t add time_b TIME(6) NOT NULL;
alter table test.t add datetime_0 DATETIME(6) NULL DEFAULT '1000-01-01 00:00:00.000000';
alter table test.t add datetime_1 DATETIME(6) NULL DEFAULT '9999-12-31 23:59:59.000000';
alter table test.t add datetime_a DATETIME NOT NULL; -- fails on MySQL
alter table test.t add datetime_b DATETIME(6) NOT NULL; -- fails on MySQL
select * from test.t;
+------+------------+------------+------------+----------+-------------------+------------------+-----------------+----------+-----------------+----------------------------+----------------------------+---------------------+----------------------------+
| a | date_0 | date_1 | date_a | time_0 | time_1 | time_2 | time_3 | time_a | time_b | datetime_0 | datetime_1 | datetime_a | datetime_b |
+------+------------+------------+------------+----------+-------------------+------------------+-----------------+----------+-----------------+----------------------------+----------------------------+---------------------+----------------------------+
| 1 | 1000-01-01 | 9999-12-31 | 0000-00-00 | 00:00:59 | -838:59:59.000000 | 838:59:59.000000 | 00:00:00.000000 | 00:00:00 | 00:00:00.000000 | 1000-01-01 00:00:00.000000 | 9999-12-31 23:59:59.000000 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00.000000 |
+------+------------+------------+------------+----------+-------------------+------------------+-----------------+----------+-----------------+----------------------------+----------------------------+---------------------+----------------------------+
drop table if exists test.t;
create table test.t(a int);
insert into test.t values (1);
alter table test.t add timestamp_a TIMESTAMP NOT NULL;
alter table test.t add timestamp_b TIMESTAMP(6) NOT NULL;
select * from test.t;
+------+---------------------+----------------------------+
| a | timestamp_a | timestamp_b |
+------+---------------------+----------------------------+
| 1 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00.000000 |
+------+---------------------+----------------------------+
drop table if exists test.t;
create table test.t(a int);
insert into test.t values (1);
alter table test.t add year_0 YEAR NULL DEFAULT '1901';
alter table test.t add year_1 YEAR NULL DEFAULT '2155';
alter table test.t add year_2 YEAR NULL DEFAULT '0000';
alter table test.t add year_3 YEAR NULL DEFAULT '01';
alter table test.t add year_4 YEAR NULL DEFAULT '70';
alter table test.t add year_5 YEAR NULL DEFAULT '00';
alter table test.t add year_a YEAR NOT NULL;
select * from test.t;
+------+--------+--------+--------+--------+--------+--------+--------+
| a | year_0 | year_1 | year_2 | year_3 | year_4 | year_5 | year_a |
+------+--------+--------+--------+--------+--------+--------+--------+
| 1 | 1901 | 2155 | 0000 | 2001 | 1970 | 2000 | 0000 |
+------+--------+--------+--------+--------+--------+--------+--------+ |
/run-tics-test tics=pr/1273 |
/run-all-tests tics=pr/1273 |
It looks like the bot doesn't accept the hint for |
I think I need to add restrictions on the |
Hi @sev7ndayyoo , thanks for trying to solve this issue! There are some cases we need to consider:
|
@7yyo: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@7yyo: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@7yyo: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: close #11952
Problem Summary:
In
NO_ZERO_DATE
, addcolumn
default
NOT NULL
is not allowed.Not in
NO_ZERO_DATE
in contrast.What is changed and how it works?
Related changes
pingcap/docs
/pingcap/docs-cn
:Release note
NO_ZERO_DATE
when altering table