MariaDB 10.6 doesn't respect the foreign_key_checks setting when creating a table with check constraints

224 views Asked by At

I'm trying to import database tables from a file of table definitions. Near the top, there is a line setting foreign_key_checks to 0, so that no errors would be thrown because of tables that reference other not-yet-created tables.

With an older version of MariaDB, this all worked fine.

However, with MariaDB 10.6 or later, when creating a table that has a check constraint referencing a table that does not yet exist, it throws an error even when this setting is set to 0.

Just a note here, that creating actual foreign keys on a new table that point to a non-existing table do not fail, only check constraints fail.

The SQL file was created with Adminer.

One solution could be to manually comment out the check constraints in the "create table" statements, and add them at the bottom of the file in "alter table" statements, but I would prefer to not do this, as it requires manual intervention.

Any ideas for workarounds or solutions?

1

There are 1 answers

0
Magmatic On

The problem I was actually encountering was this bug:

https://jira.mariadb.org/browse/MDEV-31769

So maybe the work-around is to get that bug fixed.