[MDEV-30965] Odd behavior with default timestamps and check constraints creates invalid table Created: 2023-03-29 Updated: 2023-11-28 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table, Temporal Types |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I need some help categorizing this issue, as I'm not sure where the "legacy design" ends and the unexpected behavior starts. There can also be more than one problem here. The results are for 11.0 with
although it behaves the same way with explicit_defaults_for_timestamp=OFF. In the test case below, the table t1 is first created with a current_timestamp as a default for a non-null datetime column. It gets created correctly, as expected.
Then ALTER TABLE attempts to drop the default. ALTER ends without warnings or errors, but the resulting table still has a default for the column:
I would say that in case of explicit_defaults_for_timestamp=ON it is already a problem, but given MDEV-28983, I'm not completely sure. The next ALTER adds a column with a CHECK constraint referring to this existing column, and puts the new column before the existing one. It gets added successfully.
But the resulting structure is invalid. If we try to create such a table directly, it fails:
So I'd say it's another problem, either ALTER should not succeed if it creates an invalid structure, or this structure should be valid. But I can't figure out why it is important that the table has a fake current_timestamp, and why it doesn't fail when the table simply does not have a default from the start. The resulting incorrect structure of course makes any further mysqldump output invalid or, in the test case here, causes a replication failure.
But I don't believe that replication is to blame here.
|