Skip to content

mysql_innodb_catalog: explicitly create TIMESTAMP columns as NOT NULL

Jérome Perrin requested to merge fix/create_table_timestamp into master

Between mariadb 10.4 and 11.8 [1], the value of explicit_defaults_for_timestamp system variable has changed, it is now ON. This means that on mariadb 10.4, creating a table with

CREATE TABLE `t` (
  `timestamp` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)

created a NOT NULL column, but on mariadb 11.8 this creates a NULL column.

Because the upgrader creates a temporary table with the create table SQL and compare against the existing table, when updating from mariadb 10 to mariadb 11 it detects that catalog.timestamp is now a nullable column and runs a big alter table on the whole catalog table.

Setting this explicitly as NOT NULL keeps the same behavior on both mariadb version.

[1] https://mariadb.com/docs/server/server-management/variables-and-modes/server-system-variables#explicit_defaults_for_timestamp

Merge request reports